From cdd577685758b9a6719f70a33bd2b7b11b9ce9f3 Mon Sep 17 00:00:00 2001 From: xue_meng_en <1836611252@qq.com> Date: Wed, 25 Nov 2020 20:51:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8C=E6=AD=A5=E6=97=B6=E9=97=B4=E9=97=B4=E9=9A=94?= =?UTF-8?q?=E7=94=B1=E7=94=A8=E6=88=B7=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/gs_guc/cluster_guc.conf | 1 + src/common/backend/utils/misc/guc.cpp | 16 ++++++++++++++++ .../backend/utils/misc/postgresql.conf.sample | 1 + .../process/threadpool/knl_thread.cpp | 2 +- .../storage/replication/walreceiver.cpp | 2 ++ .../storage/replication/walsender.cpp | 2 +- .../knl/knl_guc/knl_instance_attr_common.h | 1 + 7 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/bin/gs_guc/cluster_guc.conf b/src/bin/gs_guc/cluster_guc.conf index baf9e9a7c..2e0e98c80 100644 --- a/src/bin/gs_guc/cluster_guc.conf +++ b/src/bin/gs_guc/cluster_guc.conf @@ -548,6 +548,7 @@ parallel_setup_cost|real|0,1.79769e+308|NULL|NULL| force_parallel_mode|enum|off,on,regress|NULL|NULL| parallel_leader_participation|bool|0,0|NULL|NULL| catchup2normal_wait_time|int|-1,10000|ms|The maximal allowed duration for waiting from catchup to normal state.| +config_sync_interval|int|0,2147483647|ms|The value is the synchronization interval of the configuration file in milliseconds.| [gtm] nodename|string|0,0|NULL|Name of this GTM/GTM-Standby.| port|int|1,65535|NULL|Listen Port of GTM or GTM standby server.| diff --git a/src/common/backend/utils/misc/guc.cpp b/src/common/backend/utils/misc/guc.cpp index 4d392b439..b398113ce 100644 --- a/src/common/backend/utils/misc/guc.cpp +++ b/src/common/backend/utils/misc/guc.cpp @@ -4695,6 +4695,22 @@ void set_qunit_case_number_hook(int newval, void* extra) static void init_configure_names_int() { struct config_int local_configure_names_int[] = { + { + { + "config_sync_interval", + PGC_POSTMASTER, + WAL_SETTINGS, + gettext_noop("The synchronization time interval for the config file."), + NULL + }, + &g_instance.attr.attr_common.config_sync_interval, + 3600000, + 0, + INT_MAX, + NULL, + NULL, + NULL + }, { { "max_active_global_temporary_table", diff --git a/src/common/backend/utils/misc/postgresql.conf.sample b/src/common/backend/utils/misc/postgresql.conf.sample index 516eb4b4f..7530e33b1 100755 --- a/src/common/backend/utils/misc/postgresql.conf.sample +++ b/src/common/backend/utils/misc/postgresql.conf.sample @@ -316,6 +316,7 @@ hot_standby = on # "on" allows queries during recovery #wal_receiver_connect_retries = 1 # max retries that receiver connect master #wal_receiver_buffer_size = 64MB # wal receiver buffer size #enable_xlog_prune = on # xlog keep for all standbys even through they are not connecting and donnot created replslot. +#config_sync_interval = 3600000 # The parameter is the synchronization interval of the configuration file in milliseconds. The default value is 1 hour = 3600000 milliseconds. 0 indicates that the configuration file is not synchronized. #------------------------------------------------------------------------------ # QUERY TUNING diff --git a/src/gausskernel/process/threadpool/knl_thread.cpp b/src/gausskernel/process/threadpool/knl_thread.cpp index 55a618820..b9f92c310 100755 --- a/src/gausskernel/process/threadpool/knl_thread.cpp +++ b/src/gausskernel/process/threadpool/knl_thread.cpp @@ -1106,7 +1106,7 @@ static void knl_t_walreceiver_init(knl_t_walreceiver_context* walreceiver_cxt) rc = memset_s(walreceiver_cxt->gucconf_lock_file, MAXPGPATH, 0, MAXPGPATH); securec_check(rc, "\0", "\0"); walreceiver_cxt->reserve_item = {0}; - walreceiver_cxt->check_file_timeout = 60 * 60 * 1000; + walreceiver_cxt->check_file_timeout = g_instance.attr.attr_common.config_sync_interval; walreceiver_cxt->walRcvCtlBlock = NULL; walreceiver_cxt->reply_message = (StandbyReplyMessage*)palloc0(sizeof(StandbyReplyMessage)); walreceiver_cxt->feedback_message = (StandbyHSFeedbackMessage*)palloc0(sizeof(StandbyHSFeedbackMessage)); diff --git a/src/gausskernel/storage/replication/walreceiver.cpp b/src/gausskernel/storage/replication/walreceiver.cpp index 84c49f71c..30108eba2 100755 --- a/src/gausskernel/storage/replication/walreceiver.cpp +++ b/src/gausskernel/storage/replication/walreceiver.cpp @@ -2551,6 +2551,8 @@ static bool ProcessConfigFileMessage(char* buf, Size len) */ static void firstSynchStandbyFile(void) { + if (g_instance.attr.attr_common.config_sync_interval <= 0) + return; char bufTime[sizeof(ConfigModifyTimeMessage) + 1]; errno_t errorno = EOK; diff --git a/src/gausskernel/storage/replication/walsender.cpp b/src/gausskernel/storage/replication/walsender.cpp index d325c7f56..ce511b52e 100755 --- a/src/gausskernel/storage/replication/walsender.cpp +++ b/src/gausskernel/storage/replication/walsender.cpp @@ -2907,7 +2907,7 @@ static int WalSndLoop(WalSndSendDataCallback send_data) } } - if (sync_config_needed) { + if (sync_config_needed && g_instance.attr.attr_common.config_sync_interval > 0) { if (t_thrd.walsender_cxt.walsender_shutdown_requested) { if (!AM_WAL_DB_SENDER && !SendConfigFile(t_thrd.walsender_cxt.gucconf_file)) ereport(LOG, (errmsg("failed to send config to the peer when walsender shutdown."))); diff --git a/src/include/knl/knl_guc/knl_instance_attr_common.h b/src/include/knl/knl_guc/knl_instance_attr_common.h index a4b64a2aa..b1d031116 100755 --- a/src/include/knl/knl_guc/knl_instance_attr_common.h +++ b/src/include/knl/knl_guc/knl_instance_attr_common.h @@ -76,6 +76,7 @@ typedef struct knl_instance_attr_common { bool enable_alarm; char* Alarm_component; char* MOTConfigFileName; + int config_sync_interval; } knl_instance_attr_common; #endif /* SRC_INCLUDE_KNL_KNL_INSTANCE_ATTR_COMMON_H_ */