fix(snapshot): reject RESTORE TABLE of referenced tables - #28126
fix(snapshot): reject RESTORE TABLE of referenced tables#28126gouhongshen wants to merge 3 commits into
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
|
95c450a to
7148dc5
Compare
7148dc5 to
f345911
Compare
2f9ae43 to
9a9820d
Compare
9a9820d to
f0632df
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? |
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.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.