Repository navigation
fix(proxy): clear backend handshake read deadline - #27377
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
P1: this clears the deadline only immediately after HandleHandshakeContext, but the same frontend IOSession re-arms SessionTimeout before every later protocol read (pkg/frontend/mysql_buffer.go:704-714). Both long-lived handoff paths perform such reads after this new clear: migration always executes SET transferred=1 and may replay SET statements through ExecStmtContext (pkg/proxy/conn_migration.go:123-146; pkg/proxy/server_conn.go:635-692), while cache Pop executes SET CONNECTION ID (pkg/proxy/conn_cache.go:485-505). Migration then returns the backend to the tunnel and cache Pop directly returns it at lines 537-546, with no second clear. Therefore migrated and cached/reused tunnels still inherit a new absolute read deadline and can disconnect roughly 24 hours later under active raw traffic. The added test only proves the intermediate post-handshake state. Please clear the phase-owned deadline at every terminal tunnel handoff (or make each bounded control-read phase restore it), and add deterministic post-ExecStmt migration/cache handoff coverage, including clear failure.
|
Addressed the P1 deadline handoff issue in commit
Please re-review the updated PR. |
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
No blocking or non-blocking findings. The prior deadline-handoff concern is addressed across handshake, migration, and cache reuse paths, including clear-failure handling.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 3361edc9e476add69d2baabfd318b0b75ef74151: APPROVED.
The previous blocker is closed across every terminal backend-to-tunnel handoff. Initial handshake clears the frontend IO read deadline before return; migration clears it after the final replay/control statement; cache reuse clears it after SET CONNECTION ID. No later step in those paths performs another backend protocol read before handoff. Clear failures remain fail-closed: migration returns the error and cache reuse discards the backend.
Focused controlled-CGo tests cover all three handoffs, re-arming after control reads, and both migration/cache clear-failure paths; they pass on this exact head. I found no remaining lifecycle or ownership blocker in the complete diff.
|
Queued — the merge queue status continues in this comment ↓. |
|
Merge Queue Status
This pull request spent 6 hours 24 minutes 11 seconds in the queue, including 47 minutes 33 seconds running CI. Required conditions to merge
|
Fixes matrixorigin#27318. The Proxy backend CN handshake uses the frontend IO session, whose reads apply the 24-hour `SessionTimeout` as an absolute socket read deadline. After authentication succeeds, the backend connection is handed to the long-lived tunnel without clearing that phase deadline. Long-lived Proxy-to-CN connections can therefore expire after roughly 24 hours and cause simultaneous client disconnects. Approved by: @XuPeng-SH, @gouhongshen
Fixes matrixorigin#27318. The Proxy backend CN handshake uses the frontend IO session, whose reads apply the 24-hour `SessionTimeout` as an absolute socket read deadline. After authentication succeeds, the backend connection is handed to the long-lived tunnel without clearing that phase deadline. Long-lived Proxy-to-CN connections can therefore expire after roughly 24 hours and cause simultaneous client disconnects. Approved by: @XuPeng-SH, @gouhongshen
Fixes matrixorigin#27318. The Proxy backend CN handshake uses the frontend IO session, whose reads apply the 24-hour `SessionTimeout` as an absolute socket read deadline. After authentication succeeds, the backend connection is handed to the long-lived tunnel without clearing that phase deadline. Long-lived Proxy-to-CN connections can therefore expire after roughly 24 hours and cause simultaneous client disconnects. Approved by: @XuPeng-SH, @gouhongshen
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue #29406 ## What this PR does / why we need it: Backport #27377 (`2073cfdfa566cf41e591e24a108f3ce22065f927`) to `4.2-dev`. The Proxy backend handshake uses frontend IOSession reads, which arm an absolute socket read deadline using SessionTimeout (24 hours by default). Without clearing it before handing the connection to the long-lived tunnel, an actively used connection can expire approximately 24 hours after authentication. Migration control reads and cached connection reuse can re-arm the same deadline. This backport clears the phase-owned read deadline at all three handoffs: - Successful backend handshake, after joining the handshake worker and cancellation interrupt. - Migration, after the final control statement. - Cached backend reuse, after SET CONNECTION ID. A failed clear prevents handoff; cached backends that cannot be cleared are discarded. Existing handshake, migration, cancellation, connection ownership, and cache capacity protections are preserved. No timeout setting, wire protocol, persistence format, or query execution behavior changes. Compatibility adaptation is limited to using the existing 4.2 `parent` context for migration error attribution and keeping only this fix's migration tests, without unrelated newer-main tests. ### Validation Base: `6ca0a25ca5d5d3c8fe22d8587bc7e703cd034cac`. Native artifacts were built with `make cgo` inside the isolated 4.2 worktree. Go version: `go1.26.4 darwin/arm64`. - All five handoff/deadline regression tests passed, including migration and cached-reuse clear failures. - Full `pkg/proxy` suite passed with `-count=1 -timeout=300s` through the repository CGo test wrapper. - `git diff --check` passed. The tests validate deadline state and failure ownership without waiting 24 hours. ### Compose CI repair on 4.2-dev The first CI run failed before BVT SQL started: Quay rejected pulls for the pinned MinIO server and mc images in both Compose lanes ([PROXY job](https://github.com/matrixorigin/matrixone/actions/runs/36317763336/job/108627987240), [PESSIMISTIC job](https://github.com/matrixorigin/matrixone/actions/runs/36317763336/job/108627987185)). The later log-export and coverage errors were consequences of Compose never starting. This is the 4.2 backport of the merged main fix [#29370](#29370), not a proxy failure. Compose now builds the **same pinned MinIO and mc releases** from their official GitHub release binaries, verifies fixed SHA-256 hashes, and preserves the server configuration. Bucket setup reports real mc errors and tolerates an existing bucket on restart. Local validation passed: Compose configuration, both image builds, healthy MinIO, public `mo-test` bucket, repeated initialization, and `git diff --check`. The full Compose BVT lanes remain subject to the new CI run. A live 24-hour connection soak and multi-CN end-to-end validation were not run. #29407 is a separate MORPC/Pipeline investigation and is not claimed as fixed by this backport. --------- Co-authored-by: davis zhen <[email protected]> Co-authored-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
issue #27318
What this PR does / why we need it:
Fixes #27318.
The Proxy backend CN handshake uses the frontend IO session, whose reads apply the 24-hour
SessionTimeoutas an absolute socket read deadline. After authentication succeeds, the backend connection is handed to the long-lived tunnel without clearing that phase deadline. Long-lived Proxy-to-CN connections can therefore expire after roughly 24 hours and cause simultaneous client disconnects.Changes