Repository navigation
test(bvt): restore session isolation after transaction rejection - #29411
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.
Reviewed commit be9dbb372a6aa042f5b6d83c80e8c4f87f8ab68c against PR base/merge-base 5be6cd90b501da225be591ffffe6000bf01f515e. Also checked the complete two-file delta against current main a99db843c7b4630a86883addc9424433d93fc2d2. No blocking findings; this is a reasonable, proportionate fix for test-owned session-state leakage.
The expected behavior is correct: restore the caller's actual isolation, read-only flag and SQL mode after the case. Restoring saved values preserves both RC and RR callers. The runner retains connection 0 across files, so the old missing isolation restoration really does affect subsequent tests. Rollback and database teardown precede restoration, and the original rejection, cross-connection visibility and rollback assertions remain intact. The SI stale-snapshot safety check remains unchanged.
Independent validation on an isolated standalone service built from this PR's source:
- A JDBC probe exercised four combinations of incoming RC/RR, read-only 0/1 and SQL modes, twice each on the same writer/observer connections. All eight executions preserved the original two rejection checks and nine result assertions, and restored all session values and their aliases. Replacing the SQL with the parent version reproduced the state leak: RC/read-only=1 became RR/read-only=0.
- Running the parent SET SQL/result followed by the unchanged snapshot case reproduced the original foreign-key errors at lines 437/438 (
table snapshot is stale) and all ten failures in that snapshot case. - Running the patched SET case followed by the snapshot case with the CI comparison mode (
-n) passed 587/587, zero ignored/abnormal statements, exit 0. The same sequence with strict metadata comparison passed all 559 snapshot statements; its only two failures were unchanged SET-result metadata differences (expected JDBC[12,0,0], observed[-1,16383,0]), also reproduced with the parent SQL/result. These are an existing coverage limitation, not a regression introduced here;-nmatches the actual CI invocation. - Current head CI is green. Its PESSIMISTIC shard ran this SET case 28/28 and its PROXY shard ran the snapshot case 559/559. Those are separate shards; the local consecutive run supplies the missing same-connection interaction check.
Performance/engineering: four additional SET statements and two additional saved values per execution; constant bounded state, no sleeps/retries, no production hot-path changes or new framework. Expected SQL errors are recorded and execution continues to cleanup in the runner.
The original TKE topology was not rerun here. The deterministic before/after reproduction above establishes the session-leak-to-FK-failure mechanism on the local topology without claiming every possible SI conflict is fixed.
Merge Queue Status
This pull request spent 24 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Tick the box to put this pull request back in the merge queue (same as
|
## What problem does this PR solve? Fixes #28921: direct MySQL text rows for exact-second `DATETIME(p)` omitted the declared fractional width when `p > 0`. #28596 was addressed by merged #28851. #28602 remains open and deferred: calendar-invalid DATE/DATETIME input such as `2024-02-30` is still rejected during parsing/assignment, so this PR introduces no such value into comparisons or indexes. The previous `ALLOW_INVALID_DATES` implementation was removed after storage, index and recovery compatibility review. The zero-DATETIME test below covers the existing zero sentinel. ## What changed? - Preserve `.0`, `.000`, or `.000000` for exact-second `DATETIME(p)` text output. The fast path caps malformed scale at 9, matching the existing nonzero-fraction formatter bound. - Assert raw MySQL text and prepared binary row packets for ordinary and zero `DATETIME(6)` values; keep focused scale and nonzero-fraction controls. ## Validation Base: `main` at `5a96035fc7` (includes #28851). The rebase added only #29411's unrelated transaction BVT files. - Focused CGo `pkg/frontend` tests `TestColumnSlicesGetDatetime` and `TestDatetimeExactSecondWireRowsKeepDeclaredScale`: passed after final code change. - `go vet -mod=readonly ./pkg/frontend`: passed. `golangci-lint` v2.6.2 / Go 1.26.4 on `./pkg/frontend`: 0 issues. `gofmt` and `git diff --check`: clean. - Existing distributed `datetime_precision_comprehensive.sql` BVT on the local built service: 91/91 passed before the final equivalent zero-fraction fast-path refinement; direct MySQL CLI observed expected p0/p3/p6 text output. The raw packet tests above validate the final code path. - Independent review of the final three-file diff found no blockers; it checked formatting, protocol bytes, cleanup, scale bound and hot-path cost. CI is not claimed as passed here. No persisted format, SQL mode, protocol epoch or cross-CN behavior changes are included. --------- Co-authored-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #29410.
Review notes
The first TKE failures are the two
ADD FOREIGN KEYstatements at lines 437–438 ofsnapshot/sys_restore_to_sys_account.sql, each returningw-w conflict: table snapshot is stale. LaterSHOW CREATEmismatches follow because those constraints were never added. The TKE run executesset/set_transaction_rejection.sqlfirst; that case sets its shared session toREPEATABLE-READand previously did not restore isolation. The SI safety check should remain intact.Validated without Docker on a test-owned standalone MO instance built from current main with Pixi GCC 14: normal mo-tester comparison of the SET case followed by the snapshot case passed 587/587 statements twice on the same instance. The TKE topology check remains pending on this PR.
What this PR does / why we need it:
Make the transaction-rejection BVT save and restore every session setting it changes: transaction isolation, read-only mode, and SQL mode. Finish database teardown before restoring the caller's settings so later BVT files do not inherit the case's
REPEATABLE-READisolation.