Repository navigation
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? |
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
Revalidation at head 4e3e457, which is byte-identical to the previously approved head (git diff 4e3e457b..HEAD is empty; the delta contains no merge commits). Prior review history: my own Codex approval at this exact head with zero findings — there were no blockers to fix, withdraw, or reconcile. Discussion since the approval: no inline review threads, no human comments, no author replies; only pre-existing Qodo-bot paused notices. Fresh spot-checks of the worktree reconfirm the approved analysis: resetSessionWithContext (sole caller routine_manager.go:566, the QueryService ResetSession RPC used by Proxy cached-handoff) passes preserveDatabase=false, restoring the pre-#27736 DBNAME-clearing contract; resetConnectionWithContext (sole caller routine.go:460, COM_RESET_CONNECTION) passes preserveDatabase=true, matching MySQL semantics; routine_manager_test.go asserts must_not_leak does not survive QueryService ResetSession; conn_cache_test.go drives 100 client generations through the real cached-login path. PR remains mergeable; upstream movement via the recorded merge commit introduces no authored delta. Approval reconfirmed with no blocking or non-blocking findings.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review completed on exact head 4e3e457b228bde8fcd6641f7d1aca3d546b9d529.
Root cause / contract split:
COM_RESET_CONNECTIONand QueryServiceResetSessionreplace the frontend Session generation but have different database semantics. The client command must retain the selected database; Proxy cache handoff must clear it before the next client runsSET CONNECTION IDand restores its requested database. Reusing one helper withpreserveDatabase=trueleaked the previous cached client database.- The new call split is complete: the wire command is the sole caller of
resetConnectionWithContext(... preserveDatabase=true), while RoutineManager/QueryService remains onresetSessionWithContext(... preserveDatabase=false). The no-context reset already clears the database.
Correctness and counterexamples checked:
- Failed reset restores
previousDB; a partially retired generation is still fail-closed through the existing must-close error/cache rejection path. - Existing wire coverage proves
COM_RESET_CONNECTIONstill preserves the database; the QueryService regression proves the previous database is absent in the replacement generation. - The Proxy regression drives 100 real cached-login generations through authentication, connection-ID reset, alternating database restoration, binary one-parameter prepare/execute parsing, statement close, causal PING fence, QUIT, ResetSession, cache publication, and final no-database login (
DATABASE() IS NULL). A single backend connection and per-generation authentication are asserted. - Latest
mainhas no changes in the three touched files since the PR merge-base.
Unhappy path / performance:
- Q1: every per-generation client, tunnel, reader/event loop, prepared statement, process, cache, and backend has an explicit terminal owner; cleanup is idempotently guarded.
- Q2: waits have context or one-second test guards; production admission/reset bounds are unchanged. No new lock or goroutine is added to production.
- Q3: test channels and generations are fixed-capacity/fixed-count; production adds no queue, retained state, retry, metric cardinality, or logging. Runtime cost is only selecting the correct existing reset mode.
Evidence:
- Latest substantive CI attempts are green, including Ubuntu UT, arm64 SCA, coverage, Connector/J reset E2E, Proxy BVT, and pessimistic multi-CN BVT.
- Focused local exact-head tests passed:
TestRoutineManagerResetSessionWaitsForRequestAfterResponseWrite,TestMySQLWireResetConnectionPreservesDatabase, andTestPreparedShortConnectionQuitProductionPath.
Scope note: these deterministic regressions do not replace the open #20022 multi-CN/dual-Proxy prepared-short-connection stability campaign. That remains the issue-closure QA gate, not a code-review blocker.
No blocking correctness, security/isolation, performance, liveness, resource-lifecycle, or test-quality issue found.
Merge Queue Status
This pull request spent 15 minutes 17 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #27946 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
Failing checks:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
Incremental deep re-review completed on current head 8e0b75d9e1835500c2431d0bbfe6decb29931776 after Mergify merged main@3f6856cc5fa08f77d1dc98fd4f00b17c257b0f86.
range-diffshows both PR-authored commits are unchanged.- The full PR patch against the new base has the same SHA-256 (
1968992972a6e6d452dd4bd0b0309b541f912e64fb84ad445ccffbf5afed523d) as the fully reviewed patch against the old base. - There are no files modified by both merge parents and no remerge/conflict-resolution delta. Therefore the reset-contract split, Proxy generation test, Q1-Q3 lifecycle analysis, performance assessment, and focused exact-head evidence from the preceding deep review remain semantically valid.
No new correctness, isolation, performance, liveness, resource-lifecycle, or test-quality blocker was introduced by the base merge. Approval reconfirmed without waiting for duplicate CI.
## What changed - give each ordinary MORPC unary request a complete read-timeout window from admission/flush, instead of charging it for socket-idle time before the request arrived - distinguish admitted, successfully flushed, terminal-send-failed, and expired requests while preserving established idle, internal, and one-way behavior and giving stream writes their own bounded fallback window - make tenant-upgrade tests execute the observable pass directly, bound every wait, and retain one end-to-end periodic-loop test - make the merge scheduler test synchronize at the exact executor/table-check boundary, use deterministic resource admission, and prevent the test observer from blocking the scheduler - separate frontend scheduling-preview computation from its production 100 ms best-effort latency policy so correctness tests do not race CI descheduling ## Root cause and design The embedded-cluster failure was not a restore or privilege failure. `CREATE ACCOUNT` began during an already-running socket `Read` window and inherited only the remainder of a configured 20-second timeout. Merely increasing the timeout therefore could not guarantee a newly admitted request a full response window. For a normal response-expecting unary request, the backend now models four relevant states: 1. admitted/queued or being flushed: retain the stale idle timeout because work is already pending; 2. successfully flushed: start one full response window at the successful flush timestamp; 3. terminal send failure: do not extend the connection lifetime; 4. expired response window: close the stalled backend; a newer admission cannot rescue it. The timestamp is published before the terminal send-completion flag. The timeout scanner reads that flag before the timestamp, so it cannot observe an old zero timestamp paired with the new success flag. The hot path adds one atomic store only for normal unary traffic after a successful flush; the cold timeout path scans the existing lifecycle-bounded future set. Internal, one-way, probe-enabled, cancellation, and close semantics remain unchanged. Probe-less streams use one backend-level last-successful-flush window only when no unary response window exists; an expired unary remains authoritative. The other failures had the same broad symptom but different mechanisms: correctness depended on a 20 ms asynchronous timer, host/cgroup memory plus 3/5 ms scheduler polling, or a production 100 ms best-effort preview timeout. Race instrumentation and package-parallel CI load can delay those operations without changing their business result. Tests now synchronize on observable state transitions, carry bounded parent contexts, and explicitly distinguish expected cancellation from a hang deadline. The lifecycle audit found no new unbounded state or waits: future ownership remains reference-counted and backend-close bounded; the timeout scan covers only existing live futures; merge observation is nonblocking and overflow-checked; every new test wait has a 10-second guard. Fixes #27963 ## Test plan Passed before rebase: - MORPC state matrix under race: `TestReadTimeoutDoesNotChargeIdleTimeToNewRequest` (`-count=100`) - actual MORPC request tracking under race: `TestReadTimeoutTracksRequestsWithoutLivenessProbe` (`-count=50`) - merge scheduler under race: `TestScheduler` (`-count=100`) - frontend strict-pool path under race: `TestDirectSessionStrictPoolWithoutLabelSelectorFailsClosed` (`-count=50`) - all seven tenant-upgrade tests separately under race (`-count=20` each) - full package tests: `pkg/common/morpc`, `pkg/bootstrap`, `pkg/frontend`, and `pkg/vm/engine/tae/db/merge` - full `pkg/common/morpc` package under race - targeted `go vet` for all four owning packages - real embedded-cluster regression under race: `TestAuthenticatedTestsReuseBaseCluster` and `TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` Rebased cleanly onto current `main` (`3f6856cc5f`). The two new upstream commits touched only frontend code, so the affected closure was rerun after rebase: - full `pkg/frontend`: passed (13.974 s) - strict-pool frontend counterexample under race, `-count=50`: passed (1.296 s) - full `pkg/bootstrap`: passed (18.523 s) - `go vet ./pkg/frontend ./pkg/bootstrap`: passed - real embedded-cluster regressions under race: passed (36.040 s) - `git diff --check`: passed No SQL result, wire API, or planner contract changes are introduced, so no SQL BVT case is required; the embedded-cluster tests exercise the public transport/session path directly. CI reruns for the unrelated failures on #27949 and #27946 were triggered separately; this PR does not wait for those reruns. Post-review deterministic-clock closure (99e9d6c): - removed the remaining 25/50 ms wall-clock oracle from TestScheduler; policy composition now uses a lifetime longer than the test hang guard - added TestSchedulerPolicyPatchExpirationUsesInjectedClock to prove in-place policy merging, exact-deadline validity, and removal immediately after the injected clock crosses the deadline - focused normal tests passed; both scheduler tests passed separately under race detection with count 100; the full merge package passed --------- Co-authored-by: Claude Fable 5 <[email protected]>
## 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 matrixorigin#20022 ## What this PR does / why we need it: This follow-up closes the remaining prepared short-connection cache review gaps after PR matrixorigin#27916: - separates QueryService `ResetSession` from MySQL `COM_RESET_CONNECTION`: the Proxy cache reset starts with an empty database, while the client command continues to preserve its selected database; - generates the production-driver shape of a one-parameter binary `COM_STMT_EXECUTE` packet, including iteration-count `1`, null bitmap, new-parameter flag, type, and value, and requires the real Frontend parser to accept it; - sends every one of 100 client generations through the real `connectToBackendContext` cached-login path, including cache authentication, `SET CONNECTION ID`, database restoration, tunnel traffic, `STMT_CLOSE`, `QUIT`, PING fence, ResetSession, cache publication, and the next login; - alternates two login databases and finishes with a login that specifies no database, where `DATABASE()` must return `NULL`; prepared state must be empty before every next client prepares again. Validation: - PR base: `33af6ae3c0c23e4f277137460577ea64678f7ecf` - exact head: `4e3e457b228bde8fcd6641f7d1aca3d546b9d529` - falsification at pre-fix head `2cfed1bb14a3e58de1d8fc5da625d1338e689afc`: FAIL because QueryService ResetSession retained `must_not_leak` - focused Frontend and Proxy regressions: PASS - Proxy 100-generation regression, `count=10`: PASS - focused Frontend and Proxy race regressions: PASS - full `pkg/frontend` and `pkg/proxy`: PASS - full `pkg/frontend -race` and `pkg/proxy -race`: PASS - `go list`, CGo-configured `go build`, `go vet`, and `git diff --check`: PASS - semantic preflight: PASS, diff hash `a98f98d3e9a6175abfe2ec92efab67e06b15abcee9c61e02c2f5c2245eceff95` QA required: yes. These deterministic regressions do not replace the multi-CN, dual-Proxy prepared short-connection campaign required by matrixorigin#20022. BVT: N/A. Ordinary SQL BVT cannot enable Proxy connection caching, generate binary prepared short connections, or assert physical backend reuse across client generations. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What changed - give each ordinary MORPC unary request a complete read-timeout window from admission/flush, instead of charging it for socket-idle time before the request arrived - distinguish admitted, successfully flushed, terminal-send-failed, and expired requests while preserving established idle, internal, and one-way behavior and giving stream writes their own bounded fallback window - make tenant-upgrade tests execute the observable pass directly, bound every wait, and retain one end-to-end periodic-loop test - make the merge scheduler test synchronize at the exact executor/table-check boundary, use deterministic resource admission, and prevent the test observer from blocking the scheduler - separate frontend scheduling-preview computation from its production 100 ms best-effort latency policy so correctness tests do not race CI descheduling ## Root cause and design The embedded-cluster failure was not a restore or privilege failure. `CREATE ACCOUNT` began during an already-running socket `Read` window and inherited only the remainder of a configured 20-second timeout. Merely increasing the timeout therefore could not guarantee a newly admitted request a full response window. For a normal response-expecting unary request, the backend now models four relevant states: 1. admitted/queued or being flushed: retain the stale idle timeout because work is already pending; 2. successfully flushed: start one full response window at the successful flush timestamp; 3. terminal send failure: do not extend the connection lifetime; 4. expired response window: close the stalled backend; a newer admission cannot rescue it. The timestamp is published before the terminal send-completion flag. The timeout scanner reads that flag before the timestamp, so it cannot observe an old zero timestamp paired with the new success flag. The hot path adds one atomic store only for normal unary traffic after a successful flush; the cold timeout path scans the existing lifecycle-bounded future set. Internal, one-way, probe-enabled, cancellation, and close semantics remain unchanged. Probe-less streams use one backend-level last-successful-flush window only when no unary response window exists; an expired unary remains authoritative. The other failures had the same broad symptom but different mechanisms: correctness depended on a 20 ms asynchronous timer, host/cgroup memory plus 3/5 ms scheduler polling, or a production 100 ms best-effort preview timeout. Race instrumentation and package-parallel CI load can delay those operations without changing their business result. Tests now synchronize on observable state transitions, carry bounded parent contexts, and explicitly distinguish expected cancellation from a hang deadline. The lifecycle audit found no new unbounded state or waits: future ownership remains reference-counted and backend-close bounded; the timeout scan covers only existing live futures; merge observation is nonblocking and overflow-checked; every new test wait has a 10-second guard. Fixes matrixorigin#27963 ## Test plan Passed before rebase: - MORPC state matrix under race: `TestReadTimeoutDoesNotChargeIdleTimeToNewRequest` (`-count=100`) - actual MORPC request tracking under race: `TestReadTimeoutTracksRequestsWithoutLivenessProbe` (`-count=50`) - merge scheduler under race: `TestScheduler` (`-count=100`) - frontend strict-pool path under race: `TestDirectSessionStrictPoolWithoutLabelSelectorFailsClosed` (`-count=50`) - all seven tenant-upgrade tests separately under race (`-count=20` each) - full package tests: `pkg/common/morpc`, `pkg/bootstrap`, `pkg/frontend`, and `pkg/vm/engine/tae/db/merge` - full `pkg/common/morpc` package under race - targeted `go vet` for all four owning packages - real embedded-cluster regression under race: `TestAuthenticatedTestsReuseBaseCluster` and `TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` Rebased cleanly onto current `main` (`3f6856cc5f`). The two new upstream commits touched only frontend code, so the affected closure was rerun after rebase: - full `pkg/frontend`: passed (13.974 s) - strict-pool frontend counterexample under race, `-count=50`: passed (1.296 s) - full `pkg/bootstrap`: passed (18.523 s) - `go vet ./pkg/frontend ./pkg/bootstrap`: passed - real embedded-cluster regressions under race: passed (36.040 s) - `git diff --check`: passed No SQL result, wire API, or planner contract changes are introduced, so no SQL BVT case is required; the embedded-cluster tests exercise the public transport/session path directly. CI reruns for the unrelated failures on matrixorigin#27949 and matrixorigin#27946 were triggered separately; this PR does not wait for those reruns. Post-review deterministic-clock closure (99e9d6c): - removed the remaining 25/50 ms wall-clock oracle from TestScheduler; policy composition now uses a lifetime longer than the test hang guard - added TestSchedulerPolicyPatchExpirationUsesInjectedClock to prove in-place policy merging, exact-deadline validity, and removal immediately after the injected clock crosses the deadline - focused normal tests passed; both scheduler tests passed separately under race detection with count 100; the full merge package passed --------- Co-authored-by: Claude Fable 5 <[email protected]>
## 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 matrixorigin#20022 ## What this PR does / why we need it: This follow-up closes the remaining prepared short-connection cache review gaps after PR matrixorigin#27916: - separates QueryService `ResetSession` from MySQL `COM_RESET_CONNECTION`: the Proxy cache reset starts with an empty database, while the client command continues to preserve its selected database; - generates the production-driver shape of a one-parameter binary `COM_STMT_EXECUTE` packet, including iteration-count `1`, null bitmap, new-parameter flag, type, and value, and requires the real Frontend parser to accept it; - sends every one of 100 client generations through the real `connectToBackendContext` cached-login path, including cache authentication, `SET CONNECTION ID`, database restoration, tunnel traffic, `STMT_CLOSE`, `QUIT`, PING fence, ResetSession, cache publication, and the next login; - alternates two login databases and finishes with a login that specifies no database, where `DATABASE()` must return `NULL`; prepared state must be empty before every next client prepares again. Validation: - PR base: `33af6ae3c0c23e4f277137460577ea64678f7ecf` - exact head: `4e3e457b228bde8fcd6641f7d1aca3d546b9d529` - falsification at pre-fix head `2cfed1bb14a3e58de1d8fc5da625d1338e689afc`: FAIL because QueryService ResetSession retained `must_not_leak` - focused Frontend and Proxy regressions: PASS - Proxy 100-generation regression, `count=10`: PASS - focused Frontend and Proxy race regressions: PASS - full `pkg/frontend` and `pkg/proxy`: PASS - full `pkg/frontend -race` and `pkg/proxy -race`: PASS - `go list`, CGo-configured `go build`, `go vet`, and `git diff --check`: PASS - semantic preflight: PASS, diff hash `a98f98d3e9a6175abfe2ec92efab67e06b15abcee9c61e02c2f5c2245eceff95` QA required: yes. These deterministic regressions do not replace the multi-CN, dual-Proxy prepared short-connection campaign required by matrixorigin#20022. BVT: N/A. Ordinary SQL BVT cannot enable Proxy connection caching, generate binary prepared short connections, or assert physical backend reuse across client generations. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What changed - give each ordinary MORPC unary request a complete read-timeout window from admission/flush, instead of charging it for socket-idle time before the request arrived - distinguish admitted, successfully flushed, terminal-send-failed, and expired requests while preserving established idle, internal, and one-way behavior and giving stream writes their own bounded fallback window - make tenant-upgrade tests execute the observable pass directly, bound every wait, and retain one end-to-end periodic-loop test - make the merge scheduler test synchronize at the exact executor/table-check boundary, use deterministic resource admission, and prevent the test observer from blocking the scheduler - separate frontend scheduling-preview computation from its production 100 ms best-effort latency policy so correctness tests do not race CI descheduling ## Root cause and design The embedded-cluster failure was not a restore or privilege failure. `CREATE ACCOUNT` began during an already-running socket `Read` window and inherited only the remainder of a configured 20-second timeout. Merely increasing the timeout therefore could not guarantee a newly admitted request a full response window. For a normal response-expecting unary request, the backend now models four relevant states: 1. admitted/queued or being flushed: retain the stale idle timeout because work is already pending; 2. successfully flushed: start one full response window at the successful flush timestamp; 3. terminal send failure: do not extend the connection lifetime; 4. expired response window: close the stalled backend; a newer admission cannot rescue it. The timestamp is published before the terminal send-completion flag. The timeout scanner reads that flag before the timestamp, so it cannot observe an old zero timestamp paired with the new success flag. The hot path adds one atomic store only for normal unary traffic after a successful flush; the cold timeout path scans the existing lifecycle-bounded future set. Internal, one-way, probe-enabled, cancellation, and close semantics remain unchanged. Probe-less streams use one backend-level last-successful-flush window only when no unary response window exists; an expired unary remains authoritative. The other failures had the same broad symptom but different mechanisms: correctness depended on a 20 ms asynchronous timer, host/cgroup memory plus 3/5 ms scheduler polling, or a production 100 ms best-effort preview timeout. Race instrumentation and package-parallel CI load can delay those operations without changing their business result. Tests now synchronize on observable state transitions, carry bounded parent contexts, and explicitly distinguish expected cancellation from a hang deadline. The lifecycle audit found no new unbounded state or waits: future ownership remains reference-counted and backend-close bounded; the timeout scan covers only existing live futures; merge observation is nonblocking and overflow-checked; every new test wait has a 10-second guard. Fixes matrixorigin#27963 ## Test plan Passed before rebase: - MORPC state matrix under race: `TestReadTimeoutDoesNotChargeIdleTimeToNewRequest` (`-count=100`) - actual MORPC request tracking under race: `TestReadTimeoutTracksRequestsWithoutLivenessProbe` (`-count=50`) - merge scheduler under race: `TestScheduler` (`-count=100`) - frontend strict-pool path under race: `TestDirectSessionStrictPoolWithoutLabelSelectorFailsClosed` (`-count=50`) - all seven tenant-upgrade tests separately under race (`-count=20` each) - full package tests: `pkg/common/morpc`, `pkg/bootstrap`, `pkg/frontend`, and `pkg/vm/engine/tae/db/merge` - full `pkg/common/morpc` package under race - targeted `go vet` for all four owning packages - real embedded-cluster regression under race: `TestAuthenticatedTestsReuseBaseCluster` and `TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` Rebased cleanly onto current `main` (`3f6856cc5f`). The two new upstream commits touched only frontend code, so the affected closure was rerun after rebase: - full `pkg/frontend`: passed (13.974 s) - strict-pool frontend counterexample under race, `-count=50`: passed (1.296 s) - full `pkg/bootstrap`: passed (18.523 s) - `go vet ./pkg/frontend ./pkg/bootstrap`: passed - real embedded-cluster regressions under race: passed (36.040 s) - `git diff --check`: passed No SQL result, wire API, or planner contract changes are introduced, so no SQL BVT case is required; the embedded-cluster tests exercise the public transport/session path directly. CI reruns for the unrelated failures on matrixorigin#27949 and matrixorigin#27946 were triggered separately; this PR does not wait for those reruns. Post-review deterministic-clock closure (99e9d6c): - removed the remaining 25/50 ms wall-clock oracle from TestScheduler; policy composition now uses a lifetime longer than the test hang guard - added TestSchedulerPolicyPatchExpirationUsesInjectedClock to prove in-place policy merging, exact-deadline validity, and removal immediately after the injected clock crosses the deadline - focused normal tests passed; both scheduler tests passed separately under race detection with count 100; the full merge package passed --------- Co-authored-by: Claude Fable 5 <[email protected]>
## 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 matrixorigin#20022 ## What this PR does / why we need it: This follow-up closes the remaining prepared short-connection cache review gaps after PR matrixorigin#27916: - separates QueryService `ResetSession` from MySQL `COM_RESET_CONNECTION`: the Proxy cache reset starts with an empty database, while the client command continues to preserve its selected database; - generates the production-driver shape of a one-parameter binary `COM_STMT_EXECUTE` packet, including iteration-count `1`, null bitmap, new-parameter flag, type, and value, and requires the real Frontend parser to accept it; - sends every one of 100 client generations through the real `connectToBackendContext` cached-login path, including cache authentication, `SET CONNECTION ID`, database restoration, tunnel traffic, `STMT_CLOSE`, `QUIT`, PING fence, ResetSession, cache publication, and the next login; - alternates two login databases and finishes with a login that specifies no database, where `DATABASE()` must return `NULL`; prepared state must be empty before every next client prepares again. Validation: - PR base: `33af6ae3c0c23e4f277137460577ea64678f7ecf` - exact head: `4e3e457b228bde8fcd6641f7d1aca3d546b9d529` - falsification at pre-fix head `2cfed1bb14a3e58de1d8fc5da625d1338e689afc`: FAIL because QueryService ResetSession retained `must_not_leak` - focused Frontend and Proxy regressions: PASS - Proxy 100-generation regression, `count=10`: PASS - focused Frontend and Proxy race regressions: PASS - full `pkg/frontend` and `pkg/proxy`: PASS - full `pkg/frontend -race` and `pkg/proxy -race`: PASS - `go list`, CGo-configured `go build`, `go vet`, and `git diff --check`: PASS - semantic preflight: PASS, diff hash `a98f98d3e9a6175abfe2ec92efab67e06b15abcee9c61e02c2f5c2245eceff95` QA required: yes. These deterministic regressions do not replace the multi-CN, dual-Proxy prepared short-connection campaign required by matrixorigin#20022. BVT: N/A. Ordinary SQL BVT cannot enable Proxy connection caching, generate binary prepared short connections, or assert physical backend reuse across client generations. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What changed - give each ordinary MORPC unary request a complete read-timeout window from admission/flush, instead of charging it for socket-idle time before the request arrived - distinguish admitted, successfully flushed, terminal-send-failed, and expired requests while preserving established idle, internal, and one-way behavior and giving stream writes their own bounded fallback window - make tenant-upgrade tests execute the observable pass directly, bound every wait, and retain one end-to-end periodic-loop test - make the merge scheduler test synchronize at the exact executor/table-check boundary, use deterministic resource admission, and prevent the test observer from blocking the scheduler - separate frontend scheduling-preview computation from its production 100 ms best-effort latency policy so correctness tests do not race CI descheduling ## Root cause and design The embedded-cluster failure was not a restore or privilege failure. `CREATE ACCOUNT` began during an already-running socket `Read` window and inherited only the remainder of a configured 20-second timeout. Merely increasing the timeout therefore could not guarantee a newly admitted request a full response window. For a normal response-expecting unary request, the backend now models four relevant states: 1. admitted/queued or being flushed: retain the stale idle timeout because work is already pending; 2. successfully flushed: start one full response window at the successful flush timestamp; 3. terminal send failure: do not extend the connection lifetime; 4. expired response window: close the stalled backend; a newer admission cannot rescue it. The timestamp is published before the terminal send-completion flag. The timeout scanner reads that flag before the timestamp, so it cannot observe an old zero timestamp paired with the new success flag. The hot path adds one atomic store only for normal unary traffic after a successful flush; the cold timeout path scans the existing lifecycle-bounded future set. Internal, one-way, probe-enabled, cancellation, and close semantics remain unchanged. Probe-less streams use one backend-level last-successful-flush window only when no unary response window exists; an expired unary remains authoritative. The other failures had the same broad symptom but different mechanisms: correctness depended on a 20 ms asynchronous timer, host/cgroup memory plus 3/5 ms scheduler polling, or a production 100 ms best-effort preview timeout. Race instrumentation and package-parallel CI load can delay those operations without changing their business result. Tests now synchronize on observable state transitions, carry bounded parent contexts, and explicitly distinguish expected cancellation from a hang deadline. The lifecycle audit found no new unbounded state or waits: future ownership remains reference-counted and backend-close bounded; the timeout scan covers only existing live futures; merge observation is nonblocking and overflow-checked; every new test wait has a 10-second guard. Fixes matrixorigin#27963 ## Test plan Passed before rebase: - MORPC state matrix under race: `TestReadTimeoutDoesNotChargeIdleTimeToNewRequest` (`-count=100`) - actual MORPC request tracking under race: `TestReadTimeoutTracksRequestsWithoutLivenessProbe` (`-count=50`) - merge scheduler under race: `TestScheduler` (`-count=100`) - frontend strict-pool path under race: `TestDirectSessionStrictPoolWithoutLabelSelectorFailsClosed` (`-count=50`) - all seven tenant-upgrade tests separately under race (`-count=20` each) - full package tests: `pkg/common/morpc`, `pkg/bootstrap`, `pkg/frontend`, and `pkg/vm/engine/tae/db/merge` - full `pkg/common/morpc` package under race - targeted `go vet` for all four owning packages - real embedded-cluster regression under race: `TestAuthenticatedTestsReuseBaseCluster` and `TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` Rebased cleanly onto current `main` (`3f6856cc5f`). The two new upstream commits touched only frontend code, so the affected closure was rerun after rebase: - full `pkg/frontend`: passed (13.974 s) - strict-pool frontend counterexample under race, `-count=50`: passed (1.296 s) - full `pkg/bootstrap`: passed (18.523 s) - `go vet ./pkg/frontend ./pkg/bootstrap`: passed - real embedded-cluster regressions under race: passed (36.040 s) - `git diff --check`: passed No SQL result, wire API, or planner contract changes are introduced, so no SQL BVT case is required; the embedded-cluster tests exercise the public transport/session path directly. CI reruns for the unrelated failures on matrixorigin#27949 and matrixorigin#27946 were triggered separately; this PR does not wait for those reruns. Post-review deterministic-clock closure (99e9d6c): - removed the remaining 25/50 ms wall-clock oracle from TestScheduler; policy composition now uses a lifetime longer than the test hang guard - added TestSchedulerPolicyPatchExpirationUsesInjectedClock to prove in-place policy merging, exact-deadline validity, and removal immediately after the injected clock crosses the deadline - focused normal tests passed; both scheduler tests passed separately under race detection with count 100; the full merge package passed --------- Co-authored-by: Claude Fable 5 <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
issue #20022
What this PR does / why we need it:
This follow-up closes the remaining prepared short-connection cache review gaps after PR #27916:
ResetSessionfrom MySQLCOM_RESET_CONNECTION: the Proxy cache reset starts with an empty database, while the client command continues to preserve its selected database;COM_STMT_EXECUTEpacket, including iteration-count1, null bitmap, new-parameter flag, type, and value, and requires the real Frontend parser to accept it;connectToBackendContextcached-login path, including cache authentication,SET CONNECTION ID, database restoration, tunnel traffic,STMT_CLOSE,QUIT, PING fence, ResetSession, cache publication, and the next login;DATABASE()must returnNULL; prepared state must be empty before every next client prepares again.Validation:
33af6ae3c0c23e4f277137460577ea64678f7ecf4e3e457b228bde8fcd6641f7d1aca3d546b9d5292cfed1bb14a3e58de1d8fc5da625d1338e689afc: FAIL because QueryService ResetSession retainedmust_not_leakcount=10: PASSpkg/frontendandpkg/proxy: PASSpkg/frontend -raceandpkg/proxy -race: PASSgo list, CGo-configuredgo build,go vet, andgit diff --check: PASSa98f98d3e9a6175abfe2ec92efab67e06b15abcee9c61e02c2f5c2245eceff95QA required: yes. These deterministic regressions do not replace the multi-CN, dual-Proxy prepared short-connection campaign required by #20022.
BVT: N/A. Ordinary SQL BVT cannot enable Proxy connection caching, generate binary prepared short connections, or assert physical backend reuse across client generations.