Skip to content

test(bvt): restore session isolation after transaction rejection - #29411

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
aunjgr:fix/29410-snapshot-foreign-keys
Sep 27, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
aunjgr:fix/29410-snapshot-foreign-keys

Conversation

@aunjgr

@aunjgr aunjgr commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #29410.

Review notes

The first TKE failures are the two ADD FOREIGN KEY statements at lines 437–438 of snapshot/sys_restore_to_sys_account.sql, each returning w-w conflict: table snapshot is stale. Later SHOW CREATE mismatches follow because those constraints were never added. The TKE run executes set/set_transaction_rejection.sql first; that case sets its shared session to REPEATABLE-READ and 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-READ isolation.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label Sep 27, 2026
@mergify mergify Bot added the kind/test-ci label Sep 27, 2026

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; -n matches 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.

@mergify mergify Bot added the queued label Sep 27, 2026
@mergify

mergify Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-27 16:47 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-27 16:47 UTC · at 32b35d0703fd3e801a940856a97440ff64b46331

This pull request spent 24 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

This pull request seems to come from a fork, and Mergify needs the author's permission to update its branch.
The author needs to enable "Allow edits from maintainers" on this pull request, or update the branch manually.

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 5a96035 into matrixorigin:main Sep 27, 2026
3 of 4 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 27, 2026
XuPeng-SH added a commit that referenced this pull request Oct 4, 2026
## 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]>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/test-ci size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TKE SET case leaks SI isolation into snapshot foreign-key BVT

3 participants