From 8833a319b9869c75611d218fada7934a3207c1b8 Mon Sep 17 00:00:00 2001 From: xiong_xiaojun Date: Mon, 24 Aug 2020 17:34:59 +0800 Subject: [PATCH] fix csnlog cannot be found thar occur in standby node, and remove the Warning log in InternalGetCommitSeqNo. --- .../storage/access/transam/csnlog.cpp | 21 ------------------- .../storage/access/transam/xlog.cpp | 8 ++++++- src/gausskernel/storage/ipc/procarray.cpp | 2 -- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/gausskernel/storage/access/transam/csnlog.cpp b/src/gausskernel/storage/access/transam/csnlog.cpp index e35ff949d..b23cb1b5b 100755 --- a/src/gausskernel/storage/access/transam/csnlog.cpp +++ b/src/gausskernel/storage/access/transam/csnlog.cpp @@ -413,27 +413,6 @@ static CommitSeqNo InternalGetCommitSeqNo(TransactionId xid) int slotno; CommitSeqNo csn; - /* Can't ask about stuff that might not be around anymore */ - TransactionId currGlobalXmin = pg_atomic_read_u64(&t_thrd.xact_cxt.ShmemVariableCache->recentGlobalXmin); - -#ifdef ENABLE_MULTIPLE_NODES - if (TransactionIdPrecedes(xid, currGlobalXmin)) -#else - if (TransactionIdPrecedes(xid, currGlobalXmin) && !RecoveryInProgress()) -#endif - { - ereport(WARNING, - (errcode(ERRCODE_SNAPSHOT_INVALID), - (errmsg("Snapshot too old when read CSN, this is a safe error" - "if there is breakdown in gtm of CN log"), - errdetail("current xid %lu is lower than " - "recentGlobalXmin: %lu", - xid, - currGlobalXmin), - errhint("This is a safe error report, will not impact " - "data consistency, retry your query if needed.")))); - } - if (!TransactionIdIsNormal(xid)) { if (xid == InvalidTransactionId) return COMMITSEQNO_ABORTED; diff --git a/src/gausskernel/storage/access/transam/xlog.cpp b/src/gausskernel/storage/access/transam/xlog.cpp index 10ca376be..056349da4 100755 --- a/src/gausskernel/storage/access/transam/xlog.cpp +++ b/src/gausskernel/storage/access/transam/xlog.cpp @@ -10891,7 +10891,13 @@ bool CreateRestartPoint(int flags) */ if (!g_instance.attr.attr_storage.enableIncrementalCheckpoint || elapsed_secs >= u_sess->attr.attr_storage.fullCheckPointTimeout) { - TruncateCSNLOG(GetOldestXmin(NULL)); + TransactionId globalXmin = InvalidTransactionId; + (void)GetOldestActiveTransactionId(&globalXmin); + TransactionId cutoff_xid = GetOldestXmin(NULL); + if (TransactionIdIsNormal(globalXmin) && TransactionIdPrecedes(globalXmin, cutoff_xid)) { + cutoff_xid = globalXmin; + } + TruncateCSNLOG(cutoff_xid); t_thrd.checkpoint_cxt.last_truncate_log_time = now; } } diff --git a/src/gausskernel/storage/ipc/procarray.cpp b/src/gausskernel/storage/ipc/procarray.cpp index a9782d710..0877e6a19 100644 --- a/src/gausskernel/storage/ipc/procarray.cpp +++ b/src/gausskernel/storage/ipc/procarray.cpp @@ -2050,8 +2050,6 @@ TransactionId GetOldestActiveTransactionId(TransactionId *globalXmin) TransactionIdAdvance(xmax); TransactionId xmin = xmax; - Assert(!RecoveryInProgress()); - LWLockAcquire(ProcArrayLock, LW_SHARED); /*