Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit352b6b8

Browse files
committed
Merge branch 'PGPROEE9_6_atx_fix' into PGPROEE9_6
2 parentsdf21be5 +b03c87d commit352b6b8

File tree

5 files changed

+79
-12
lines changed

5 files changed

+79
-12
lines changed

‎src/backend/access/transam/xact.c

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ typedef struct SubXactCallbackItem
294294

295295
staticSubXactCallbackItem*SubXact_callbacks=NULL;
296296

297+
staticboolxactHasCatcacheInvalidationMessages;
298+
staticboolxactHasRelcacheInvalidationMessages;
297299

298300
/* local function prototypes */
299301
staticvoidAssignTransactionId(TransactionStates);
@@ -1850,7 +1852,9 @@ typedef struct {
18501852
void*TriggerState;
18511853
void*SPIState;
18521854
void*SnapshotState;
1855+
structTransInvalidationInfo*InvalidationInfo;
18531856
}SuspendedTransactionState;
1857+
18541858
staticintsuspendedXactNum=0;
18551859
staticSuspendedTransactionStatesuspendedXacts[MAX_SUSPENDED_XACTS];
18561860

@@ -2168,6 +2172,8 @@ CommitTransaction(void)
21682172
* waiting for lock on a relation we've modified, we want them to know
21692173
* about the catalog change before they start using the relation).
21702174
*/
2175+
xactHasCatcacheInvalidationMessages=HasCatcacheInvalidationMessages();
2176+
xactHasRelcacheInvalidationMessages=HasRelcacheInvalidationMessages();
21712177
AtEOXact_Inval(true);
21722178

