Repository navigation
fix: handle missing child table in DropTable FK cleanup - #24132
Merged
mergify[bot] merged 4 commits intoApr 14, 2026
Merged
mergify[bot] merged 4 commits into
mergify[bot] merged 4 commits into
Conversation
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]>
aunjgr
approved these changes
Apr 14, 2026
Cover all branches of the helper function to satisfy PR coverage CI (was 33%, needs ≥75%). Co-authored-by: Copilot <[email protected]>
Contributor
Merge Queue Status
This pull request spent 57 minutes 58 seconds in the queue, including 57 minutes 40 seconds running CI. Required conditions to merge
|
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 #24133
What this PR does / why we need it:
When a table has stale
RefChildTblsentries pointing to non-existent child tables (due to previous operations like CDC, snapshot restore, or prior bugs), theFkChildTblsReferToMecleanup loop indropTableSinglefails with:This blocks
DROP TABLEandDROP ACCOUNToperations.Related issue: #24008 / PR #24009 (fixed the same error in
removeFkeysRelationshipsfor DropDatabase path, but missed the DropTable path).What is changed?
pkg/sql/compile/ddl.go(dropTableSingle):FkChildTblsReferToMeloop (line 2957) — AddedisMissingTableForFkCleanuperror tolerance when looking up child tables. If a child table no longer exists, log a warning and continue instead of returning a fatal error. This is the same pattern already applied by PR fix: tolerate same-txn missing tables during FK cleanup #24009 toremoveFkeysRelationships.ForeignTblloop (line 2929) — Upgraded the existing error check from rawstrings.Contains(err.Error(), "can not find table by id")to the more robustisMissingTableForFkCleanup()helper (which also catchesErrNoSuchTable).