From e2cb7cb626e0241c9a0a3a89e3532cdfa4497be2 Mon Sep 17 00:00:00 2001 From: wuyuechuan Date: Wed, 2 Sep 2020 16:19:49 +0800 Subject: [PATCH] gs_basebackup occasionally failed when compress=9 --- src/bin/gs_guc/cluster_guc.conf | 1 + src/bin/pg_basebackup/pg_basebackup.cpp | 2 +- src/common/backend/utils/misc/guc.cpp | 20 ++++++++++++++++++- .../storage/replication/walsender.cpp | 2 +- .../knl/knl_guc/knl_session_attr_storage.h | 1 + 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/bin/gs_guc/cluster_guc.conf b/src/bin/gs_guc/cluster_guc.conf index 9e7af9293..00837318f 100644 --- a/src/bin/gs_guc/cluster_guc.conf +++ b/src/bin/gs_guc/cluster_guc.conf @@ -461,6 +461,7 @@ wal_sender_timeout|int|0,2147483647|ms|If the host larger data rebuild operation wal_sync_method|enum|fsync,fsync_writethrough,fdatasync,open_sync,open_datasync|NULL|If fsync set to off, this parameter setting does not make sense, because all data updates are not forced to be written to disk.| wal_writer_delay|int|1,10000|ms|If the time is too long will cause WAL buffers memory shortage, time is too short will cause WAL continue to write, increase disk I/O burden.| walsender_max_send_size|int|8,2147483647|kB|NULL| +basebackup_timeout|int|0,2147483647|s|NULL| wal_compression|bool|0,0|NULL|NULL| work_mem|int|64,2147483647|kB|For complex queries, it may run several concurrent sort or hash operation, each of which can use the amount of memory that this parameter is declared using the temporary file is insufficient. Also, several running sessions could be sorted the same time. Therefore, the total memory usage may be work_mem several times.| xloginsert_locks|int|1,1000|NULL|NULL| diff --git a/src/bin/pg_basebackup/pg_basebackup.cpp b/src/bin/pg_basebackup/pg_basebackup.cpp index 06a67edd5..4dea6c8d5 100644 --- a/src/bin/pg_basebackup/pg_basebackup.cpp +++ b/src/bin/pg_basebackup/pg_basebackup.cpp @@ -1972,7 +1972,7 @@ static int GsBaseBackup(int argc, char** argv) case 'Z': check_env_value_c(optarg); compresslevel = atoi(optarg); - if (compresslevel <= 0 || compresslevel > 9) { + if (compresslevel < 0 || compresslevel > 9) { fprintf(stderr, _("%s: invalid compression level \"%s\"\n"), progname, optarg); exit(1); } diff --git a/src/common/backend/utils/misc/guc.cpp b/src/common/backend/utils/misc/guc.cpp index b31c45532..2a6916815 100644 --- a/src/common/backend/utils/misc/guc.cpp +++ b/src/common/backend/utils/misc/guc.cpp @@ -401,7 +401,8 @@ const char* sync_guc_variable_namelist[] = {"work_mem", "enable_incremental_catchup", "wait_dummy_time", "max_recursive_times", - "sql_use_spacelimit"}; + "sql_use_spacelimit", + "basebackup_timeout"}; static void set_config_sourcefile(const char* name, char* sourcefile, int sourceline); static bool call_bool_check_hook(struct config_bool* conf, bool* newval, void** extra, GucSource source, int elevel); @@ -5004,6 +5005,23 @@ static void init_configure_names_int() NULL, NULL }, + { + { + "basebackup_timeout", + PGC_USERSET, + WAL_SETTINGS, + gettext_noop("Sets the timeout in seconds for a reponse from gs_basebackup."), + NULL, + GUC_UNIT_S + }, + &u_sess->attr.attr_storage.basebackup_timeout, + 60 * 10, + 0, + INT_MAX, + NULL, + NULL, + NULL + }, { { "wal_receiver_connect_timeout", diff --git a/src/gausskernel/storage/replication/walsender.cpp b/src/gausskernel/storage/replication/walsender.cpp index 45e1afc50..04cef91f8 100755 --- a/src/gausskernel/storage/replication/walsender.cpp +++ b/src/gausskernel/storage/replication/walsender.cpp @@ -1755,7 +1755,7 @@ static bool HandleWalReplicationCommand(const char* cmd_string) /* Send CommandComplete and ReadyForQuery messages */ EndCommand_noblock("SELECT", DestRemote); - ReadyForQuery_noblock(DestRemote, u_sess->attr.attr_storage.wal_sender_timeout); + ReadyForQuery_noblock(DestRemote, u_sess->attr.attr_storage.basebackup_timeout * MILLISECONDS_PER_SECONDS); /* ReadyForQuery did pq_flush for us */ /* Audit database recovery */ pgaudit_system_recovery_ok(); 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 25910c071..845a50844 100755 --- a/src/include/knl/knl_guc/knl_session_attr_storage.h +++ b/src/include/knl/knl_guc/knl_session_attr_storage.h @@ -83,6 +83,7 @@ typedef struct knl_session_attr_storage { int wal_receiver_timeout; int wal_receiver_connect_timeout; int wal_receiver_connect_retries; + int basebackup_timeout; int max_loaded_cudesc; int num_temp_buffers; int psort_work_mem;