Fix nil pointer panic when Flight SQL worker crashes during active session#223
Merged
fuziontech merged 3 commits intomainfrom Feb 17, 2026
Merged
Fix nil pointer panic when Flight SQL worker crashes during active session#223fuziontech merged 3 commits intomainfrom
fuziontech merged 3 commits intomainfrom
Conversation
…ssion arrow-go's flight.Client.Close() nils out the embedded FlightServiceClient. When a worker crashes, the health check goroutine closes the shared gRPC client while session goroutines are still using it, causing a nil pointer dereference in GetFlightInfo that crashes the entire control plane. Fix with two layers of defense: - Add atomic `dead` flag to FlightExecutor, checked before any RPC call - Add recover() in QueryContext/ExecContext to catch the panic in the race window between the flag check and the actual RPC - Mark all affected executors dead in OnWorkerCrash before the client is closed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…add tests 1. Narrow recoverClientPanic to only catch nil pointer dereferences; re-panic on unrelated errors to preserve stack traces. 2. Add recoverWorkerPanic to ManagedWorker.CreateSession and DestroySession which access the shared gRPC client directly (same crash class). 3. Proactively close TCP connections on worker crash via connCloser so session goroutines exit cleanly instead of looping on ErrWorkerDead. 4. Add 16 unit tests covering MarkDead, recover behavior (nil pointer vs other panics), OnWorkerCrash session/connection cleanup, and SetConnCloser. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add recoverWorkerPanic to the doHealthCheck call in HealthCheckLoop. Same race: w.client.Close() from a concurrent crash/retire nils out FlightServiceClient while the health check goroutine calls DoAction. - Replace nil contexts with context.Background() in tests. - Add TestDestroySessionAfterOnWorkerCrash to verify the exact production sequence: OnWorkerCrash cleans up, then the deferred DestroySession is a safe no-op. - Add comment explaining intentional double-close of TCP connection (OnWorkerCrash + handleConnection defer). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
flight.(*client).Close()setsFlightServiceClient = nilon the internal struct. Since sessions share the worker's gRPC client (NewFlightExecutorFromClient), the health check goroutine closing the dead worker's client races with session goroutines still making RPCs on itdeadflag toFlightExecutorthat's checked before any RPC, plusrecover()as belt-and-suspenders for the race window between the flag check and the gRPC callOnWorkerCrashnow marks all affected executors dead before the health check closesw.clientTest plan
go test ./...—TestDefaultMaxWorkersfailure is pre-existing/CPU-count dependent)🤖 Generated with Claude Code