You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WorkerSessionManager: overlapping ensureWorker() calls during SRV preparation can orphan a worker #1002
Found in the PR #997 review (finding P5, latent, low severity).
Problem
WorkerSessionManager.initializeWorker() now awaits prepareDriverConnectionString() (the SRV probe and, if needed, the DNS fallback) before it assigns _worker. ensureWorker() decides whether to spawn with !this._worker || this._workerState === 'idle'.
If a second ensureWorker() call arrives while SRV preparation is still running, it starts a second spawn:
it replaces _startupAbortController without aborting the first one;
both startups create a Worker; the second assignment overwrites _worker;
the first worker thread, and its client, are never terminated.
Before PR #997 there was no await between the check and the assignment, so the window did not exist.
Why it does not happen today
Current callers serialize: the query playground checks isExecuting(clusterId), and the shell calls initialize() once. PR #997 records this with a one-line comment in ensureWorker().
Proposed fix (option A from the review)
Track the in-flight startup:
keep the spawn promise and its clusterId;
a same-cluster call awaits the in-flight promise instead of spawning;
a different-cluster call calls terminateWorker() first (which already aborts the startup controller), then spawns.
This also stops a second caller from sending eval to a worker that is still starting.
Tests: two overlapping ensureWorker() calls for the same cluster create one worker; overlapping calls for different clusters abort the first startup and leave exactly one worker.
Activity
docs(srv): record PR #997 review decisions and fixes