Skip to content

fix(controlplane): prevent connection drops during zero-downtime handover#200

Merged
fuziontech merged 1 commit intomainfrom
fix/handover-drain-race
Feb 14, 2026
Merged

fix(controlplane): prevent connection drops during zero-downtime handover#200
fuziontech merged 1 commit intomainfrom
fix/handover-drain-race

Conversation

@fuziontech
Copy link
Member

Summary

  • When the PG listener is closed during handover, acceptLoop returned, causing RunControlPlane()main() to exit and kill all in-flight connection goroutines before the drain logic in handleHandoverRequest could complete
  • Fix: replace return with select {} so the main goroutine blocks until the handover/shutdown handler calls os.Exit(0) after properly draining connections
  • Added TestHandoverDrainsBeforeExit regression test that holds an idle connection open during handover and verifies the old CP stays alive to drain it

Test plan

  • TestHandoverDrainsBeforeExit passes with fix, fails without it
  • All 9 existing handover tests pass
  • Deploy to canary and verify systemctl reload duckgres preserves active psql sessions

🤖 Generated with Claude Code

… handover drain

When the PG listener is closed during handover, acceptLoop's `return` caused
RunControlPlane() → main() to exit, killing all in-flight connection goroutines
before the drain logic in handleHandoverRequest could complete. Replace `return`
with `select {}` so the main goroutine blocks until the handover handler (or
shutdown handler) calls os.Exit(0) after properly draining connections.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fuziontech fuziontech enabled auto-merge (squash) February 14, 2026 01:47
@fuziontech fuziontech merged commit 8044062 into main Feb 14, 2026
11 checks passed
@fuziontech fuziontech deleted the fix/handover-drain-race branch February 14, 2026 01:48
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