diff options
author | Robert Haas <rhaas@postgresql.org> | 2012-06-14 10:19:33 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2012-06-14 10:19:33 -0400 |
commit | cd80073445ff5d72ad42923ba3d017541feae103 (patch) | |
tree | 069ff417fafbd7b11a34f36d5402da2c4698394d | |
parent | 6cd015bea38b8a59feb84bf238a880a3b503cf5f (diff) | |
download | postgresql-cd80073445ff5d72ad42923ba3d017541feae103.tar.gz postgresql-cd80073445ff5d72ad42923ba3d017541feae103.zip |
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
-rw-r--r-- | src/backend/access/transam/xact.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 8f00186dd74..8e4a45568b3 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -1944,14 +1944,6 @@ CommitTransaction(void) */ AtEOXact_Inval(true); - /* - * Likewise, dropping of files deleted during the transaction is best done - * after releasing relcache and buffer pins. (This is not strictly - * necessary during commit, since such pins should have been released - * already, but this ordering is definitely critical during abort.) - */ - smgrDoPendingDeletes(true); - AtEOXact_MultiXact(); ResourceOwnerRelease(TopTransactionResourceOwner, @@ -1961,6 +1953,17 @@ CommitTransaction(void) RESOURCE_RELEASE_AFTER_LOCKS, true, true); + /* + * Likewise, dropping of files deleted during the transaction is best done + * after releasing relcache and buffer pins. (This is not strictly + * necessary during commit, since such pins should have been released + * already, but this ordering is definitely critical during abort.) Since + * this may take many seconds, also delay until after releasing locks. + * Other backends will observe the attendant catalog changes and not + * attempt to access affected files. + */ + smgrDoPendingDeletes(true); + /* Check we've released all catcache entries */ AtEOXact_CatCache(true); @@ -2354,7 +2357,6 @@ AbortTransaction(void) AtEOXact_Buffers(false); AtEOXact_RelationCache(false); AtEOXact_Inval(false); - smgrDoPendingDeletes(false); AtEOXact_MultiXact(); ResourceOwnerRelease(TopTransactionResourceOwner, RESOURCE_RELEASE_LOCKS, @@ -2362,6 +2364,7 @@ AbortTransaction(void) ResourceOwnerRelease(TopTransactionResourceOwner, RESOURCE_RELEASE_AFTER_LOCKS, false, true); + smgrDoPendingDeletes(false); AtEOXact_CatCache(false); AtEOXact_GUC(false, 1); @@ -4238,13 +4241,13 @@ AbortSubTransaction(void) AtEOSubXact_RelationCache(false, s->subTransactionId, s->parent->subTransactionId); AtEOSubXact_Inval(false); - AtSubAbort_smgr(); ResourceOwnerRelease(s->curTransactionOwner, RESOURCE_RELEASE_LOCKS, false, false); ResourceOwnerRelease(s->curTransactionOwner, RESOURCE_RELEASE_AFTER_LOCKS, false, false); + AtSubAbort_smgr(); AtEOXact_GUC(false, s->gucNestLevel); AtEOSubXact_SPI(false, s->subTransactionId); |