Repository navigation
fix: tolerate same-txn missing tables during FK cleanup - #24009
Merged
Merged
Conversation
Fixes #24008 Co-authored-by: Copilot <[email protected]>
ouyuanning
approved these changes
Mar 29, 2026
Contributor
Merge Queue Status
This pull request spent 5 seconds in the queue, with no time running CI. Required conditions to merge
|
aptend
pushed a commit
to aptend/matrixone
that referenced
this pull request
Apr 2, 2026
…#24009) This PR fixes an intermittent snapshot restore failure during `restore account ... {snapshot=...}`. The failure happens in `DropDatabase -> removeFkeysRelationships()` when FK cleanup revisits tables that were already deleted earlier in the same restore transaction. Before this patch, some of these expected missing-table cases could still abort the restore. This change makes the handling symmetric across all three relevant FK-cleanup lookup surfaces: - opening a relation returned by `Relations()` - looking up the parent table via `GetRelationById(fkey.ForeignTbl)` - looking up child tables via `GetRelationById(childId)` Only two narrow cases are tolerated: - `moerr.ErrNoSuchTable` - `moerr.ErrInternal` with `can not find table by id` All other errors still return immediately. This PR also adds focused regression coverage for all three missing-table surfaces in `pkg/sql/compile/ddl_test.go`. Validation: - `go test ./pkg/sql/compile -run 'TestRemoveFkeysRelationshipsSkipsDeletedRelationsDuringDropDatabase|TestRemoveFkeysRelationshipsSkipsDeletedChildTableIds|TestRemoveFkeysRelationshipsSkipsDeletedParentTableIds' -count=1` - `go test ./pkg/sql/compile -count=1` Approved by: @ouyuanning
jiangxinmeng1
added a commit
to jiangxinmeng1/matrixone
that referenced
this pull request
Apr 14, 2026
When a table has stale RefChildTbls entries pointing to non-existent child tables, the FkChildTblsReferToMe cleanup loop in dropTableSingle would fail with 'can not find table by id' error, blocking DROP TABLE and DROP ACCOUNT operations. This adds the same isMissingTableForFkCleanup error tolerance that PR matrixorigin#24009 added to removeFkeysRelationships (DropDatabase path), but for the DropTable path's child table lookup. Also upgrades the existing ForeignTbl loop error check from a raw strings.Contains to the more robust isMissingTableForFkCleanup helper. Approved by: jiangxinmeng1 Co-authored-by: Copilot <[email protected]>
1 of 7 tasks
mergify Bot
pushed a commit
that referenced
this pull request
Apr 14, 2026
When a table has stale `RefChildTbls` entries pointing to non-existent child tables (due to previous operations like CDC, snapshot restore, or prior bugs), the `FkChildTblsReferToMe` cleanup loop in `dropTableSingle` fails with: ``` internal error: can not find table by id <N>: accountId: <M> ``` This blocks `DROP TABLE` and `DROP ACCOUNT` operations. Related issue: #24008 / PR #24009 (fixed the same error in `removeFkeysRelationships` for DropDatabase path, but missed the DropTable path). Approved by: @aunjgr
fengttt
pushed a commit
to fengttt/matrixone
that referenced
this pull request
May 7, 2026
…#24009) This PR fixes an intermittent snapshot restore failure during `restore account ... {snapshot=...}`. The failure happens in `DropDatabase -> removeFkeysRelationships()` when FK cleanup revisits tables that were already deleted earlier in the same restore transaction. Before this patch, some of these expected missing-table cases could still abort the restore. This change makes the handling symmetric across all three relevant FK-cleanup lookup surfaces: - opening a relation returned by `Relations()` - looking up the parent table via `GetRelationById(fkey.ForeignTbl)` - looking up child tables via `GetRelationById(childId)` Only two narrow cases are tolerated: - `moerr.ErrNoSuchTable` - `moerr.ErrInternal` with `can not find table by id` All other errors still return immediately. This PR also adds focused regression coverage for all three missing-table surfaces in `pkg/sql/compile/ddl_test.go`. Validation: - `go test ./pkg/sql/compile -run 'TestRemoveFkeysRelationshipsSkipsDeletedRelationsDuringDropDatabase|TestRemoveFkeysRelationshipsSkipsDeletedChildTableIds|TestRemoveFkeysRelationshipsSkipsDeletedParentTableIds' -count=1` - `go test ./pkg/sql/compile -count=1` Approved by: @ouyuanning
fengttt
pushed a commit
to fengttt/matrixone
that referenced
this pull request
May 7, 2026
…#24132) When a table has stale `RefChildTbls` entries pointing to non-existent child tables (due to previous operations like CDC, snapshot restore, or prior bugs), the `FkChildTblsReferToMe` cleanup loop in `dropTableSingle` fails with: ``` internal error: can not find table by id <N>: accountId: <M> ``` This blocks `DROP TABLE` and `DROP ACCOUNT` operations. Related issue: matrixorigin#24008 / PR matrixorigin#24009 (fixed the same error in `removeFkeysRelationships` for DropDatabase path, but missed the DropTable path). Approved by: @aunjgr
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #24008 #23955
What this PR does / why we need it:
This PR fixes an intermittent snapshot restore failure during
restore account ... {snapshot=...}.The failure happens in
DropDatabase -> removeFkeysRelationships()when FK cleanup revisits tables that were already deleted earlier in the same restore transaction. Before this patch, some of these expected missing-table cases could still abort the restore.This change makes the handling symmetric across all three relevant FK-cleanup lookup surfaces:
Relations()GetRelationById(fkey.ForeignTbl)GetRelationById(childId)Only two narrow cases are tolerated:
moerr.ErrNoSuchTablemoerr.ErrInternalwithcan not find table by idAll other errors still return immediately.
This PR also adds focused regression coverage for all three missing-table surfaces in
pkg/sql/compile/ddl_test.go.Validation:
go test ./pkg/sql/compile -run 'TestRemoveFkeysRelationshipsSkipsDeletedRelationsDuringDropDatabase|TestRemoveFkeysRelationshipsSkipsDeletedChildTableIds|TestRemoveFkeysRelationshipsSkipsDeletedParentTableIds' -count=1go test ./pkg/sql/compile -count=1