8000 Using snapshot lsn · pct960/postgres@5afae09 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5afae09

Browse files
committed
Using snapshot lsn
1 parent 3be82b2 commit 5afae09

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

src/backend/access/transam/xact.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2098,7 +2098,8 @@ StartTransaction(void)
20982098
VirtualTransactionId vxid;
20992099

21002100
//maxLSN = XLogGetMaxLSN(NULL);
2101-
maxLSN = GetInsertRecPtr();
2101+
//maxLSN = GetXLogInsertRecPtr();
2102+
maxLSN = GetCurrentSnapshotLSN();
21022103
//elog(INFO, "maxlsn init");
21032104

21042105
/*

src/backend/storage/ipc/procarray.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,6 @@ GetSnapshotDataInitOldSnapshot(Snapshot snapshot)
20952095
* If not using "snapshot too old" feature, fill related fields with
20962096
* dummy values that don't require any locking.
20972097
*/
2098-
snapshot->lsn = InvalidXLogRecPtr;
20992098
snapshot->whenTaken = 0;
21002099
}
21012100
else
@@ -2105,10 +2104,11 @@ GetSnapshotDataInitOldSnapshot(Snapshot snapshot)
21052104
* snapshot becomes old enough to need to fall back on the special
21062105
* "old snapshot" logic.
21072106
*/
2108-
snapshot->lsn = GetXLogInsertRecPtr();
21092107
snapshot->whenTaken = GetSnapshotCurrentTimestamp();
21102108
MaintainOldSnapshotTimeMapping(snapshot->whenTaken, snapshot->xmin);
21112109
}
2110+
2111+
snapshot->lsn = GetXLogInsertRecPtr();
21122112
}
21132113

21142114
/*

src/backend/utils/time/snapmgr.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,19 @@ SnapshotSetCommandId(CommandId curcid)
499499
/* Should we do the same with CatalogSnapshot? */
500500
}
501501

502+
/*
503+
* GetCurrentSnapshotLSN
504+
* Propagate CommandCounterIncrement into the static snapshots, if set
505+
*/
506+
XLogRecPtr
507+
GetCurrentSnapshotLSN()
508+
{
509+
if (CurrentSnapshot)
510+
return CurrentSnapshot->lsn;
511+
512+
return InvalidXLogRecPtr;
513+
}
514+
502515
/*
503516
* SetTransactionSnapshot
504517
* Set the transaction's snapshot from an imported MVCC snapshot.

src/include/utils/snapmgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ OldSnapshotThresholdActive(void)
106106
extern Snapshot GetTransactionSnapshot(void);
107107
extern Snapshot GetLatestSnapshot(void);
108108
extern void SnapshotSetCommandId(CommandId curcid);
109+
extern XLogRecPtr GetCurrentSnapshotLSN();
109110
extern Snapshot GetOldestSnapshot(void);
110111

111112
extern Snapshot GetCatalogSnapshot(Oid relid);

0 commit comments

Comments
 (0)
0