8000 Waiting for maxSnapshotLSN · pct960/postgres@0595253 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0595253

Browse files
committed
Waiting for maxSnapshotLSN
1 parent f169155 commit 0595253

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

src/backend/access/transam/transam.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ TransactionIdDidAbort(TransactionId transactionId)
230230
* are correctly marked subcommit first.
231231
*/
232232
void
233-
TransactionIdCommitTree(TransactionId xid, int nxids, TransactionId *xids)
233+
TransactionIdCommitTree(TransactionId xid, int nxids, TransactionId *xids, XLogRecPtr lsn)
234234
{
235235
TransactionIdSetTreeStatus(xid, nxids, xids,
236236
TRANSACTION_STATUS_COMMITTED,
237-
InvalidXLogRecPtr);
237+
lsn);
238238
}
239239

240240
/*

src/backend/access/transam/twophase.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2354,7 +2354,7 @@ RecordTransactionCommitPrepared(TransactionId xid,
23542354
XLogFlush(recptr);
23552355

23562356
/* Mark the transaction committed in pg_xact */
2357-
TransactionIdCommitTree(xid, nchildren, children);
2357+
TransactionIdCommitTree(xid, nchildren, children, recptr);
23582358

23592359
/* Checkpoint can proceed now */
23602360
MyProc->delayChkptFlags &= ~DELAY_CHKPT_START;

src/backend/access/transam/xact.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,7 @@ getMaxLSNFromSnapshot()
12871287

12881288
//cur = GetActiveSnapshot();
12891289
cur = GetLatestSnapshot();
1290+
//cur = GetTransactionSnapshot();
12901291
if (cur == NULL)
12911292
elog(ERROR, "no active snapshot set");
12921293

@@ -1418,7 +1419,7 @@ RecordTransactionCommit(void)
14181419
*/
14191420
if (!wrote_xlog && synchronous_commit > SYNCHRONOUS_COMMIT_OFF)
14201421
{
1421-
XLogRecPtr XLogMaxLSN = XLogGetMaxLSN(NULL);
1422+
//XLogRecPtr XLogMaxLSN = XLogGetMaxLSN(NULL);
14221423
//XLogRecPtr walSndAppliedLSN = SyncRepGetWalSndLSN();
14231424
//XLogRecPtr RecentFlushPtr = InvalidXLogRecPtr;
14241425
//if (!RecoveryInProgress())
@@ -1441,12 +1442,13 @@ RecordTransactionCommit(void)
14411442
//LWLockRelease(SyncRepLock);
14421443

14431444
XLogRecPtr remoteFlushLSN = ((volatile WalSndCtlData *) WalSndCtl)->lsn[Min(synchronous_commit, SYNC_REP_WAIT_APPLY)];
1444-
elog(INFO, "lsn from snapshot = (%d)", getMaxLSNFromSnapshot());
1445+
XLogRecPtr maxSnapshotLSN = getMaxLSNFromSnapshot();
14451446
//elog(INFO, "maxlsn = (%d), remotelsn = (%d)", XLogMaxLSN, remoteFlushLSN);
14461447

1447-
if((XLogMaxLSN > remoteFlushLSN) && (remoteFlushLSN != 0))
1448+
//if((XLogMaxLSN > remoteFlushLSN) && (remoteFlushLSN != 0))
1449+
if((maxSnapshotLSN > remoteFlushLSN) && (maxSnapshotLSN != 0))
14481450
{
1449-
SyncRepWaitForLSN(XLogMaxLSN, false);
1451+
SyncRepWaitForLSN(maxSnapshotLSN, false);
14501452
//elog(INFO, "RO finished waiting for syncrepwaitforlsn!");
14511453
}
14521454
//elog(INFO, "RO txn maxLSN = (%d), RecntFlushPtr value = (%d), XactMaxLSN = (%d)", XLogMaxLSN, RecentFlushPtr, XactMaxLSN);
@@ -1557,15 +1559,15 @@ RecordTransactionCommit(void)
15571559
synchronous_commit > SYNCHRONOUS_COMMIT_OFF) ||
15581560
forceSyncCommit || nrels > 0)
15591561
{
1560-
XLogRecPtr maxLSN = XLogGetMaxLSN(0);
1562+
//XLogRecPtr maxLSN = XLogGetMaxLSN(0);
15611563
//elog(INFO, "XactLastRecEnd=(%d), maxLSN=(%d), WalSndCtl->lsn[mode]=(%d, %d, %d)", XactLastRecEnd, maxLSN, WalSndCtl->lsn[0], WalSndCtl->lsn[1], WalSndCtl->lsn[2]);
15621564
XLogFlush(XactLastRecEnd);
15631565

15641566
/*
15651567
* Now we may update the CLOG, if we wrote a COMMIT record above
15661568
*/
15671569
if (markXidCommitted)
1568-
TransactionIdCommitTree(xid, nchildren, children);
1570+
TransactionIdCommitTree(xid, nchildren, children, XactLastRecEnd);
15691571
}
15701572
else
15711573
{
@@ -2382,6 +2384,13 @@ CommitTransaction(void)
23822384
*/
23832385
ProcArrayEndTransaction(MyProc, latestXid);
23842386

2387+
//TransactionId xid = GetTopTransactionIdIfAny();
2388+
//bool markXidCommitted = TransactionIdIsValid(xid);
2389+
//bool wrote_xlog = (XactLastCommitEnd != 0);
2390+
2391+
//if (wrote_xlog && markXidCommitted)
2392+
// SyncRepWaitForLSN(XactLastCommitEnd, true);
2393+
23852394
/*
23862395
* This is all post-commit cleanup. Note that if an error is raised here,
23872396
* it's too late to abort the transaction. This should be just
@@ -6048,7 +6057,7 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
60486057
/*
60496058
* Mark the transaction committed in pg_xact.
60506059
*/
6051-
TransactionIdCommitTree(xid, parsed->nsubxacts, parsed->subxacts);
6060+
TransactionIdCommitTree(xid, parsed->nsubxacts, parsed->subxacts, lsn);
60526061
}
60536062
else
60546063
{

src/include/access/transam.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ extern PGDLLIMPORT VariableCache ShmemVariableCache;
273273
*/
274274
extern bool TransactionIdDidCommit(TransactionId transactionId);
275275
extern bool TransactionIdDidAbort(TransactionId transactionId);
276-
extern void TransactionIdCommitTree(TransactionId xid, int nxids, TransactionId *xids);
276+
extern void TransactionIdCommitTree(TransactionId xid, int nxids, TransactionId *xids, XLogRecPtr lsn);
277277
extern void TransactionIdAsyncCommitTree(TransactionId xid, int nxids, TransactionId *xids, XLogRecPtr lsn);
278278
extern void TransactionIdAbortTree(TransactionId xid, int nxids, TransactionId *xids);
279279
extern bool TransactionIdPrecedes(TransactionId id1, TransactionId id2);

0 commit comments

Comments
 (0)
0