21732179
AtEOXact_MultiXact();
@@ -2662,6 +2668,8 @@ AbortTransaction(void)
26622668
AtEOXact_Buffers(false);
26632669
}
26642670
AtEOXact_RelationCache(false);
2671+
xactHasCatcacheInvalidationMessages=HasCatcacheInvalidationMessages();
2672+
xactHasRelcacheInvalidationMessages=HasRelcacheInvalidationMessages();
26652673
AtEOXact_Inval(false);
26662674
AtEOXact_MultiXact();
26672675
ResourceOwnerRelease(TopTransactionResourceOwner,
@@ -3504,7 +3512,20 @@ void SuspendTransaction(void)
35043512
SuspendedTransactionState*sus=suspendedXacts+suspendedXactNum++;
35053513

35063514
sus->TopTransactionStateData=TopTransactionStateData;
3515+
35073516
sus->SnapshotState=SuspendSnapshot();/* only before the resource-owner stuff */
3517+
3518+
if (HasCatcacheInvalidationMessages())
3519+
{
3520+
ResetCatalogCaches();
3521+
}
3522+
if (HasRelcacheInvalidationMessages())
3523+
{
3524+
RelationCacheInvalidate();
3525+
}
3526+
sus->InvalidationInfo=SuspendInvalidationInfo();
3527+
xactHasCatcacheInvalidationMessages= false;
3528+
xactHasRelcacheInvalidationMessages= false;
35083529

35093530
tts=&TopTransactionStateData;
35103531
tts->state=TRANS_INPROGRESS;
@@ -3545,7 +3566,6 @@ void SuspendTransaction(void)
35453566
MOVELEFT(sus->CurTransactionContext,CurTransactionContext,NULL);
35463567
MOVELEFT(sus->TransactionAbortContext,TransactionAbortContext,NULL);
35473568

3548-
MemoryContextSwitchTo(CurTransactionContext);
35493569
MOVELEFT(sus->CurrentResourceOwner,CurrentResourceOwner,NULL);
35503570
MOVELEFT(sus->CurTransactionResourceOwner,CurTransactionResourceOwner,NULL);
35513571
MOVELEFT(sus->TopTransactionResourceOwner,TopTransactionResourceOwner,NULL);
@@ -3602,17 +3622,26 @@ bool ResumeTransaction(void)
36023622
prepareGID=sus->prepareGID;
36033623
forceSyncCommit=sus->forceSyncCommit;
36043624

3625+
MemoryContextDelete(TransactionAbortContext);
3626+
36053627
TopTransactionContext=sus->TopTransactionContext;
36063628
CurTransactionContext=sus->CurTransactionContext;
36073629
TransactionAbortContext=sus->TransactionAbortContext;
36083630

3609-
//MemoryContextSwitchTo(CurTransactionContext);
36103631
CurrentResourceOwner=sus->CurrentResourceOwner;
3611-
Assert(*(unsigned long long*)CurrentResourceOwner!=0x7f7f7f7f7f7f7f7f);
36123632
CurTransactionResourceOwner=sus->CurTransactionResourceOwner;
36133633
TopTransactionResourceOwner=sus->TopTransactionResourceOwner;
36143634

36153635
ResumeSnapshot(sus->SnapshotState);/* only after the resource-owner stuff */
3636+
ResumeInvalidationInfo(sus->InvalidationInfo);
3637+
if (xactHasCatcacheInvalidationMessages)
3638+
{
3639+
ResetCatalogCaches();
3640+
}
3641+
if (xactHasRelcacheInvalidationMessages)
3642+
{
3643+
RelationCacheInvalidate();
3644+
}
36163645

36173646
MyProc->backendId=sus->vxid.backendId;
36183647
MyProc->lxid=sus->vxid.localTransactionId;

‎src/backend/utils/cache/inval.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,32 @@ xactGetCommittedInvalidationMessages(SharedInvalidationMessage **msgs,
841841
returnnumSharedInvalidMessagesArray;
842842
}
843843

844+
boolHasCatcacheInvalidationMessages(void)
845+
{
846+
returntransInvalInfo!=NULL
847+
&& (transInvalInfo->CurrentCmdInvalidMsgs.cclist!=NULL
848+
||transInvalInfo->PriorCmdInvalidMsgs.cclist!=NULL);
849+
}
850+
851+
boolHasRelcacheInvalidationMessages(void)
852+
{
853+
returntransInvalInfo!=NULL
854+
&& (transInvalInfo->CurrentCmdInvalidMsgs.rclist!=NULL
855+
||transInvalInfo->PriorCmdInvalidMsgs.rclist!=NULL);
856+
}
857+
858+
structTransInvalidationInfo*SuspendInvalidationInfo()
859+
{
860+
TransInvalidationInfo*state=transInvalInfo;
861+
transInvalInfo=NULL;
862+
returnstate;
863+
}
864+
865+
voidResumeInvalidationInfo(structTransInvalidationInfo*inval)
866+
{
867+
transInvalInfo=inval;
868+
}
869+
844870
/*
845871
* ProcessCommittedInvalidationMessages is executed by xact_redo_commit() or
846872
* standby_redo() to process invalidation messages. Currently that happens

‎src/backend/utils/resowner/resowner.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include"postgres.h"
2222

2323
#include"access/hash.h"
24+
#include"access/xact.h"
2425
#include"storage/predicate.h"
2526
#include"storage/proc.h"
2627
#include"utils/memutils.h"
@@ -555,7 +556,7 @@ ResourceOwnerReleaseInternal(ResourceOwner owner,
555556
}
556557
elseif (phase==RESOURCE_RELEASE_LOCKS)
557558
{
558-
if (isTopLevel)
559+
if (isTopLevel&&getNestLevelATX()==0)
559560
{
560561
/*
561562
* For a top-level xact we are going to release all locks (or at
@@ -578,7 +579,7 @@ ResourceOwnerReleaseInternal(ResourceOwner owner,
578579
LOCALLOCK**locks;
579580
intnlocks;
580581

581-
Assert(owner->parent!=NULL);
582+
//Assert(owner->parent != NULL);
582583

583584
/*
584585
* Pass the list of locks owned by this resource owner to the lock
@@ -595,7 +596,7 @@ ResourceOwnerReleaseInternal(ResourceOwner owner,
595596
nlocks=owner->nlocks;
596597
}
597598

598-
if (isCommit)
599+
if (isCommit&& !isTopLevel)
599600
LockReassignCurrentOwner(locks,nlocks);
600601
else
601602
LockReleaseCurrentOwner(locks,nlocks);

‎src/backend/utils/time/snapmgr.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,9 +2176,6 @@ void *SuspendSnapshot(void)
21762176
MOVELEFT(s->ActiveSnapshot,ActiveSnapshot,NULL);
21772177
MOVELEFT(s->OldestActiveSnapshot,OldestActiveSnapshot,NULL);
21782178

2179-
RelationCacheInvalidate();
2180-
ResetCatalogCaches();
2181-
21822179
returns;
21832180
}
21842181

@@ -2191,6 +2188,13 @@ void ResumeSnapshot(void *data)
21912188
//UnregisterSnapshot(CatalogSnapshot);
21922189
//UnregisterSnapshot(HistoricSnapshot);
21932190

2191+
free(CurrentSnapshotData.xip);
2192+
free(CurrentSnapshotData.subxip);
2193+
free(SecondarySnapshotData.xip);
2194+
free(SecondarySnapshotData.subxip);
2195+
free(CatalogSnapshotData.xip);
2196+
free(CatalogSnapshotData.subxip);
2197+
21942198
CurrentSnapshotData=s->CurrentSnapshotData;
21952199
SecondarySnapshotData=s->SecondarySnapshotData;
21962200
CatalogSnapshotData=s->CatalogSnapshotData;
@@ -2207,8 +2211,5 @@ void ResumeSnapshot(void *data)
22072211
ActiveSnapshot=s->ActiveSnapshot;
22082212
OldestActiveSnapshot=s->OldestActiveSnapshot;
22092213

2210-
RelationCacheInvalidate();
2211-
ResetCatalogCaches();
2212-
22132214
free(s);
22142215
}

‎src/include/utils/inval.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,14 @@ extern void CacheRegisterRelcacheCallback(RelcacheCallbackFunction func,
6161
externvoidCallSyscacheCallbacks(intcacheid,uint32hashvalue);
6262

6363
externvoidInvalidateSystemCaches(void);
64+
65+
/* Funcitons below are needed to support ATX */
66+
67+
structTransInvalidationInfo;
68+
69+
externboolHasCatcacheInvalidationMessages(void);
70+
externboolHasRelcacheInvalidationMessages(void);
71+
externstructTransInvalidationInfo*SuspendInvalidationInfo(void);
72+
externvoidResumeInvalidationInfo(structTransInvalidationInfo*inval);
73+
6474
#endif/* INVAL_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp