mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 00:26:30 +00:00
repmgr standby switchover: add sanity check for pg_rewind useability
pg_rewind will only be executed on a demoted primary if explictly requested, to prevent transactions on the primary, which were never replicated, from being automatically overwritten. If --force-rewind is provided, we'll need to check pg_rewind is actually useable before we need to use it.
This commit is contained in:
58
dbutils.c
58
dbutils.c
@@ -11,9 +11,9 @@
|
||||
|
||||
#include "repmgr.h"
|
||||
#include "dbutils.h"
|
||||
#include "controldata.h"
|
||||
|
||||
#include "catalog/pg_control.h"
|
||||
|
||||
#include "dirutil.h"
|
||||
|
||||
/* mainly for use by repmgrd */
|
||||
int server_version_num = UNKNOWN_SERVER_VERSION_NUM;
|
||||
@@ -1239,6 +1239,60 @@ get_replication_info(PGconn *conn, ReplInfo *replication_info)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
can_use_pg_rewind(PGconn *conn, const char *data_directory, PQExpBufferData *reason)
|
||||
{
|
||||
bool can_use = true;
|
||||
|
||||
if (guc_set(conn, "full_page_writes", "=", "off"))
|
||||
{
|
||||
if (can_use == false)
|
||||
appendPQExpBuffer(reason, "; ");
|
||||
|
||||
appendPQExpBuffer(
|
||||
reason,
|
||||
_("\"full_page_writes\" must be set to \"on\""));
|
||||
|
||||
can_use = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* "wal_log_hints" off - are data checksums available?
|
||||
* Note: we're checking the local pg_control file here as the value will
|
||||
* be the same throughout the cluster and saves a round-trip to the
|
||||
* demotion candidate.
|
||||
*/
|
||||
if (guc_set(conn, "wal_log_hints", "=", "on") == false)
|
||||
{
|
||||
int data_checksum_version = get_data_checksum_version(data_directory);
|
||||
|
||||
if (data_checksum_version < 0)
|
||||
{
|
||||
if (can_use == false)
|
||||
appendPQExpBuffer(reason, "; ");
|
||||
|
||||
appendPQExpBuffer(
|
||||
reason,
|
||||
_("\"wal_log_hints\" is set to \"off\" but unable to determine checksum version"));
|
||||
can_use = false;
|
||||
}
|
||||
else if (data_checksum_version == 0)
|
||||
{
|
||||
if (can_use == false)
|
||||
appendPQExpBuffer(reason, "; ");
|
||||
|
||||
appendPQExpBuffer(
|
||||
reason,
|
||||
_("\"wal_log_hints\" is set to \"off\" and checksums are disabled"));
|
||||
|
||||
can_use = false;
|
||||
}
|
||||
}
|
||||
|
||||
return can_use;
|
||||
}
|
||||
|
||||
|
||||
/* ================ */
|
||||
/* result functions */
|
||||
/* ================ */
|
||||
|
||||
Reference in New Issue
Block a user