diff --git a/doc/event-notifications.sgml b/doc/event-notifications.sgml index faf11f67..9f670c68 100644 --- a/doc/event-notifications.sgml +++ b/doc/event-notifications.sgml @@ -144,6 +144,9 @@ standby_register + + standby_register_sync + standby_unregister diff --git a/doc/repmgr-standby-register.sgml b/doc/repmgr-standby-register.sgml index 5288f7b0..96a3649a 100644 --- a/doc/repmgr-standby-register.sgml +++ b/doc/repmgr-standby-register.sgml @@ -57,16 +57,16 @@ Waiting for the registration to propagate to the standby - Depending on your environment and workload, it may take some time for - the standby's node record to propagate from the primary to the standby. Some - actions (such as starting repmgrd) require that the standby's node record + Depending on your environment and workload, it may take some time for the standby's node record + to propagate from the primary to the standby. Some actions (such as starting + repmgrd) require that the standby's node record is present and up-to-date to function correctly. - By providing the option --wait-sync to the + By providing the option to the repmgr standby register command, &repmgr; will wait until the record is synchronised before exiting. An optional timeout (in - seconds) can be added to this option (e.g. --wait-sync=60). + seconds) can be added to this option (e.g. ). @@ -75,20 +75,20 @@ Under some circumstances you may wish to register a standby which is not yet running; this can be the case when using provisioning tools to create - a complex replication cluster. In this case, by using the -F/--force + a complex replication cluster. In this case, by using the option and providing the connection parameters to the primary server, the standby can be registered. Similarly, with cascading replication it may be necessary to register a standby whose upstream node has not yet been registered - in this case, - using -F/--force will result in the creation of an inactive placeholder + using will result in the creation of an inactive placeholder record for the upstream node, which will however later need to be registered - with the -F/--force option too. + with the option too. When used with repmgr standby register, care should be taken that use of the - -F/--force option does not result in an incorrectly configured cluster. + option does not result in an incorrectly configured cluster. @@ -96,8 +96,15 @@ Event notifications A standby_register event notification - will be generated. + will be generated immediately after the node record is updated on the primary. + + + If the option is provided, a standby_register_sync + event notification will be generated immediately after the node record has synchronised to the + standby. + + diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index de19735b..3dae11dc 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -763,6 +763,7 @@ check_barman_config(void) * * Event(s): * - standby_register + * - standby_register_sync */ /* XXX check --upstream-node-id works when re-registering */ @@ -1156,13 +1157,11 @@ do_standby_register(void) exit(ERR_BAD_CONFIG); } - appendPQExpBuffer( - &details, + appendPQExpBuffer(&details, "standby registration succeeded"); if (runtime_options.force == true) - appendPQExpBuffer( - &details, + appendPQExpBuffer(&details, " (-F/--force option was used)"); @@ -1251,16 +1250,41 @@ do_standby_register(void) timer++; } + /* Log the event */ + initPQExpBuffer(&details); + if (sync_ok == false) { - log_error(_("node record was not synchronised after %i seconds"), - runtime_options.wait_register_sync_seconds); + appendPQExpBuffer(&details, + _("node record was not synchronised after %i seconds"), + runtime_options.wait_register_sync_seconds); + } + else + { + appendPQExpBuffer(&details, + _("node record synchronised after %i seconds"), + timer); + } + + create_event_notification(primary_conn, + &config_file_options, + config_file_options.node_id, + "standby_register_sync", + sync_ok, + details.data); + + if (sync_ok == false) + { + log_error("%s", details.data); + termPQExpBuffer(&details); PQfinish(primary_conn); PQfinish(conn); exit(ERR_REGISTRATION_SYNC); } log_info(_("node record on standby synchronised from primary")); + log_detail("%s", details.data); + termPQExpBuffer(&details); }