Repository navigation
fix(frontend): reduce disconnect scan stalls during KILL - #32378
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? |
|
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: 9c227818db233108062d070ab83492c5aedde0dd
Assessment: approve
The fix reuses existing lifecycle admission and connection cleanup. Idle-close and request/KILL handoff paths are sound, with no actionable findings.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Seventeen focused cases passed once under race, then each passed 100 repetitions with one exact test per command.
-
Preflight, native build, frozen-source/delta and formatting checks passed. All 23 receipts reconcile with retained logs in validation-index.json.
-
Reused author-reported full frontend normal/race, proxy normal, authenticated SQL rollback/KILL and static checks. Both discussion entries were assessed.
Limitations:
-
Substantive CI was pending in the frozen snapshot. Full-package/SQL/static evidence lacks raw attachments; Darwin execution was unavailable.
-
Busy or contended close paths and main’s existing write-half-close cancellation policy remain unchanged.
What type of PR is this?
Which issue(s) this PR fixes:
Part of #32362; keep the issue open. The 4.2-dev change is #32364; main already has a one-second disconnect probe without the 30-second grace described in that issue.
What this PR does / why we need it:
On main, an idle connection's
KILL CONNECTIONcan hold the routine request mutex while closing its protocol. A disconnect scan that has already snapshotted that routine can then wait behind a slow close before it reaches another disconnected request. This change removes that lock-held close when the routine and its lifecycle controller are uncontended and idle. It seals the existing lifecycle controller before releasing the locks, so a reset or migration cannot acquire the session while the protocol is closing. Busy or contended paths retain their previous behavior; this does not guarantee that every disconnect scan is nonblocking.A request finishing concurrently with KILL now hands connection closure to the existing connection owner after attempting its response. This closes an existing window where KILL and request completion could each leave closure to the other. No additional monitor, per-connection cache, or persistent close state is introduced.
The existing main-branch FIN/RST sampling policy is unchanged. In particular, main currently cancels a request after a client write-half-close; this PR does not change that limitation. During an account KILL of an idle connection, a concurrent subsequent KILL QUERY can now fail immediately because the connection is already sealed; the base implementation could instead wait for the close and report a no-op success. KILL QUERY against a still-running request remains supported.
Validation
./pkg/frontendnormal and race tests;./pkg/proxynormal tests. Seventeen individually measured KILL, disconnect, reset, response and cleanup cases each passed 100 repetitions with-race.go vet, the repository-pinnedmolint, and incrementalgolangci-lintpassed for the affected frontend/proxy/issues closure and final test delta. Native Darwin execution was not available.SELECT 1calls per sample), base was 17.0k–18.7k QPS and this change 18.0k QPS; p95 was 0.819–0.899 ms and 0.828–0.854 ms respectively. Base itself varied ~10%, so these samples show no obvious large regression in this workload; they do not establish a general speedup or a production latency bound.