Repository navigation
Description
Is there an existing issue for the same bug?
- I checked the open issues for this
ADD FOREIGN KEYstale-snapshot conflict and the TKE case.
Branch Name
fix/28012-restart-sql-context; the same failure occurs on unrelated fix/28079-account-lifecycle-shared.
Commit ID
66e89ff6c1ece72ce39969fcedb13153c87d9fd8 (first linked TKE run).
Other Environment Information
MatrixOne “MO Checkin Regression On TKE / MO CHECKIN BVT TEST” GitHub Actions job on 2026-09-27.
Actual Behavior
The first failure in test/distributed/cases/snapshot/sys_restore_to_sys_account.sql is at lines 437–438:
alter table ti1 add constraint fi1 foreign key (b) references ti2(a);
alter table tm1 add constraint fm1 foreign key (b) references tm2(a);Both return w-w conflict: tableID: ..., table snapshot is stale. Because those constraints were never added, later historical/restored SHOW CREATE TABLE checks at lines 442, 444, 454, 456, 481, and 482 omit the expected fi1/fm1 definitions. These are cascading mismatches, not evidence that SHOW CREATE itself dropped valid foreign-key metadata. The script reports 10 failed statements.
Expected Behavior
The two sequential ADD FOREIGN KEY statements succeed on their current tables, and snapshot/restored SHOW CREATE TABLE retains the constraints.
Steps to Reproduce
- Run the TKE checkin BVT including
test/distributed/cases/snapshot/sys_restore_to_sys_account.sql. - Inspect the first errors at lines 437–438 before the downstream
SHOW CREATEmismatches.
Additional information
- First failed TKE job.
- Same line-437 write conflict on an unrelated branch.
- The test(embed): renew SQL deadline after restart admission #29398 diff is test-only and cannot alter the deployed SQL service. Root cause within the FK DDL/write-conflict path remains under investigation.
Diagnosis and focused validation
The TKE log runs test/distributed/cases/set/set_transaction_rejection.sql before the snapshot case. That SET case changed the primary session to REPEATABLE-READ but restored only sql_mode, leaking fixed SI isolation to later files. The foreign-key table-lock guard then reports the stale SI snapshot at the first ADD FOREIGN KEY; later SHOW CREATE mismatches cascade from those rejected ALTERs. This is the working cause pending TKE-topology confirmation, not a reason to weaken the SI guard.
The fix saves and restores isolation, read-only, and SQL mode in the SET case. A normal-comparison local run of the SET and snapshot cases together passed 587/587 statements twice on the same standalone instance; exact TKE CI remains the final topology check.
Activity
[-][Bug]: TKE snapshot SHOW CREATE omits foreign keys[/-][+][Bug]: ADD FOREIGN KEY hits stale-snapshot write conflict in TKE BVT[/+][-][Bug]: ADD FOREIGN KEY hits stale-snapshot write conflict in TKE BVT[/-][+][Bug]: TKE SET case leaks SI isolation into snapshot foreign-key BVT[/+]test(bvt): restore session isolation after transaction rejection (#29411