mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
doc: add note about switchover and exclusive backups
Also rename server_not_in_exclusive_backup_mode() to avoid double negatives. GitHub #476.
This commit is contained in:
2
HISTORY
2
HISTORY
@@ -18,6 +18,8 @@
|
|||||||
GitHub #451 (Ian)
|
GitHub #451 (Ian)
|
||||||
repmgr: fix "primary_slot_name" when using "standby clone" with --recovery-conf-only;
|
repmgr: fix "primary_slot_name" when using "standby clone" with --recovery-conf-only;
|
||||||
GitHub #474 (Ian)
|
GitHub #474 (Ian)
|
||||||
|
repmgr: don't perform a switchover if an exclusive backup is running;
|
||||||
|
GitHub #476 (Martín)
|
||||||
repmgr: enable "witness unregister" to be run on any node; GitHub #472 (Ian)
|
repmgr: enable "witness unregister" to be run on any node; GitHub #472 (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)
|
||||||
|
|||||||
57
dbutils.c
57
dbutils.c
@@ -1601,6 +1601,39 @@ repmgrd_get_local_node_id(PGconn *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function that checks if the primary is in exclusive backup mode.
|
||||||
|
* We'll use this when executing an action can conflict with an exclusive
|
||||||
|
* backup.
|
||||||
|
*/
|
||||||
|
BackupState
|
||||||
|
server_in_exclusive_backup_mode(PGconn *conn)
|
||||||
|
{
|
||||||
|
BackupState backup_state = BACKUP_STATE_UNKNOWN;
|
||||||
|
PGresult *res = PQexec(conn, "SELECT pg_catalog.pg_is_in_backup()");
|
||||||
|
|
||||||
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
|
{
|
||||||
|
log_error(_("unable to retrieve information regarding backup mode of node"));
|
||||||
|
log_detail("%s", PQerrorMessage(conn));
|
||||||
|
PQclear(res);
|
||||||
|
return BACKUP_STATE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (atobool(PQgetvalue(res, 0, 0)) == true)
|
||||||
|
{
|
||||||
|
backup_state = BACKUP_STATE_IN_BACKUP;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backup_state = BACKUP_STATE_NO_BACKUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
PQclear(res);
|
||||||
|
|
||||||
|
return backup_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ================ */
|
/* ================ */
|
||||||
/* result functions */
|
/* result functions */
|
||||||
@@ -3953,31 +3986,7 @@ connection_ping(PGconn *conn)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Function that checks if the primary is in exclusive backup mode.
|
|
||||||
* We'll use this when executing an action can conflict with an exclusive
|
|
||||||
* backup.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
server_not_in_exclusive_backup_mode(PGconn *conn)
|
|
||||||
{
|
|
||||||
PGresult *res = PQexec(conn, "SELECT pg_is_in_backup()");
|
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
|
||||||
{
|
|
||||||
log_error(_("unable to retrieve information regarding backup mode of node"));
|
|
||||||
log_detail("%s", PQerrorMessage(conn));
|
|
||||||
PQclear(res);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(PQgetvalue(res, 0, 0), "t") == 0)
|
|
||||||
{
|
|
||||||
log_warning(_("node is in exclusive backup mode"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ==================== */
|
/* ==================== */
|
||||||
/* monitoring functions */
|
/* monitoring functions */
|
||||||
|
|||||||
10
dbutils.h
10
dbutils.h
@@ -96,6 +96,14 @@ typedef enum
|
|||||||
SLOT_ACTIVE
|
SLOT_ACTIVE
|
||||||
} ReplSlotStatus;
|
} ReplSlotStatus;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
BACKUP_STATE_UNKNOWN = -1,
|
||||||
|
BACKUP_STATE_IN_BACKUP,
|
||||||
|
BACKUP_STATE_NO_BACKUP
|
||||||
|
} BackupState;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Struct to store node information
|
* Struct to store node information
|
||||||
*/
|
*/
|
||||||
@@ -390,6 +398,7 @@ int get_ready_archive_files(PGconn *conn, const char *data_directory);
|
|||||||
bool identify_system(PGconn *repl_conn, t_system_identification *identification);
|
bool identify_system(PGconn *repl_conn, t_system_identification *identification);
|
||||||
bool repmgrd_set_local_node_id(PGconn *conn, int local_node_id);
|
bool repmgrd_set_local_node_id(PGconn *conn, int local_node_id);
|
||||||
int repmgrd_get_local_node_id(PGconn *conn);
|
int repmgrd_get_local_node_id(PGconn *conn);
|
||||||
|
BackupState server_in_exclusive_backup_mode(PGconn *conn);
|
||||||
|
|
||||||
/* extension functions */
|
/* extension functions */
|
||||||
ExtensionStatus get_repmgr_extension_status(PGconn *conn);
|
ExtensionStatus get_repmgr_extension_status(PGconn *conn);
|
||||||
@@ -467,7 +476,6 @@ int wait_connection_availability(PGconn *conn, long long timeout);
|
|||||||
bool is_server_available(const char *conninfo);
|
bool is_server_available(const char *conninfo);
|
||||||
bool is_server_available_params(t_conninfo_param_list *param_list);
|
bool is_server_available_params(t_conninfo_param_list *param_list);
|
||||||
void connection_ping(PGconn *conn);
|
void connection_ping(PGconn *conn);
|
||||||
bool server_not_in_exclusive_backup_mode(PGconn *conn);
|
|
||||||
|
|
||||||
/* monitoring functions */
|
/* monitoring functions */
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -106,6 +106,14 @@
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<command><link linkend="repmgr-standby switchover">repmgr standby switchover</link></command>
|
||||||
|
will refuse to run if an exclusive backup is taking place on the current primary.
|
||||||
|
(GitHub #476).
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</para>
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|||||||
@@ -46,6 +46,9 @@
|
|||||||
<application>repmgrd</application> should not be active on any nodes while a switchover is being
|
<application>repmgrd</application> should not be active on any nodes while a switchover is being
|
||||||
executed. This restriction may be lifted in a later version.
|
executed. This restriction may be lifted in a later version.
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
|
&repmgr; will not perform the switchover if an exclusive backup is running on the current primary.
|
||||||
|
</para>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
As mentioned in the previous section, success of the switchover operation depends on
|
As mentioned in the previous section, success of the switchover operation depends on
|
||||||
&repmgr; being able to shut down the current primary server quickly and cleanly.
|
&repmgr; being able to shut down the current primary server quickly and cleanly.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@@ -121,15 +121,21 @@
|
|||||||
</simpara>
|
</simpara>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Check that access from applications is minimalized or preferably blocked
|
Check that access from applications is minimalized or preferably blocked
|
||||||
completely, so applications are not unexpectedly interrupted.
|
completely, so applications are not unexpectedly interrupted.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<note>
|
||||||
|
<para>
|
||||||
|
If an exclusive backup is running on the current primary, &repmgr; will not perform the
|
||||||
|
switchover.
|
||||||
|
</para>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Check there is no significant replication lag on standbys attached to the
|
Check there is no significant replication lag on standbys attached to the
|
||||||
current primary.
|
current primary.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@@ -147,6 +153,7 @@
|
|||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Finally, consider executing <command>repmgr standby switchover</command> with the
|
Finally, consider executing <command>repmgr standby switchover</command> with the
|
||||||
<literal>--dry-run</literal> option; this will perform any necessary checks and inform you about
|
<literal>--dry-run</literal> option; this will perform any necessary checks and inform you about
|
||||||
|
|||||||
@@ -2919,11 +2919,12 @@ do_standby_switchover(void)
|
|||||||
* If the DBA wants to do the switchover anyway, he should first stop the
|
* If the DBA wants to do the switchover anyway, he should first stop the
|
||||||
* backup that's running.
|
* backup that's running.
|
||||||
*/
|
*/
|
||||||
if (!server_not_in_exclusive_backup_mode(remote_conn))
|
if (server_in_exclusive_backup_mode(remote_conn) != BACKUP_STATE_NO_BACKUP)
|
||||||
{
|
{
|
||||||
log_error(_("can't perform a switchover while primary server is in exclusive backup mode"));
|
log_error(_("unable to perform a switchover while primary server is in exclusive backup mode"));
|
||||||
log_hint(_("stop backup before attempting the switchover"));
|
log_hint(_("stop backup before attempting the switchover"));
|
||||||
|
|
||||||
|
PQfinish(local_conn);
|
||||||
PQfinish(remote_conn);
|
PQfinish(remote_conn);
|
||||||
|
|
||||||
exit(ERR_SWITCHOVER_FAIL);
|
exit(ERR_SWITCHOVER_FAIL);
|
||||||
|
|||||||
Reference in New Issue
Block a user