Repository navigation
fix(proxy): preserve LAST_INSERT_ID across connection migration - #29192
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? |
f0b56ec to
08a66cf
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
GPT-6 high review at exact head 7f0e9fb (base 3727c5c): APPROVE.
The migration contract correctly distinguishes an authoritative exported zero from an omitted legacy field, fails closed on missing capability/marker and incompatible v92 targets, preserves the scalar HLL contract, and restores LAST_INSERT_ID into both Session and Process after replay. One-shot admission, cancellation/deadline cleanup, failed-target closure, and bounded state are closed.
The real two-CN Proxy Connector/J regression retains the same connection and prepared statements across handoff, checks source/target CNs, direct and prepared LAST_INSERT_ID, and a subsequent insert; fallback and automatic reconnect are disabled. Current-head CI, UT/SCA, and both BVT jobs passed. Local native/race evidence was reused only where source-equivalence was verified, not presented as new CI. This review does not claim mixed-version upgrade acceptance or close broader QA gates.
Merge Queue Status
This pull request spent 16 minutes 32 seconds in the queue, with no time running CI. Waiting for any of
All conditions
ReasonPull request #29192 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.
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
|
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #29184
What this PR does / why we need it:
After inserting an auto-increment row, a JDBC connection could observe
LAST_INSERT_ID() = 0when Proxy migrated it away from a draining CN. Preserve the session value through the migration snapshot and restore it in both Session and Process after statement replay, so the original connection retains its last generated ID.useServerPrepStmts=falseandtrue. It retains the same JDBC connection and prepared statements, confirms source/target CN IDs during drain, verifiesLAST_INSERT_ID()through both direct SQL and a retained prepared query after handoff through a retry interval, and checks that another insert updates the value.Validation
Rebased onto
3727c5c5436ca136d7b0312f75bc223a11692a85.Final validated revision:
7f0e9fb0100029eef22da9e8bf70804fe5710523.Two-CN + Proxy JDBC regression
The corrected test passed twice on the same isolated native topology. Each run executed both modes: 2 tests, 0 failures, 0 errors, 0 skipped, with
BUILD SUCCESS. Class elapsed times were 20.88 s and 29.83 s. After each run, both CNs were verifiedWorkingwith no test databases remaining. The second run validates that teardown permits reuse, not just a fresh-cluster success.The native service was rebuilt at
cfaefd92dcdaa6d1a49b60dc150d2c760e2ae228; executable SHA-256:0678a85d7fbf9ab8a77a37f06a22a2e7475293bb2f3b9330c54e6108c3437669. The later review correction changes only the Java test, leaving Go/native build inputs identical. The native build and Go race results are reused on that source-equivalence basis, not represented as newly executed CI.The isolated local topology uses one LogService, one TN, two CNs, and Proxy. From
xtool/jstfu, with the topology running:Adaptive race stress
On macOS arm64 with CGO enabled, each test below was selected individually. Measure once with:
.agents/skills/mo-dev/scripts/mo-cgo-test -json -race -count=1 -timeout=120s -run '^TEST$' ./pkg/PACKAGETis the terminal test-event duration, excluding compilation/package startup. Repetition count isclamp(floor(30s/T),1,100); a completed measurement rounded to zero uses the cap of 100. Repeat the same exact selector separately in one process with-count=Nand otherwise identical flags.Every stress command exited 0; no race report occurred. Each of the four frontend runs also emitted exactly 100 passing terminal test events.
Affected packages
Both passed: Proxy 25.075 s, Frontend 48.036 s. These cover the v92 legacy-target rejection boundary, missing capability/marker handling, state restoration, cancellation, and lifecycle tests. These commands ran on
cfaefd92d; the only change from that revision to the final head is the Java regression correction described above.gofmt -lon changed Go files was empty,git diff --check origin/main...HEADpassed, and the rebase range-diff was inspected.Compatibility and remaining risk
Migration fails closed when a participating updated source or Proxy cannot prove that the value was exported. An entirely legacy Source/Proxy/Target path retains its existing behavior. The change adds bounded scalar fields and admission checks to migration; ordinary query execution is unchanged.
Shared build, general BVT, coverage, and Connector/J pool-reset CI passed on the previous published head. They have not yet run on the updated head; CI results after this push remain pending. The local JDBC regression is separate from pool-reset CI and requires the environment variables above to execute rather than skip.