Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dff178f

Browse files
committed
More cleanup after failed reduced-lock-levels-for-DDL feature.
Turns out that use of ShareUpdateExclusiveLock or ShareRowExclusiveLock to protect DDL changes had gotten copied into several places that were not touched by either of Simon's original patches for the feature, and thus neither he nor I thought to revert them. (Indeed, it appears that two of these uses were committed *after* the reversion, which just goes to show that git merging is no panacea.) Change these places to use AccessExclusiveLock again. If we ever manage to resurrect that feature, we're going to have to think a bit harder about how to keep lock level usage in sync for DDL operations that aren't within the AlterTable infrastructure. Two of these bugs are only in HEAD, but one is in the 9.1 branch too. Alvaro found one of them, I found the other two.
1 parent 5c5138f commit dff178f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/backend/catalog/toasting.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ AlterTableCreateToastTable(Oid relOid, Datum reloptions)
5959
Relation rel;
6060

6161
/*
62-
* Grab a DDL-exclusive lock on the target table, since we'll update the
63-
* pg_class tuple. This is redundant for all present users. Tuple
64-
* toasting behaves safely in the face of a concurrent TOAST table add.
62+
* Grab an exclusive lock on the target table, since we'll update its
63+
* pg_class tuple. This is redundant for all present uses, since caller
64+
* will have such a lock already. But the lock is needed to ensure that
65+
* concurrent readers of the pg_class tuple won't have visibility issues,
66+
* so let's be safe.
6567
*/
66-
rel = heap_open(relOid, ShareUpdateExclusiveLock);
68+
rel = heap_open(relOid, AccessExclusiveLock);
6769

6870
/* create_toast_table does all the work */
6971
(void) create_toast_table(rel, InvalidOid, InvalidOid, reloptions);

0 commit comments

Comments
 (0)