Backport 8540: Fix deadlock adding named constraint with long partition name (#7799)…#8560
Open
codeforall wants to merge 1 commit intorelease-14.0from
Open
Backport 8540: Fix deadlock adding named constraint with long partition name (#7799)…#8560codeforall wants to merge 1 commit intorelease-14.0from
codeforall wants to merge 1 commit intorelease-14.0from
Conversation
…#8540) DESCRIPTION: Fix deadlock when adding named constraint on partitioned table with long partition name. Previously, SwitchToSequentialAndLocalExecutionIfConstraintNameTooLong was only called when the user did NOT provide an explicit constraint name. When a name was provided (e.g., ALTER TABLE ... ADD CONSTRAINT myname UNIQUE(...)), the code fell through to the standard parallel DDL path without checking if the auto-generated constraint names on partition shards would exceed NAMEDATALEN, causing potential self-deadlocks. This commit adds calls to SwitchToSequentialAndLocalExecutionIfConstraintNameTooLong for both named foreign key constraints and named non-FK constraints (PRIMARY KEY, UNIQUE, EXCLUDE, CHECK) in PreprocessAlterTableStmt, so that the long partition shard name check is performed regardless of whether the user specified a constraint name. Also adds regression tests covering named PRIMARY KEY, UNIQUE, and CHECK constraints on partitioned tables with long partition names, including the error case when a parallel query has already been executed in the same transaction. DESCRIPTION: PR description that will go into the change log, up to 78 characters
Codecov Report❌ Patch coverage is ❌ Your project check has failed because the head coverage (63.24%) is below the target coverage (87.50%). You can increase the head coverage or adjust the target coverage.
Additional details and impacted files@@ Coverage Diff @@
## release-14.0 #8560 +/- ##
=================================================
- Coverage 88.73% 63.24% -25.49%
=================================================
Files 287 287
Lines 63238 63239 +1
Branches 7925 7923 -2
=================================================
- Hits 56114 39997 -16117
- Misses 4862 20212 +15350
- Partials 2262 3030 +768 🚀 New features to boost your workflow:
|
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.
… (#8540)
DESCRIPTION: Fix deadlock when adding named constraint on partitioned table with long partition name.
Previously, SwitchToSequentialAndLocalExecutionIfConstraintNameTooLong was only called when the user did NOT provide an explicit constraint name. When a name was provided (e.g., ALTER TABLE ... ADD CONSTRAINT myname UNIQUE(...)), the code fell through to the standard parallel DDL path without checking if the auto-generated constraint names on partition shards would exceed NAMEDATALEN, causing potential self-deadlocks.
This commit adds calls to
SwitchToSequentialAndLocalExecutionIfConstraintNameTooLong for both named foreign key constraints and named non-FK constraints (PRIMARY KEY, UNIQUE, EXCLUDE, CHECK) in PreprocessAlterTableStmt, so that the long partition shard name check is performed regardless of whether the user specified a constraint name.
Also adds regression tests covering named PRIMARY KEY, UNIQUE, and CHECK constraints on partitioned tables with long partition names, including the error case when a parallel query has already been executed in the same transaction.
DESCRIPTION: PR description that will go into the change log, up to 78 characters
DESCRIPTION: PR description that will go into the change log, up to 78 characters