Skip to content

Wait for worker query close before session reuse#751

Merged
bill-ph merged 8 commits into
mainfrom
codex/wait-worker-close-before-session-reuse
Jun 10, 2026
Merged

Wait for worker query close before session reuse#751
bill-ph merged 8 commits into
mainfrom
codex/wait-worker-close-before-session-reuse

Conversation

@bill-ph

@bill-ph bill-ph commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fix the worker query close lifecycle so the control plane does not reuse a worker session until the worker has acknowledged that the previous Flight SQL DoGet operation released its server-side operation state.

Previously, FlightRowSet.Close cancelled the worker DoGet stream and returned after releasing the local reader. The worker could still be unwinding its DoGet goroutine and holding the session operation token, so the next same-session query could race into the worker and fail with FailedPrecondition.

This PR adds a small worker WaitSessionIdle action and has FlightRowSet.Close call it after cancelling the stream. That makes close/cancel completion explicit instead of relying on optimistic gRPC cancellation timing.

Changes

  • Add WorkerWaitSessionIdlePayload and a WaitSessionIdle worker action.
  • Track an operation idle signal on worker sessions and wait on it without polling.
  • Make FlightRowSet.Close wait for the worker idle acknowledgement before returning.
  • Add deterministic unit coverage for the client close wait and worker action blocking behavior.
  • Document why this cleanup-window race is unit-covered rather than asserted in the e2e harness.

Tests

  • go test ./server/flightclient -run TestFlightRowSetCloseWaitsForWorkerDoGetCleanup -count=1
  • go test ./duckdbservice -run TestWaitSessionIdleBlocksUntilOperationReleases -count=1
  • go test ./server/flightclient ./duckdbservice -count=1
  • go test ./server/flightsqlingress -count=1
  • just lint
  • just test-unit

@bill-ph bill-ph merged commit 47a6dcd into main Jun 10, 2026
26 of 27 checks passed
@bill-ph bill-ph deleted the codex/wait-worker-close-before-session-reuse branch June 10, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant