Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb8ca984

Browse files
committed
Revert lowering of lock level for ATTACH PARTITION
I lowered the lock level for partitions being scanned fromAccessExclusive to ShareLock in the course of72cf7f3, but that wasbogus, as pointed out by Robert Haas. Revert that bit. Doing this ispossible, but requires more work.Discussion:https://postgr.es/m/CA+TgmobV7Nfmqv+TZXcdSsb9Bjc-OL-Anv6BNmCbfJVZLYPE4Q@mail.gmail.com
1 parent181ccbb commitb8ca984

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13997,10 +13997,9 @@ QueuePartitionConstraintValidation(List **wqueue, Relation scanrel,
1399713997
List*thisPartConstraint;
1399813998

1399913999
/*
14000-
* This is the minimum lock we need to prevent concurrent data
14001-
* additions.
14000+
* This is the minimum lock we need to prevent deadlocks.
1400214001
*/
14003-
part_rel=heap_open(partdesc->oids[i],ShareLock);
14002+
part_rel=heap_open(partdesc->oids[i],AccessExclusiveLock);
1400414003

1400514004
/*
1400614005
* Adjust the constraint for scanrel so that it matches this
@@ -14113,17 +14112,17 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
1411314112
*
1411414113
* We do that by checking if rel is a member of the list of attachrel's
1411514114
* partitions provided the latter is partitioned at all. We want to avoid
14116-
* having to construct this list again, so we requesta lock on all
14117-
* partitions. We needShareLock, preventing data changes, because we
14118-
*may decideto scan them if we find out that the table being attached (or
14119-
*its leafpartitions) may contain rows that violate the partition
14120-
*constraint. Ifthe table has a constraint that would prevent such rows,
14121-
*which bydefinition is present in all the partitions, we need not scan
14122-
*thetable, nor its partitions. But we cannot risk a deadlock by taking
14123-
*aweaker lock now and the stronger one only when needed.
14115+
* having to construct this list again, so we requestthe strongest lock
14116+
*on allpartitions. We needthe strongest lock, because we may decide
14117+
* to scan them if we find out that the table being attached (or its leaf
14118+
* partitions) may contain rows that violate the partition constraint. If
14119+
* the table has a constraint that would prevent such rows, which by
14120+
* definition is present in all the partitions, we need not scan the
14121+
* table, nor its partitions. But we cannot risk a deadlock by taking a
14122+
* weaker lock now and the stronger one only when needed.
1412414123
*/
1412514124
attachrel_children=find_all_inheritors(RelationGetRelid(attachrel),
14126-
ShareLock,NULL);
14125+
AccessExclusiveLock,NULL);
1412714126
if (list_member_oid(attachrel_children,RelationGetRelid(rel)))
1412814127
ereport(ERROR,
1412914128
(errcode(ERRCODE_DUPLICATE_TABLE),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp