Skip to content

Commit fd3ce52

Browse files
committed
Do not perform AtEOXact for autonomous transactions for SMgr, pending delete, multixacts
1 parent d618b75 commit fd3ce52

File tree

1 file changed

+27
-17
lines changed
  • src/backend/access/transam

1 file changed

+27
-17
lines changed

src/backend/access/transam/xact.c

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,8 +2013,11 @@ CommitTransaction(void)
20132013
TransactionState s = CurrentTransactionState;
20142014
TransactionId latestXid;
20152015
bool is_parallel_worker;
2016+
bool is_autonomous_transaction;
20162017

20172018
is_parallel_worker = (s->blockState == TBLOCK_PARALLEL_INPROGRESS);
2019+
is_autonomous_transaction = getNestLevelATX() != 0;
2020+
20182021

20192022
/* Enforce parallel mode restrictions during parallel worker commit. */
20202023
if (is_parallel_worker)
@@ -2048,7 +2051,7 @@ CommitTransaction(void)
20482051
* If there weren't any, we are done ... otherwise loop back to check
20492052
* if they queued deferred triggers. Lather, rinse, repeat.
20502053
*/
2051-
if (getNestLevelATX() != 0 || !PreCommit_Portals(false))
2054+
if (is_autonomous_transaction || !PreCommit_Portals(false))
20522055
break;
20532056
}
20542057

@@ -2160,7 +2163,7 @@ CommitTransaction(void)
21602163
RESOURCE_RELEASE_BEFORE_LOCKS,
21612164
true, true);
21622165

2163-
if (getNestLevelATX() == 0)
2166+
if (!is_autonomous_transaction)
21642167
{
21652168
/* Check we've released all buffer pins */
21662169
AtEOXact_Buffers(true);
@@ -2180,38 +2183,45 @@ CommitTransaction(void)
21802183
xactHasRelcacheInvalidationMessages = HasRelcacheInvalidationMessages();
21812184
AtEOXact_Inval(true);
21822185

2183-
AtEOXact_MultiXact();
2184-
2186+
if (!is_autonomous_transaction)
2187+
{
2188+
AtEOXact_MultiXact();
2189+
}
21852190
ResourceOwnerRelease(TopTransactionResourceOwner,
21862191
RESOURCE_RELEASE_LOCKS,
21872192
true, true);
21882193
ResourceOwnerRelease(TopTransactionResourceOwner,
21892194
RESOURCE_RELEASE_AFTER_LOCKS,
21902195
true, true);
21912196

2192-
/*
2193-
* Likewise, dropping of files deleted during the transaction is best done
2194-
* after releasing relcache and buffer pins. (This is not strictly
2195-
* necessary during commit, since such pins should have been released
2196-
* already, but this ordering is definitely critical during abort.) Since
2197-
* this may take many seconds, also delay until after releasing locks.
2198-
* Other backends will observe the attendant catalog changes and not
2199-
* attempt to access affected files.
2200-
*/
2201-
smgrDoPendingDeletes(true);
2197+
if (!is_autonomous_transaction)
2198+
{
2199+
/*
2200+
* Likewise, dropping of files deleted during the transaction is best done
2201+
* after releasing relcache and buffer pins. (This is not strictly
2202+
* necessary during commit, since such pins should have been released
2203+
* already, but this ordering is definitely critical during abort.) Since
2204+
* this may take many seconds, also delay until after releasing locks.
2205+
* Other backends will observe the attendant catalog changes and not
2206+
* attempt to access affected files.
2207+
*/
2208+
smgrDoPendingDeletes(true);
2209+
}
22022210

22032211
/* Check we've released all catcache entries */
22042212
AtEOXact_CatCache(true);
22052213

22062214
AtCommit_Notify();
22072215
AtEOXact_GUC(true, s->gucNestLevel);
2208-
if (getNestLevelATX() == 0)
2216+
if (!is_autonomous_transaction)
2217+
{
22092218
AtEOXact_SPI(true);
2219+
}
22102220
AtEOXact_on_commit_actions(true);
22112221
AtEOXact_Namespace(true, is_parallel_worker);
2212-
AtEOXact_SMgr();
2213-
if (getNestLevelATX() == 0)
2222+
if (!is_autonomous_transaction)
22142223
{
2224+
AtEOXact_SMgr();
22152225
AtEOXact_Files();
22162226
AtEOXact_ComboCid();
22172227
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy