From ac8363f2bc5a378f9137ec93f107faf14e18f494 Mon Sep 17 00:00:00 2001 From: "arcoalien@qq.com" Date: Wed, 26 Jan 2022 11:01:37 +0800 Subject: [PATCH] =?UTF-8?q?fix=20issue=20=E9=80=9A=E8=BF=87SET=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=8A=A8=E6=80=81=E4=BF=AE=E6=94=B9synchronous=5Fcomm?= =?UTF-8?q?it=E8=AE=BE=E7=BD=AE=E4=B8=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/utils/misc/guc.cpp | 2 -- src/gausskernel/storage/access/transam/xact.cpp | 5 ++--- src/gausskernel/storage/replication/datasyncrep.cpp | 2 +- src/include/access/xact.h | 3 --- src/include/replication/syncrep.h | 5 +++-- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/common/backend/utils/misc/guc.cpp b/src/common/backend/utils/misc/guc.cpp index 1b25dd201..562792662 100755 --- a/src/common/backend/utils/misc/guc.cpp +++ b/src/common/backend/utils/misc/guc.cpp @@ -216,7 +216,6 @@ #define MS_PER_D (1000 * 60 * 60 * 24) #define H_PER_D 24 -extern volatile int synchronous_commit; extern volatile bool most_available_sync; extern void SetThreadLocalGUC(knl_session_context* session); THR_LOCAL int comm_ackchk_time; @@ -5433,7 +5432,6 @@ bool SelectConfigFiles(const char* userDoption, const char* progname) } ProcessConfigFile(PGC_POSTMASTER); - synchronous_commit = (volatile int)u_sess->attr.attr_storage.guc_synchronous_commit; most_available_sync = (volatile bool)u_sess->attr.attr_storage.guc_most_available_sync; /* diff --git a/src/gausskernel/storage/access/transam/xact.cpp b/src/gausskernel/storage/access/transam/xact.cpp index f1be27eff..183d648e1 100755 --- a/src/gausskernel/storage/access/transam/xact.cpp +++ b/src/gausskernel/storage/access/transam/xact.cpp @@ -121,8 +121,6 @@ extern void uuid_struct_destroy_function(); THR_LOCAL bool CancelStmtForReadOnly = false; /* just need cancel stmt once when DefaultXactReadOnly=true */ THR_LOCAL bool TwoPhaseCommit = false; -volatile int synchronous_commit = SYNCHRONOUS_COMMIT_ON; - extern bool is_user_name_changed(); extern void HDFSAbortCacheBlock(); extern THR_LOCAL Oid lastUDFOid; @@ -1921,7 +1919,8 @@ static TransactionId RecordTransactionCommit(void) * if all to-be-deleted tables are temporary though, since they are lost * anyway if we crash.) */ - if ((wrote_xlog && synchronous_commit > SYNCHRONOUS_COMMIT_OFF) || t_thrd.xact_cxt.forceSyncCommit || nrels > 0) { + if ((wrote_xlog && u_sess->attr.attr_storage.guc_synchronous_commit > SYNCHRONOUS_COMMIT_OFF) || + t_thrd.xact_cxt.forceSyncCommit || nrels > 0) { /* * Synchronous commit case: * diff --git a/src/gausskernel/storage/replication/datasyncrep.cpp b/src/gausskernel/storage/replication/datasyncrep.cpp index cd5479a25..ff3e85b69 100644 --- a/src/gausskernel/storage/replication/datasyncrep.cpp +++ b/src/gausskernel/storage/replication/datasyncrep.cpp @@ -186,7 +186,7 @@ void WaitForDataSync(void) * if we modify the syncmode dynamically, we'll stop wait */ if ((t_thrd.walsender_cxt.WalSndCtl->sync_master_standalone && !IS_SHARED_STORAGE_MODE) || - synchronous_commit <= SYNCHRONOUS_COMMIT_LOCAL_FLUSH) { + u_sess->attr.attr_storage.guc_synchronous_commit <= SYNCHRONOUS_COMMIT_LOCAL_FLUSH) { ereport(WARNING, (errmsg("canceling wait for synchronous replication due to syncmaster standalone."), errdetail("The transaction has already committed locally, but might not have been replicated to " diff --git a/src/include/access/xact.h b/src/include/access/xact.h index fef506c94..a004776f4 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -105,9 +105,6 @@ typedef enum { /* Define the default setting for synchonous_commit */ #define SYNCHRONOUS_COMMIT_ON SYNCHRONOUS_COMMIT_REMOTE_FLUSH -/* Synchronous commit level */ -extern volatile int synchronous_commit; - /* ---------------- * transaction-related XLOG entries * ---------------- diff --git a/src/include/replication/syncrep.h b/src/include/replication/syncrep.h index 519f7e9ec..ef6dcd40e 100755 --- a/src/include/replication/syncrep.h +++ b/src/include/replication/syncrep.h @@ -17,8 +17,9 @@ #include "utils/guc.h" #include "replication/replicainternal.h" -#define SyncRepRequested() \ - (g_instance.attr.attr_storage.max_wal_senders > 0 && synchronous_commit > SYNCHRONOUS_COMMIT_LOCAL_FLUSH) +#define SyncRepRequested() \ + (g_instance.attr.attr_storage.max_wal_senders > 0 && \ + u_sess->attr.attr_storage.guc_synchronous_commit > SYNCHRONOUS_COMMIT_LOCAL_FLUSH) /* SyncRepWaitMode */ #define SYNC_REP_NO_WAIT -1