Repository navigation
fix: drain proxy connection work during shutdown - #33104
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
This pull request is merged. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: b2d1708bec7d79e331418327490e2ad7960950e8
Assessment: request_changes
The shutdown path reuses Goetty’s handler join and preserves the existing cache handoff. The race suite and embedded SQL tests passed. One regression remains in ordinary disconnect logging.
Model: gpt-6.2-sol / xhigh
Session: 01a1ee80-0d82-7030-a965-b51f496c3054 · slot 2 · generation 1
- P3
pkg/proxy/handler.go:291: A plaintext client disconnects normally after a successful query.
Impact: Routine disconnects emit a misleading ERROR log. On proxies with high connection turnover, those entries can obscure genuine failures.
Evidence: The handler closes the raw socket to unblock forwarding. After joining the workers, clientConn.Close closes the same transport again and logs the expected closed-socket error at ERROR. Matched race runs recorded four such errors for four plaintext disconnects on the candidate and zero on the merge base. Preserve the early socket close and post-join cleanup, and use the existing expected-close classifier for the second close. See receipts 1795445673864054133-2 and 1795445608599041622-2.
Validation:
-
Verified the frozen patch, pinned policy, formatting, native artifact provenance, isolation preflight, and all three discussion entries.
-
The complete Proxy race suite passed 330 root tests. Thirteen focused tests each passed 100 race repetitions. See receipt 1795445533643004999-2 and validation-audit.log.
-
TestChangeWatchProxy and TestProxyShutdownCancelsInFlightSQL passed under the race detector. The shutdown test passed two additional runs. See receipts 1795445615535763930-2 and 1795445660604440197-2.
Limitations:
- Local validation used Linux and an embedded single-CN cluster. The frozen CI snapshot still had active lanes. This review assessed main.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 97db0d1a801728d2fd54f907e14d93b98f036604
Assessment: approve
Proxy shutdown now joins Goetty handlers and their forwarding and transfer workers before releasing shared clients. It reuses the existing cache handoff barrier and preserves disconnect cleanup for in-flight SQL. The prior logging finding is resolved. Routine plaintext disconnects emit no Proxy close ERROR, and unexpected close failures retain the connection ID and phase.
Model: gpt-6.2-sol / xhigh
Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3
Validation:
-
Verified the 16-file frozen diff, formatting, pinned policy, native build provenance, isolation preflight, and all five discussion entries.
-
The full Proxy race suite passed 331 tests. Fast QUIT, ordinary disconnect, and injected close failures each passed 100 race repetitions on the assigned head. Commands, receipts, and logs are indexed in validation-reconciliation.json.
-
TestChangeWatchProxy and TestProxyShutdownCancelsInFlightSQL passed under the race detector. The shutdown test verified that the active client query failed and its backend session disappeared from the process list. See isolated-race.jsonl and checks/1795449405732982918-2.json.
Limitations:
-
Local SQL validation used a Linux embedded single-CN cluster. Full CI lanes were still running in the frozen snapshot. The review covers main.
-
The matched idle-shutdown checks still observed Goetty handler and post-handler close diagnostics. Total ERROR entries decreased on the head.
What type of PR is this?
Which issue(s) this PR fixes:
Refs #32745 (main flaky CI tracker)
Related: #32744 (4.2-dev flaky CI tracker)
The observed crash was on main in PR #33058. The 4.2-dev branch uses a different Goetty version and does not contain the same test; this PR does not claim that the identical failure has been reproduced there or close either tracker.
What this PR does / why we need it:
Proxy shutdown disconnected sessions without waiting for their handlers. A handler could then attempt disconnect cleanup after its query client and service runtime had been released, causing a nil-runtime panic.
Make the existing connection owner cancel and drain handlers, tunnel pipes and in-progress transfers before releasing shared dependencies. Keep event delivery cancellable before it is accepted, retain acknowledgements after acceptance, and start both forwarding directions before processing traffic so an immediate
COM_QUITcannot publish a still-used backend to the connection cache. Preserve disconnect cleanup for in-flight SQL and remove the redundant EOF cache fallback. Both client transport close attempts retain diagnostics for unexpected failures while suppressing the expected already-closed error; the log identifies the connection and close phase.No database SQL or storage is added. The start barrier is per tunnel generation and does not add work per packet. The Proxy-side handshake synchronization addresses the observed Goetty connection-swap race for Proxy; it does not claim to fix other Goetty users.
Validation
./pkg/proxy -race -count=1and the selectedTestChangeWatchProxy/TestProxyShutdownCancelsInFlightSQLintegration tests under-racepassed on1845f66c848; the only later change adjusts test cleanup.TestTunnelStartsBothPipesBeforeQuitpassed 100 race iterations after its cleanup change. A deliberately injected failure after QUIT delivery confirmed its worker is released. Earlier fast-QUIT testing also failed when the start barrier was deliberately removed.gofmt, repositoryerr-check,go vet,molintandgolangci-lint2.14.0. After the test-only cleanup change, the affected./pkg/proxychecks were repeated and passed.Tests used Go 1.27.1 on Linux with the checkout's native libraries. CI for the updated head is pending. Goetty's separate pre-existing post-handler close diagnostic is outside the proxy close diagnostic fixed here.