Skip to content

Commit d4cd07d

Browse files
committed
Fix handling pending deletes for ATX
1 parent cd7a710 commit d4cd07d

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

src/backend/access/transam/xact.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,7 @@ typedef struct {
18561856
void *SPIState;
18571857
void *SnapshotState;
18581858
void *PredicateState;
1859+
void *StorageState;
18591860
struct TransInvalidationInfo* InvalidationInfo;
18601861

18611862
List *on_commit_actions;
@@ -2197,19 +2198,16 @@ CommitTransaction(void)
21972198
RESOURCE_RELEASE_AFTER_LOCKS,
21982199
true, true);
21992200

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

22142212
AtCommit_Notify();
22152213
AtEOXact_GUC(true, s->gucNestLevel);
@@ -3532,7 +3530,8 @@ void SuspendTransaction(void)
35323530

35333531
sus->SnapshotState = SuspendSnapshot(); /* only before the resource-owner stuff */
35343532
sus->PredicateState = SuspendPredicate();
3535-
3533+
sus->StorageState = SuspendStorage();
3534+
35363535
if (HasCatcacheInvalidationMessages())
35373536
{
35383537
ResetCatalogCaches();
@@ -3655,6 +3654,7 @@ bool ResumeTransaction(void)
36553654

36563655
ResumeSnapshot(sus->SnapshotState); /* only after the resource-owner stuff */
36573656
ResumePredicate(sus->PredicateState);
3657+
ResumeStorage(sus->StorageState);
36583658
ResumeInvalidationInfo(sus->InvalidationInfo);
36593659
if (xactHasCatcacheInvalidationMessages)
36603660
{

src/backend/catalog/storage.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,3 +563,15 @@ smgr_redo(XLogReaderState *record)
563563
else
564564
elog(PANIC, "smgr_redo: unknown op code %u", info);
565565
}
566+
567+
void* SuspendStorage(void)
568+
{
569+
PendingRelDelete* pending = pendingDeletes;
570+
pendingDeletes = NULL;
571+
return pending;
572+
}
573+
574+
void ResumeStorage(void* ctx)
575+
{
576+
pendingDeletes = (PendingRelDelete*)ctx;
577+
}

src/include/catalog/storage.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,7 @@ extern void AtSubCommit_smgr(void);
3333
extern void AtSubAbort_smgr(void);
3434
extern void PostPrepare_smgr(void);
3535

36+
extern void* SuspendStorage(void);
37+
extern void ResumeStorage(void* ctx);
38+
3639
#endif /* STORAGE_H */

0 commit comments

Comments
 (0)