支持不同步配置文件

This commit is contained in:
xue_meng_en 2020-12-17 12:30:09 +08:00
parent 088fefe2a8
commit 31b29d863f
8 changed files with 46 additions and 25 deletions

View File

@ -548,7 +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.|
sync_config_strategy|enum|all_node,only_sync_node,none_node|NULL|NULL|
[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.|

View File

@ -962,6 +962,13 @@ static const struct config_enum_entry unique_sql_track_option[] = {
extern struct config_enum_entry wal_level_options[];
extern struct config_enum_entry sync_method_options[];
static const struct config_enum_entry sync_config_strategy_options[] = {
{"all_node", ALL_NODE, true},
{"only_sync_node", ONLY_SYNC_NODE, true},
{"none_node", NONE_NODE, true},
{NULL, 0, false}
};
/*
* GUC option variables that are exported from this module
*/
@ -4696,22 +4703,6 @@ 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",
@ -11618,6 +11609,21 @@ static void init_configure_names_string()
static void init_configure_names_enum()
{
struct config_enum local_configure_names_enum[] = {
{
{
"sync_config_strategy",
PGC_POSTMASTER,
WAL_SETTINGS,
gettext_noop("Synchronization strategy for configuration files between host and standby."),
NULL
},
&g_instance.attr.attr_common.sync_config_strategy,
ALL_NODE,
sync_config_strategy_options,
NULL,
NULL,
NULL
},
{
{
"backslash_quote",

View File

@ -250,6 +250,12 @@ incremental_checkpoint_timeout = 60s # range 1s-1h
# The value is best configured less than half of
# the wal_receiver_timeout and wal_sender_timeout.
# - Synchronous configuration file -
#sync_config_strategy = all_node # Configuration file synchronization strategy.
# ALL_NODE : The standby nodes are allowed to send synchronous requests, and the host are allowed to actively send configuration files to all standby nodes.
# ONLY_SYNC_NODE : The standby nodes are allowed to send synchronization requests, and the host only actively sends configuration files to the standby.
# NONE_NODE : No standby requests are allowed, and the host is not allowed to actively send configuration files to the standby.
# - Sending Server(s) -
# Set these on the master and on any standby that will send replication data.

View File

@ -1112,7 +1112,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 = g_instance.attr.attr_common.config_sync_interval;
walreceiver_cxt->check_file_timeout = 60 * 60 * 1000;
walreceiver_cxt->walRcvCtlBlock = NULL;
walreceiver_cxt->reply_message = (StandbyReplyMessage*)palloc0(sizeof(StandbyReplyMessage));
walreceiver_cxt->feedback_message = (StandbyHSFeedbackMessage*)palloc0(sizeof(StandbyHSFeedbackMessage));

View File

@ -114,7 +114,7 @@ const char* g_reserve_param[RESERVE_SIZE] = {"application_name",
"synchronous_standby_names",
"local_bind_address",
"archive_dest",
NULL,
"sync_config_strategy",
NULL,
NULL,
NULL,
@ -494,7 +494,8 @@ void WalReceiverMain(void)
* Note: If switchover in one hour, and there is no parameter is reloaded,
* the parameters set by client will be disabled. So we should do this.
*/
firstSynchStandbyFile();
if (g_instance.attr.attr_common.sync_config_strategy != NONE_NODE)
firstSynchStandbyFile();
set_disable_conn_mode();
knl_g_set_is_local_redo_finish(false);
@ -581,7 +582,8 @@ void WalReceiverMain(void)
XLogWalRcvSendReply(requestReply, requestReply);
XLogWalRcvSendHSFeedback();
}
ConfigFileTimer();
if (g_instance.attr.attr_common.sync_config_strategy != NONE_NODE)
ConfigFileTimer();
}
}
@ -2551,8 +2553,6 @@ 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;

View File

@ -2906,7 +2906,10 @@ static int WalSndLoop(WalSndSendDataCallback send_data)
}
}
if (sync_config_needed && g_instance.attr.attr_common.config_sync_interval > 0) {
if (sync_config_needed &&
(g_instance.attr.attr_common.sync_config_strategy == ALL_NODE ||
(g_instance.attr.attr_common.sync_config_strategy == ONLY_SYNC_NODE &&
t_thrd.walsender_cxt.MyWalSnd->sync_standby_priority > 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.")));

View File

@ -76,7 +76,7 @@ typedef struct knl_instance_attr_common {
bool enable_alarm;
char* Alarm_component;
char* MOTConfigFileName;
int config_sync_interval;
int sync_config_strategy;
} knl_instance_attr_common;
#endif /* SRC_INCLUDE_KNL_KNL_INSTANCE_ATTR_COMMON_H_ */

View File

@ -98,5 +98,11 @@ typedef union syncrep_scanner_YYSTYPE {
extern int syncrep_scanner_yylex(syncrep_scanner_YYSTYPE* lvalp, YYLTYPE* llocp, syncrep_scanner_yyscan_t yyscanner);
extern void syncrep_scanner_yyerror(const char* message, syncrep_scanner_yyscan_t yyscanner);
typedef enum {
ALL_NODE,
ONLY_SYNC_NODE,
NONE_NODE
} Sync_Config_Strategy;
#endif /* _SYNCREP_H */