Repository navigation
feat(dev): run er-dispatcher as its own process, like the chart does - #630
Merged
Merged
Conversation
`frontend/dev/env.sh` set `ER_DISPATCH_IN_PROCESS=1`, so the local stack ran
one process serving the API and draining the queue. Phase 4 of the
batch-orchestration design deletes that flag with the legacy arm, and the
design already settled where local dev lands: "`make run` stays for API-only
work and loses `ER_DISPATCH_IN_PROCESS` in Phase 4."
So `up.sh` starts `er-dispatcher` beside er-server. That is the topology the
chart ships — a separate dispatcher Deployment — and local dev should not be
the last place a retired one survives. Three things make it a small change
rather than a port: there is a real `[[bin]] er-dispatcher` target, so no
`argv[0]` trickery is needed outside the image; `env.sh` already exports the
`ER_PG_DSN` the dispatcher reads; and the chart's own Deployment is the proof
the daemon runs standalone.
**No boot ordering is required, and that is a property rather than a hope.**
`er_server::pg::ensure_schema` opens with
`pg_advisory_xact_lock(hashtext('erserver.ensure_schema'), 0)`, so concurrent
ensures serialise instead of deadlocking. That lock is what retired the
API-strictly-before-dispatcher dance the Python stack needed, where the
dispatcher's long-lived leader connection blocked the API's DDL forever.
**The half-up state is reachable again, so it is checked again.** With the
dispatcher in-process, "the API answers" implied "the queue is being drained",
and `run.sh`'s detection of a live-API-no-dispatcher stack was deleted as
unreachable. Two processes bring it back: a dispatcher that dies leaves every
job in `queued` forever while the API keeps answering, and nothing about the
API says so. That silence is the original bug the check existed to name, so
`up.sh` asserts the dispatcher survived boot and prints its log when it did
not. The dispatcher is a daemon with no port, so liveness is the process plus
the absence of an early exit.
The flag is left OUT of env.sh rather than set to 0, with a comment saying
where it went; `cleanup` stops both processes, and the three header comments
that described the one-process topology now describe this one.
Co-Authored-By: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
frontend/dev/env.shsetER_DISPATCH_IN_PROCESS=1, so the local stack ran one process serving the API and draining the queue. Phase 4 of the batch-orchestration design deletes that flag with the legacy arm — and the design had already settled where local dev lands:So
up.shstartser-dispatcherbeside er-server: the topology the chart ships (a separate dispatcher Deployment), rather than leaving local dev as the last place a retired one survives.Three things make this a small change rather than a port:
[[bin]] er-dispatchertarget, so noargv[0]trickery is needed outside the image;env.shalready exports theER_PG_DSNthe dispatcher reads;No boot ordering is required, and that's a property rather than a hope
er_server::pg::ensure_schemaopens withpg_advisory_xact_lock(hashtext('erserver.ensure_schema'), 0), so concurrent ensures serialise instead of deadlocking. That lock is what retired the API-strictly-before-dispatcher dance the Python stack needed, where the dispatcher's long-lived leader connection blocked the API's DDL forever.(It also makes a note of mine stale — I had "start the API before the dispatcher or
ensure_schemahangs" recorded, which was true before that lock landed.)The half-up state is reachable again, so it's checked again
With the dispatcher in-process, "the API answers" implied "the queue is being drained", and
run.sh's detection of a live-API-no-dispatcher stack was deleted as unreachable.Two processes bring it back: a dispatcher that dies leaves every job in
queuedforever while the API keeps answering, and nothing about the API says so. That silence is the original bug the check existed to name — soup.shasserts the dispatcher survived boot and prints its log when it didn't. The dispatcher is a daemon with no port, so liveness is the process plus the absence of an early exit.This is the honest cost of the change, and I'd rather pay it with a check than pretend the state is still unreachable.
Details
The flag is left out of
env.shrather than set to0, with a comment saying where it went.cleanupstops both processes. The three header comments that described the one-process topology now describe this one.Verified: both binaries build (
cargo build --bin er-server --bin er-dispatcher), all three scripts passbash -n, andmake checkis green.Pairs with #629, which fixes the regression I found while implementing the other half of this Phase 4 decision.
🤖 Generated with Claude Code