fix issue 通过SET命令动态修改synchronous_commit设置不生效

This commit is contained in:
arcoalien@qq.com 2022-01-26 11:01:37 +08:00
parent 3fbed4ad61
commit ac8363f2bc
5 changed files with 6 additions and 11 deletions

View File

@ -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;
/*

View File

@ -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:
*

View File

@ -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 "

View File

@ -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
* ----------------

View File

@ -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