Repository navigation
fix(engine): await worker/boss onStart before EngineManager registration - #1760
Merged
Merged
Conversation
Since #1757 the worker registry is built inside EngineWorker.onStart on the worker thread, but EngineWorker.doStart returned as soon as the thread was started. Engine.start then proceeded to start the EngineManager, whose file watch could fire register before the worker's onStart had run, producing an NPE on EngineWorker.attach when this.registry was still null. Add a CountDownLatch in EngineWorker and EngineBoss that is counted down at the end of onStart (in a finally so init failures still release the latch) and awaited at the end of doStart, making startup ordering deterministic. https://claude.ai/code/session_01RXTcFJG39snE5KhLkMSALD
7 tasks done
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.
Summary
Fixes an NPE introduced by #1757 that surfaces in
binding-pgsql-kafka(ProxyIT.shouldDropTopicand others):After #1757,
EngineWorkerbuilds itsregistry(and the per-worker binding/guard/vault/catalog/store/model/metric contexts) insideonStart, on the worker thread, so handlersupply(this)calls happen on the owning thread. ButEngineWorker.doStartwas fire-and-forget — it returned as soon asstartOnThreadhad launched the runner, before the runner had reachedonStart.Engine.startthen proceeded to startEngineManager, whose config watch could fireregisterand callEngineWorker.attach(namespace)→registry.attach(namespace)against a worker whoseonStarthadn't yet run, producing the NPE. The pre-#1757 code happened to be safe only because all of that initialization ran in the constructor.The fix makes startup ordering deterministic with a
CountDownLatchper worker / boss:onStartin afinally(so init failures still release the latch —awaitreturns and the runner's error handler surfaces the real exception).doStartbefore returning.EngineBosscurrently has no work inonStart, but adding the symmetric scaffolding keeps the worker/boss lifecycle consistent and protects against future asymmetric init.Test plan
./mvnw -pl runtime/engine clean install— 320 unit + 204 ITs pass; JaCoCo coverage check passes./mvnw -pl incubator/binding-pgsql-kafka clean verify—ProxyIT5/5 pass (previously 4 run with 3 errors)./mvnw -pl runtime/binding-http -am clean verify— green./mvnw -pl runtime/engine checkstyle:check— cleanhttps://claude.ai/code/session_01RXTcFJG39snE5KhLkMSALD
Generated by Claude Code