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

Commit78dd16d

Browse files
committed
Support read committed isolation level
1 parente83a073 commit78dd16d

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

‎contrib/pg_xtm/pg_dtm.c‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ static TransactionId DtmMinXid;
8686
staticboolDtmHasGlobalSnapshot;
8787
staticboolDtmIsGlobalTransaction;
8888
staticintDtmLocalXidReserve;
89+
staticintDtmCurcid;
90+
staticSnapshotDtmLastSnapshot;
8991
staticTransactionManagerDtmTM= {DtmGetTransactionStatus,DtmSetTransactionStatus,DtmGetSnapshot,DtmGetNewTransactionId,DtmGetOldestXmin };
9092

9193

9294
#defineXTM_TRACE(fmt, ...)
93-
//#define XTM_INFO(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
94-
#defineXTM_INFO(fmt, ...)
95+
#defineXTM_INFO(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
96+
//#define XTM_INFO(fmt, ...)
9597

9698
staticvoidDumpSnapshot(Snapshots,char*name)
9799
{
@@ -100,8 +102,8 @@ static void DumpSnapshot(Snapshot s, char *name)
100102
char*cursor=buf;
101103
cursor+=sprintf(
102104
cursor,
103-
"snapshot %s for transaction %d: xmin=%d, xmax=%d, active=[",
104-
name,GetCurrentTransactionId(),s->xmin,s->xmax
105+
"snapshot %s(%p) for transaction %d: xmin=%d, xmax=%d, active=[",
106+
name,s,GetCurrentTransactionId(),s->xmin,s->xmax
105107
);
106108
for (i=0;i<s->xcnt;i++) {
107109
if (i==0) {
@@ -480,10 +482,12 @@ DtmGetNewTransactionId(bool isSubXact)
480482

481483
staticSnapshotDtmGetSnapshot(Snapshotsnapshot)
482484
{
483-
if (TransactionIdIsValid(DtmNextXid)) {
484-
if (!DtmHasGlobalSnapshot) {
485+
if (TransactionIdIsValid(DtmNextXid)&&IsMVCCSnapshot(snapshot)&&snapshot!=&CatalogSnapshotData) {
486+
if (!DtmHasGlobalSnapshot&& (snapshot!=DtmLastSnapshot||DtmCurcid!=snapshot->curcid)) {
485487
DtmGlobalGetSnapshot(DtmNextXid,&DtmSnapshot,&DtmMinXid);
486488
}
489+
DtmCurcid=snapshot->curcid;
490+
DtmLastSnapshot=snapshot;
487491
DtmMergeSnapshots(snapshot,&DtmSnapshot);
488492
if (!IsolationUsesXactSnapshot()) {
489493
DtmHasGlobalSnapshot= false;
@@ -595,6 +599,7 @@ DtmXactCallback(XactEvent event, void *arg)
595599
LWLockRelease(dtm->hashLock);
596600
}
597601
DtmNextXid=InvalidTransactionId;
602+
DtmLastSnapshot=NULL;
598603
}
599604
}
600605
}
@@ -701,6 +706,7 @@ dtm_begin_transaction(PG_FUNCTION_ARGS)
701706

702707
DtmHasGlobalSnapshot= true;
703708
DtmIsGlobalTransaction= true;
709+
DtmLastSnapshot=NULL;
704710

705711
PG_RETURN_INT32(DtmNextXid);
706712
}
@@ -716,6 +722,7 @@ Datum dtm_join_transaction(PG_FUNCTION_ARGS)
716722

717723
DtmHasGlobalSnapshot= true;
718724
DtmIsGlobalTransaction= true;
725+
DtmLastSnapshot=NULL;
719726

720727
PG_RETURN_VOID();
721728
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
970970
* and more contention on the PGXACT array.
971971
*/
972972
bool
973-
HeapTupleSatisfiesMVCC(HeapTuplehtup,Snapshotsnapshot,
973+
_HeapTupleSatisfiesMVCC(HeapTuplehtup,Snapshotsnapshot,
974974
Bufferbuffer)
975975
{
976976
HeapTupleHeadertuple=htup->t_data;
@@ -1156,7 +1156,7 @@ HeapTupleSatisfiesMVCC(HeapTuple htup, Snapshot snapshot,
11561156

11571157
return false;
11581158
}
1159-
#if0
1159+
#if1
11601160
bool
11611161
HeapTupleSatisfiesMVCC(HeapTuplehtup,Snapshotsnapshot,
11621162
Bufferbuffer)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp