repmgr: fix "standby register --wait-sync" when no timeout provided

The default value for "wait_register_sync_seconds" was zero, which is treated
as disabling --wait-sync altogether. Default value now set to -1, which is taken
to mean no timeout value supplied.
This commit is contained in:
Ian Barwick
2018-07-04 17:22:04 +09:00
parent a194cf56b3
commit 37311e15a3
4 changed files with 30 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
4.1.0 2018-??-?? 4.1.0 2018-??-??
repmgr: add "--missing-slots" check to "repmgr node check" (Ian) repmgr: add "--missing-slots" check to "repmgr node check" (Ian)
repmgr: improve command line error handling; GitHub #464 (Ian) repmgr: improve command line error handling; GitHub #464 (Ian)
repmgr: fix "standby register --wait-sync" when no timeout provided (Ian)
repmgrd: create a PID file by default; GitHub #457 (Ian) repmgrd: create a PID file by default; GitHub #457 (Ian)
repmgrd: daemonize process by default; GitHub #458 (Ian) repmgrd: daemonize process by default; GitHub #458 (Ian)

View File

@@ -67,6 +67,23 @@
</itemizedlist> </itemizedlist>
</para> </para>
</sect2> </sect2>
<sect2>
<title>Bug fixes</title>
<para>
<itemizedlist>
<listitem>
<para>
<application>repmgr</application>: fix <command><link linkend="repmgr-standby-register">repmgr standby register--wait-sync </link></command>
when no timeout provided.
</para>
</listitem>
</itemizedlist>
</para>
</sect2>
</sect1> </sect1>
<sect1 id="release-4.0.6"> <sect1 id="release-4.0.6">

View File

@@ -1708,11 +1708,15 @@ do_standby_register(void)
termPQExpBuffer(&details); termPQExpBuffer(&details);
/* if --wait-sync option set, wait for the records to synchronise */ /*
* if --wait-sync option set, wait for the records to synchronise
* (unless 0 seconds provided, which disables it, which is the same as
* not providing the option)
*/
if (PQstatus(conn) == CONNECTION_OK && if (PQstatus(conn) == CONNECTION_OK &&
runtime_options.wait_register_sync == true && runtime_options.wait_register_sync == true &&
runtime_options.wait_register_sync_seconds > 0) runtime_options.wait_register_sync_seconds != 0)
{ {
bool sync_ok = false; bool sync_ok = false;
int timer = 0; int timer = 0;
@@ -1736,7 +1740,11 @@ do_standby_register(void)
{ {
bool records_match = true; bool records_match = true;
if (runtime_options.wait_register_sync_seconds && runtime_options.wait_register_sync_seconds == timer) /*
* If timeout set to a positive value, check if we've reached it and
* exit the loop
*/
if (runtime_options.wait_register_sync_seconds > 0 && runtime_options.wait_register_sync_seconds == timer)
break; break;
node_record_status = get_node_record(conn, node_record_status = get_node_record(conn,

View File

@@ -153,7 +153,7 @@ typedef struct
/* "standby clone"/"standby follow" options */ \ /* "standby clone"/"standby follow" options */ \
NO_UPSTREAM_NODE, \ NO_UPSTREAM_NODE, \
/* "standby register" options */ \ /* "standby register" options */ \
false, 0, DEFAULT_WAIT_START, \ false, -1, DEFAULT_WAIT_START, \
/* "standby switchover" options */ \ /* "standby switchover" options */ \
false, false, "", false, \ false, false, "", false, \
/* "node status" options */ \ /* "node status" options */ \