From 66aea199368af1eb044321618763c839e6478ba7 Mon Sep 17 00:00:00 2001 From: April01xxx Date: Wed, 13 Oct 2021 15:36:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=81=E5=A4=8D=E5=88=B6sy?= =?UTF-8?q?nchronous=5Fcommit=E5=8F=82=E6=95=B0=E5=B7=A5=E4=BD=9C=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../storage/replication/syncrep.cpp | 21 ++++++++++--------- .../knl/knl_guc/knl_session_attr_storage.h | 1 + 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/gausskernel/storage/replication/syncrep.cpp b/src/gausskernel/storage/replication/syncrep.cpp index 29b237d24..df592d8e4 100755 --- a/src/gausskernel/storage/replication/syncrep.cpp +++ b/src/gausskernel/storage/replication/syncrep.cpp @@ -70,7 +70,6 @@ */ volatile bool most_available_sync = false; -static volatile int SyncRepWaitMode = SYNC_REP_WAIT_FLUSH; const int MAX_SYNC_REP_RETRY_COUNT = 1000; const int SYNC_REP_SLEEP_DELAY = 1000; @@ -155,7 +154,7 @@ void SyncRepWaitForLSN(XLogRecPtr XactCommitLSN, bool enableHandleCancel) { char *new_status = NULL; const char *old_status = NULL; - int mode = SyncRepWaitMode; + int mode = u_sess->attr.attr_storage.sync_rep_wait_mode; /* * Fast exit if user has not requested sync replication, or there are no @@ -516,6 +515,7 @@ void SyncRepReleaseWaiters(void) int numreceive = 0; int numwrite = 0; int numflush = 0; + int numapply = 0; bool got_recptr = false; bool am_sync = false; @@ -590,15 +590,16 @@ void SyncRepReleaseWaiters(void) } if (XLByteLT(walsndctl->lsn[SYNC_REP_WAIT_APPLY], replayPtr)) { walsndctl->lsn[SYNC_REP_WAIT_APPLY] = t_thrd.walsender_cxt.MyWalSnd->apply; - numflush = SyncRepWakeQueue(false, SYNC_REP_WAIT_APPLY); + numapply = SyncRepWakeQueue(false, SYNC_REP_WAIT_APPLY); } LWLockRelease(SyncRepLock); ereport(DEBUG3, - (errmsg("released %d procs up to receive %X/%X, %d procs up to write %X/%X, %d procs up to flush %X/%X", + (errmsg("released %d procs up to receive %X/%X, %d procs up to write %X/%X, %d procs up to flush %X/%X, %d procs up to apply %X/%X", numreceive, (uint32)(receivePtr >> 32), (uint32)receivePtr, numwrite, (uint32)(writePtr >> 32), - (uint32)writePtr, numflush, (uint32)(flushPtr >> 32), (uint32)flushPtr))); + (uint32)writePtr, numflush, (uint32)(flushPtr >> 32), (uint32)flushPtr, + numapply, (uint32)(replayPtr >> 32), (uint32)replayPtr))); } /* @@ -1821,19 +1822,19 @@ void assign_synchronous_commit(int newval, void *extra) { switch (newval) { case SYNCHRONOUS_COMMIT_REMOTE_RECEIVE: - SyncRepWaitMode = SYNC_REP_WAIT_RECEIVE; + u_sess->attr.attr_storage.sync_rep_wait_mode = SYNC_REP_WAIT_RECEIVE; break; case SYNCHRONOUS_COMMIT_REMOTE_WRITE: - SyncRepWaitMode = SYNC_REP_WAIT_WRITE; + u_sess->attr.attr_storage.sync_rep_wait_mode = SYNC_REP_WAIT_WRITE; break; case SYNCHRONOUS_COMMIT_REMOTE_FLUSH: - SyncRepWaitMode = SYNC_REP_WAIT_FLUSH; + u_sess->attr.attr_storage.sync_rep_wait_mode = SYNC_REP_WAIT_FLUSH; break; case SYNCHRONOUS_COMMIT_REMOTE_APPLY: - SyncRepWaitMode = SYNC_REP_WAIT_APPLY; + u_sess->attr.attr_storage.sync_rep_wait_mode = SYNC_REP_WAIT_APPLY; break; default: - SyncRepWaitMode = SYNC_REP_NO_WAIT; + u_sess->attr.attr_storage.sync_rep_wait_mode = SYNC_REP_NO_WAIT; break; } } diff --git a/src/include/knl/knl_guc/knl_session_attr_storage.h b/src/include/knl/knl_guc/knl_session_attr_storage.h index b8f340cbd..33fef53a5 100755 --- a/src/include/knl/knl_guc/knl_session_attr_storage.h +++ b/src/include/knl/knl_guc/knl_session_attr_storage.h @@ -191,6 +191,7 @@ typedef struct knl_session_attr_storage { char* Inplace_upgrade_next_system_object_oids; int resource_track_log; int guc_synchronous_commit; + int sync_rep_wait_mode; int sync_method; int autovacuum_mode; int cstore_insert_mode;