Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove nullableBoundary LP; replace with executable boundaries #2391

Draft
wants to merge 170 commits into
base: main
Choose a base branch
from

Conversation

benjie
Copy link
Member

@benjie benjie commented Feb 26, 2025

I've determined that I should be able to do this after the launch of V5, so I'm going to postpone it. This current code is a proof of concept that passes the tests, but it's based on the incorrect concept that a step itself can be a "nullable boundary" (now called an executable boundary) which isn't accurate since it's only a nullable boundary in a particular context (i.e. one path through the planning tree) but may not be an executable boundary in other paths through the tree.

Instead, the plan is to make it so that each call to planIntoOutputPlan (i.e. planning of either a field or a list item) will have with it a execution boundary step that represents the parent; then any steps created during the planning of that field/list position will implicitly be dependent on this executable boundary, and come execution time steps will check their executable boundary for null/error values, and will result in an execution values with the STOPPED flag without needing to actually execute.

There's a lot of subtlety in this, particularly around the deduplicate, optimize, hoist and pushDown lifecycle steps, so after spending a good few hours thinking about it I've decided to put off the transition until later. The POC suggests that this won't be a breaking change for downstream code, so we should be able to do it in 5.1 or similar if we want.

From my notes:

  • track nullable boundary steps as we plan the document, rather than storing onto steps directly. New name: "EXECUTABLE BOUNDARY" - sub all "nullable boundary" with "executable boundary" below.
    • LayerPlan gains currentNullableBoundary
    • On planField / planListItem/etc, set the nullable boundary to be current step
    • When add dependency on nullable boundary, rejectNull
    • Side effect steps need to be dependent on nullable boundary
    • Nullable boundary must be copied into layer plans as necessary
    • Execution of layer plans should be ordered such that steps execute after their nullable boundary
    • Nullable boundary becomes an "implicit" dependency of a step, if it is null/error, step should become STOPPED.
    • On step construction:
      • Store the relevant nullable boundary (i.e. it has to be related to its dependencies?)
    • On dedupe:
      • Nullable boundary step should align
      • Resulting step should get the "merged" set of nullable boundaries from all replaced steps + self.
        • Step will only stop execution if ALL merged nullable boundaries fail.
      • Peers must have the same flags (already the case)
    • Step cache should invalidate when nullable boundary changes (?)
    • On optimize:
      • New steps should copy the nullable boundary
      • Resulting step should have the same nullable boundary as original step.
    • On tree shake:
      • Nullable boundaries cannot be discarded
    • On plan finalized:
      • Update all nullable boundary steps to be the current version of themself
      • Resolve nullable boundaries so that only the ones "before" the step still exist (BEWARE: side effect steps!)
        • step.nullableBoundaries = step.nullableBoundaries.filter(nb => step.canDependOn(nb))
        • If execution boundary is already checked by a dependency, it can be removed
    • On execute:
      • When step depends on a nullable boundary, and that boundary step is null or error, step should become "super inhibit" (i.e. FLAG_STOPPED)

Copy link

changeset-bot bot commented Feb 26, 2025

🦋 Changeset detected

Latest commit: 8f13f4f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
graphile-build Patch
graphile-build-pg Patch
postgraphile Patch
@dataplan/pg Patch
graphile-utils Patch
pgl Patch
graphile Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@benjie benjie changed the base branch from main to disable-eval February 26, 2025 13:29
@benjie benjie force-pushed the disable-eval branch 2 times, most recently from 1bbb7b9 to 0fc2db9 Compare March 10, 2025 18:07
Base automatically changed from disable-eval to main March 12, 2025 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🌳 Triage
Development

Successfully merging this pull request may close these issues.

1 participant