From ae2eb713b5c6f55556c8e38073747a0176f32c17 Mon Sep 17 00:00:00 2001 From: zhengxue Date: Fri, 22 Jan 2021 16:09:39 +0800 Subject: [PATCH] fix bug about default of lockwait_timeout by gs_guc fix bug about default of lockwait_timeout by gs_guc --- src/bin/gs_guc/pg_guc.cpp | 10 +++-- src/test/regress/input/gs_guc_reload.source | 9 +++++ src/test/regress/output/gs_guc_reload.source | 39 ++++++++++++++++++++ src/test/regress/parallel_schedule0 | 1 + 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 src/test/regress/input/gs_guc_reload.source create mode 100644 src/test/regress/output/gs_guc_reload.source diff --git a/src/bin/gs_guc/pg_guc.cpp b/src/bin/gs_guc/pg_guc.cpp index 54567e772..c5bb72a99 100644 --- a/src/bin/gs_guc/pg_guc.cpp +++ b/src/bin/gs_guc/pg_guc.cpp @@ -1129,16 +1129,18 @@ do_gucset(const char *action_type, const char *data_dir) to_generatenewline(optconf_line, newconf_line, config_param[i], config_value[i], optvalue_len); } else { /* - * if parameter as value is NULL; consider it as UNSET (i.e to default value) - * which means comment the configuration parameter + * if parameter value is NULL, not consider it as UNSET, + * which means maintain the configuration parameter, and + * there will be prompts telling the user to assign a value. */ //line is commented if (isOptLineCommented(optconf_line)) { rc = strncpy_s(newconf_line, MAX_PARAM_LEN*2, optconf_line, (size_t)Min(line_len, MAX_PARAM_LEN*2 - 1)); securec_check_c(rc, "\0", "\0"); } else { - nRet = snprintf_s(newconf_line, MAX_PARAM_LEN*2, MAX_PARAM_LEN*2 - 1, "#%s", optconf_line); - securec_check_ss_c(nRet, "\0", "\0"); + write_stderr( _("ERROR: %s parameters value is expected\n"), config_param[i]); + return FAILURE; + } } updateoradd = UPDATE_PARAMETER; diff --git a/src/test/regress/input/gs_guc_reload.source b/src/test/regress/input/gs_guc_reload.source new file mode 100644 index 000000000..e98b5094f --- /dev/null +++ b/src/test/regress/input/gs_guc_reload.source @@ -0,0 +1,9 @@ +-----gs_guc_reload(GUC) set default value of lockwait_timeout by gs_guc reload +--set new value +\! @abs_bindir@/gs_guc reload -D @abs_srcdir@/tmp_check/datanode1/ -c "lockwait_timeout=1s" +\! sleep 10s +show lockwait_timeout; +--no assign value +\! @abs_bindir@/gs_guc reload -D @abs_srcdir@/tmp_check/datanode1/ -c "lockwait_timeout" +\! sleep 10s +show lockwait_timeout; diff --git a/src/test/regress/output/gs_guc_reload.source b/src/test/regress/output/gs_guc_reload.source new file mode 100644 index 000000000..5e2c13b5a --- /dev/null +++ b/src/test/regress/output/gs_guc_reload.source @@ -0,0 +1,39 @@ +-----gs_guc_reload(GUC) set default value of lockwait_timeout by gs_guc reload +--set new value +\! @abs_bindir@/gs_guc reload -D @abs_srcdir@/tmp_check/datanode1/ -c "lockwait_timeout=1s" +The gs_guc run with the following arguments: [@abs_bindir@/gs_guc -D @abs_srcdir@/tmp_check/datanode1/ -c lockwait_timeout=1s reload ]. +realpath(@abs_bindir@/..//bin/cluster_static_config) failed : No such file or directory! +expected instance path: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] +gs_guc reload: lockwait_timeout=1s: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] +server signaled + +Total instances: 1. Failed instances: 0. +Success to perform gs_guc! + +\! sleep 10s +show lockwait_timeout; + lockwait_timeout +------------------ + 1s +(1 row) + +--no assign value +\! @abs_bindir@/gs_guc reload -D @abs_srcdir@/tmp_check/datanode1/ -c "lockwait_timeout" +The gs_guc run with the following arguments: [@abs_bindir@/gs_guc -D @abs_srcdir@/tmp_check/datanode1/ -c lockwait_timeout reload ]. +realpath(@abs_bindir@/..//bin/cluster_static_config) failed : No such file or directory! +expected instance path: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] +ERROR: lockwait_timeout parameters value is expected + +Total instances: 1. Failed instances: 1. +Failed instance information: +--?.* + +Failure to perform gs_guc! + +\! sleep 10s +show lockwait_timeout; + lockwait_timeout +------------------ + 1s +(1 row) + diff --git a/src/test/regress/parallel_schedule0 b/src/test/regress/parallel_schedule0 index 7f39242ab..711252112 100644 --- a/src/test/regress/parallel_schedule0 +++ b/src/test/regress/parallel_schedule0 @@ -748,3 +748,4 @@ test: rule_test # gs_guc test # ---------- #test: gs_guc +test: gs_guc_reload