]> granicus.if.org Git - postgresql/commitdiff
More cleanup after failed reduced-lock-levels-for-DDL feature.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Oct 2011 17:49:51 +0000 (13:49 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Oct 2011 17:50:30 +0000 (13:50 -0400)
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.

src/backend/catalog/toasting.c
src/backend/commands/trigger.c
src/backend/rewrite/rewriteRemove.c

index a938c98190ee3a27cadaa3e21e994aa11509240b..3a40e8bffc54a1ffb221582c74dd2fe4a5268dab 100644 (file)
@@ -58,11 +58,13 @@ AlterTableCreateToastTable(Oid relOid, Datum reloptions)
        Relation        rel;
 
        /*
-        * Grab a DDL-exclusive lock on the target table, since we'll update the
-        * pg_class tuple.      This is redundant for all present users.  Tuple
-        * toasting behaves safely in the face of a concurrent TOAST table add.
+        * Grab an exclusive lock on the target table, since we'll update its
+        * pg_class tuple. This is redundant for all present uses, since caller
+        * will have such a lock already.  But the lock is needed to ensure that
+        * concurrent readers of the pg_class tuple won't have visibility issues,
+        * so let's be safe.
         */
-       rel = heap_open(relOid, ShareUpdateExclusiveLock);
+       rel = heap_open(relOid, AccessExclusiveLock);
 
        /* create_toast_table does all the work */
        (void) create_toast_table(rel, InvalidOid, InvalidOid, reloptions);
index 9fb9754848568f9d76635e6337778184187a0793..a6e7268aa78e8204acbe69b5642fc09fca8b4367 100644 (file)
@@ -1038,7 +1038,7 @@ DropTrigger(RangeVar *relation, const char *trigname, DropBehavior behavior,
        ObjectAddress object;
 
        /* lock level should match RemoveTriggerById */
-       relid = RangeVarGetRelid(relation, ShareRowExclusiveLock, false, false);
+       relid = RangeVarGetRelid(relation, AccessExclusiveLock, false, false);
 
        object.classId = TriggerRelationId;
        object.objectId = get_trigger_oid(relid, trigname, missing_ok);
index 917bb4649335c00e70a8a91f9397b14698336caa..b9b693cee1d6773991bf01325c5e556f44f602b7 100644 (file)
@@ -45,8 +45,8 @@ RemoveRewriteRule(RangeVar *relation, const char *ruleName,
        Oid                     owningRel;
        ObjectAddress object;
 
-       /* should match RemoveRewriteRuleById */
-       owningRel = RangeVarGetRelid(relation, ShareUpdateExclusiveLock,
+       /* lock level should match RemoveRewriteRuleById */
+       owningRel = RangeVarGetRelid(relation, AccessExclusiveLock,
                                                                 false, false);
 
        /*