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

Commitcd7a710

Browse files
committed
Fix predicate locks for serializable autonomous transactions
1 parente47510f commitcd7a710

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,7 @@ typedef struct {
18551855
void*TriggerState;
18561856
void*SPIState;
18571857
void*SnapshotState;
1858+
void*PredicateState;
18581859
structTransInvalidationInfo*InvalidationInfo;
18591860

18601861
List*on_commit_actions;
@@ -3530,6 +3531,7 @@ void SuspendTransaction(void)
35303531
sus->TopTransactionStateData=TopTransactionStateData;
35313532

35323533
sus->SnapshotState=SuspendSnapshot();/* only before the resource-owner stuff */
3534+
sus->PredicateState=SuspendPredicate();
35333535

35343536
if (HasCatcacheInvalidationMessages())
35353537
{
@@ -3652,6 +3654,7 @@ bool ResumeTransaction(void)
36523654
TopTransactionResourceOwner=sus->TopTransactionResourceOwner;
36533655

36543656
ResumeSnapshot(sus->SnapshotState);/* only after the resource-owner stuff */
3657+
ResumePredicate(sus->PredicateState);
36553658
ResumeInvalidationInfo(sus->InvalidationInfo);
36563659
if (xactHasCatcacheInvalidationMessages)
36573660
{

‎src/backend/storage/lmgr/predicate.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
#include"utils/rel.h"
203203
#include"utils/snapmgr.h"
204204
#include"utils/tqual.h"
205+
#include"utils/memutils.h"
205206

206207
/* Uncomment the next line to test the graceful degradation code. */
207208
/* #define TEST_OLDSERXID */
@@ -4963,3 +4964,34 @@ predicatelock_twophase_recover(TransactionId xid, uint16 info,
49634964
CreatePredicateLock(&lockRecord->target,targettaghash,sxact);
49644965
}
49654966
}
4967+
4968+
typedefstructSuspendedPredicateState
4969+
{
4970+
HTAB*LocalPredicateLockHash;
4971+
SERIALIZABLEXACT*MySerializableXact;
4972+
boolMyXactDidWrite;
4973+
}SuspendedPredicateState;
4974+
4975+
4976+
void*SuspendPredicate(void)
4977+
{
4978+
SuspendedPredicateState*s= (SuspendedPredicateState*)MemoryContextAlloc(TopMemoryContext,sizeof(SuspendedPredicateState));
4979+
s->LocalPredicateLockHash=LocalPredicateLockHash;
4980+
s->MySerializableXact=MySerializableXact;
4981+
s->MyXactDidWrite=MyXactDidWrite;
4982+
4983+
LocalPredicateLockHash=NULL;
4984+
MySerializableXact=InvalidSerializableXact;
4985+
MyXactDidWrite= false;
4986+
4987+
returns;
4988+
}
4989+
4990+
voidResumePredicate(void*data)
4991+
{
4992+
SuspendedPredicateState*s= (SuspendedPredicateState*)data;
4993+
LocalPredicateLockHash=s->LocalPredicateLockHash;
4994+
MySerializableXact=s->MySerializableXact;
4995+
MyXactDidWrite=s->MyXactDidWrite;
4996+
pfree(s);
4997+
}

‎src/include/storage/predicate.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,7 @@ extern void PredicateLockTwoPhaseFinish(TransactionId xid, bool isCommit);
7070
externvoidpredicatelock_twophase_recover(TransactionIdxid,uint16info,
7171
void*recdata,uint32len);
7272

73+
externvoid*SuspendPredicate(void);
74+
externvoidResumePredicate(void*data);
75+
7376
#endif/* PREDICATE_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp