Repository navigation
fix(snapshot): reject RESTORE TABLE of referenced tables - #28126
Conversation
|
Unrelated CI blockers: run 33844838948 had three self-hosted runners lose communication with GitHub; its AMD64 failures match #27784 and its ARM64 SCA failure matches #27742. The rerun was attempted once for attempt 1 and rejected with A separate unrelated producer failure is tracked by #28171. In workflow run 33902380103, attempt 1, the compose multi-CN pessimistic BVT job 101122331742 failed only at
Latest unrelated producer blocker: workflow run 35056375131, job 104669233364, failed only in The same run also hit tracked global UT budget issue #28661 in job 104680111462: the 70-minute deadline cancelled three still-active ArrowLoad/HashBuild tests, while every completed package passed and no assertion/compile/race failure occurred. |
95c450a to
7148dc5
Compare
7148dc5 to
f345911
Compare
f0632df to
df7eb66
Compare
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 exact head a02d2d7; approved. I inspected the complete eight-file diff, transaction/privilege/account validation ordering, FK lookup helper, and every changed recreation caller.
The fix changes a misleading successful no-op into an explicit unsupported error for an explicit table restore. The target-account check runs after snapshot/permission validation and before deleteCurFkTables; metadata lookup failures now propagate. Explicit-versus-bulk mode is carried through both ordinary and FK recreation paths, while database/account bulk skipping remains unchanged. The existing transaction finalizer rolls back early errors.
The regression oracles cover a successful ordinary-table restore and historical read, the referenced-parent error, unchanged current parent/child rows, sys/non-system account cases, helper error propagation and exact no-destructive-SQL rollback order. They do not pretend that coordinated dependent-table restoration is implemented. No new hot query path or unbounded work is introduced; the extra metadata lookup is scoped to explicit restore.
Validation: git diff --check PASS. Author-reported full frontend/focused UT and real standalone mo-tester results (26/26, 289/289, 100/100) are reused evidence; no fresh native cluster execution by this reviewer. No confirmed blocker found. Optional follow-up coverage: a non-sys target-account ID in the focused context test would make tenant-context propagation more explicit (current unit cases use sys, while BVT already covers acc01).
Merge Queue Status
This pull request spent 1 minute 40 seconds in the queue, with no time running CI. Waiting for any of
All conditions
ReasonPull request #28126 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:
Related to #27117
What this PR does / why we need it:
Root cause
RESTORE TABLEbuilds its foreign-key graph with filters for the selected table. For a referenced parent table, the child table that points to it is therefore not part of the table-restore graph. Later,recreateTabledetects that the target is referenced and returnsnilafter logging a skip. The restore transaction then completes successfully without changing the target, leaving post-snapshot data visible.Changes
not supportederror when the target is referenced by a foreign-key constraint.main.restore_fk_table.sql/.resultcase so explicit restores of referenced parent tables in both sys-account andacc01contexts assert the same unsupported error while the subsequent data checks remain unchanged.Issue-to-test proof
restore_table_referenced_by_fk.sqlcovers the ordinary table-restore control, historical snapshot read, referenced-parent restore, failure atomicity of the parent, child-row preservation, and cleanup. It assertsbeforefor the control and historical read, requires the unsupported error for the parent restore, and observeschangedplus child(1,1)afterward.restore_fk_restore_master_table.sqlverifies the existing account-level restore scenario now reports the same unsupported error and leaves the following table reads unchanged.restore_fk_table.sqlcovers the two existing explicit parent-table restore cases in sys and non-system account sessions, asserting the unsupported error and retaining the original parent/child rows afterward; its later account restore continues to cover bulk-restore skipping.TestRecreateTableReferencedByForeignKeycovers explicit rejection versus bulk-restore skipping and metadata-check error propagation.TestValidateRestoreTableTargetcovers referenced targets, non-referenced targets, lookup errors, and target-account execution context.TestRestoreTablesWithFkRejectsReferencedTableverifies explicit mode is propagated through the FK recreation helper.TestRestoreTableRejectsReferencedTableBeforeMutationexercisesdoRestoreSnapshotend to end through validation, asserts the unsupported error, and verifies the transaction rolls back before any destructive SQL.Tests run
make -C thirdparties -j2make -C cgo -j2make build -j2.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -run 'Test(RecreateTableReferencedByForeignKey|ValidateRestoreTableTarget|RestoreTablesWithFkRejectsReferencedTable|RestoreTableRejectsReferencedTableBeforeMutation)$' ./pkg/frontend.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/frontend.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -coverprofile=/tmp/mo-27117-frontend.cover ./pkg/frontendmo-testerruns against an isolated standalone LOG/TN/CN cluster, all with a 100% threshold:restore_table_referenced_by_fk.sql26/26,restore_fk_table.sql289/289, andcluster/restore_fk_restore_master_table.sql100/100.Residual risks
RESTORE TABLEfor a table referenced by a foreign key remains explicitly unsupported; implementing coordinated dependent-table restoration is outside this PR.