Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cd80073

Browse files
committed
During transaction cleanup, release locks before deleting files.
There's no need to hold onto the locks until the files are needed, and by doing it this way, we reduce the impact on other backends who may be awaiting locks we hold. Noah Misch
1 parent 6cd015b commit cd80073

File tree

1 file changed

+13
-10
lines changed
  • src/backend/access/transam

1 file changed

+13
-10
lines changed

src/backend/access/transam/xact.c

+13-10
Original file line numberDiff line numberDiff line change
@@ -1944,14 +1944,6 @@ CommitTransaction(void)
19441944
*/
19451945
AtEOXact_Inval(true);
19461946

1947-
/*
1948-
* Likewise, dropping of files deleted during the transaction is best done
1949-
* after releasing relcache and buffer pins. (This is not strictly
1950-
* necessary during commit, since such pins should have been released
1951-
* already, but this ordering is definitely critical during abort.)
1952-
*/
1953-
smgrDoPendingDeletes(true);
1954-
19551947
AtEOXact_MultiXact();
19561948

19571949
ResourceOwnerRelease(TopTransactionResourceOwner,
@@ -1961,6 +1953,17 @@ CommitTransaction(void)
19611953
RESOURCE_RELEASE_AFTER_LOCKS,
19621954
true, true);
19631955

1956+
/*
1957+
* Likewise, dropping of files deleted during the transaction is best done
1958+
* after releasing relcache and buffer pins. (This is not strictly
1959+
* necessary during commit, since such pins should have been released
1960+
* already, but this ordering is definitely critical during abort.) Since
1961+
* this may take many seconds, also delay until after releasing locks.
1962+
* Other backends will observe the attendant catalog changes and not
1963+
* attempt to access affected files.
1964+
*/
1965+
smgrDoPendingDeletes(true);
1966+
19641967
/* Check we've released all catcache entries */
19651968
AtEOXact_CatCache(true);
19661969

@@ -2354,14 +2357,14 @@ AbortTransaction(void)
23542357
AtEOXact_Buffers(false);
23552358
AtEOXact_RelationCache(false);
23562359
AtEOXact_Inval(false);
2357-
smgrDoPendingDeletes(false);
23582360
AtEOXact_MultiXact();
23592361
ResourceOwnerRelease(TopTransactionResourceOwner,
23602362
RESOURCE_RELEASE_LOCKS,
23612363
false, true);
23622364
ResourceOwnerRelease(TopTransactionResourceOwner,
23632365
RESOURCE_RELEASE_AFTER_LOCKS,
23642366
false, true);
2367+
smgrDoPendingDeletes(false);
23652368
AtEOXact_CatCache(false);
23662369

23672370
AtEOXact_GUC(false, 1);
@@ -4238,13 +4241,13 @@ AbortSubTransaction(void)
42384241
AtEOSubXact_RelationCache(false, s->subTransactionId,
42394242
s->parent->subTransactionId);
42404243
AtEOSubXact_Inval(false);
4241-
AtSubAbort_smgr();
42424244
ResourceOwnerRelease(s->curTransactionOwner,
42434245
RESOURCE_RELEASE_LOCKS,
42444246
false, false);
42454247
ResourceOwnerRelease(s->curTransactionOwner,
42464248
RESOURCE_RELEASE_AFTER_LOCKS,
42474249
false, false);
4250+
AtSubAbort_smgr();
42484251

42494252
AtEOXact_GUC(false, s->gucNestLevel);
42504253
AtEOSubXact_SPI(false, s->subTransactionId);

0 commit comments

Comments
 (0)