mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 07:06:30 +00:00
Compare commits
56 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31a49ff781 | ||
|
|
a6f99b58dd | ||
|
|
09b041433e | ||
|
|
058c8168e1 | ||
|
|
0468e47ef3 | ||
|
|
216326f316 | ||
|
|
3fb20ce774 | ||
|
|
e468ca859e | ||
|
|
623c84c022 | ||
|
|
c2dded1d7b | ||
|
|
457dbbd267 | ||
|
|
5485c06bc1 | ||
|
|
00ae42eb07 | ||
|
|
33525491ae | ||
|
|
8c84f7a214 | ||
|
|
efe4bed88e | ||
|
|
9ba8dcbac3 | ||
|
|
a8996a5bfa | ||
|
|
4cbba98193 | ||
|
|
23e6b85de3 | ||
|
|
d5ecb09f22 | ||
|
|
719dd93676 | ||
|
|
5747f1d446 | ||
|
|
9313b43cb1 | ||
|
|
5aeb1b0589 | ||
|
|
6c93388848 | ||
|
|
d4ad8ce20c | ||
|
|
bacab8d31c | ||
|
|
14856e3a4d | ||
|
|
ca9242badb | ||
|
|
ff0929e882 | ||
|
|
8cd1811edb | ||
|
|
bf15c0d40f | ||
|
|
9ae9d31165 | ||
|
|
d5064bdc02 | ||
|
|
9d0524a008 | ||
|
|
5398fd2d22 | ||
|
|
4c44c01380 | ||
|
|
5113ab0274 | ||
|
|
25f68bb283 | ||
|
|
730f67258c | ||
|
|
ca0e4de1ee | ||
|
|
2fb0f056fe | ||
|
|
3a789d53e0 | ||
|
|
fb67b2cd4f | ||
|
|
9f07804b6a | ||
|
|
d5b2fa2309 | ||
|
|
d696c4019e | ||
|
|
e6ffbcc67a | ||
|
|
e1410831e0 | ||
|
|
cb4f6f6e3f | ||
|
|
75e5d79654 | ||
|
|
55fbe12971 | ||
|
|
db4199e08f | ||
|
|
0d9ed02729 | ||
|
|
8e9f0b802b |
11
HISTORY
11
HISTORY
@@ -1,14 +1,3 @@
|
||||
4.2.0 2018-??-??
|
||||
repmgr: add parameter "shutdown_check_timeout" for use by "standby switchover";
|
||||
GitHub #504 (Ian)
|
||||
repmgr: add "--node-id" option to "repmgr cluster cleanup"; GitHub #493 (Ian)
|
||||
repmgr: report unreachable nodes when running "repmgr cluster (matrix|crosscheck);
|
||||
GitHub #246 (Ian)
|
||||
repmgr: add configuration file parameter "repmgr_bindir"; GitHub #246 (Ian)
|
||||
repmgr: fix "Missing replication slots" label in "node check"; GitHub #507 (Ian)
|
||||
repmgrd: fix parsing of -d/--daemonize option (Ian)
|
||||
repmgrd: support "pausing" of repmgrd (Ian)
|
||||
|
||||
4.1.1 2018-09-05
|
||||
logging: explicitly log the text of failed queries as ERRORs to
|
||||
assist logfile analysis; GitHub #498
|
||||
|
||||
15
Makefile.in
15
Makefile.in
@@ -13,9 +13,8 @@ DATA = \
|
||||
repmgr--unpackaged--4.0.sql \
|
||||
repmgr--4.0.sql \
|
||||
repmgr--4.0--4.1.sql \
|
||||
repmgr--4.1.sql \
|
||||
repmgr--4.1--4.2.sql \
|
||||
repmgr--4.2.sql
|
||||
repmgr--4.1.sql
|
||||
|
||||
|
||||
REGRESS = repmgr_extension
|
||||
|
||||
@@ -30,24 +29,19 @@ all: \
|
||||
PG_CPPFLAGS = -std=gnu89 -I$(includedir_internal) -I$(libpq_srcdir) -Wall -Wmissing-prototypes -Wmissing-declarations $(EXTRA_CFLAGS)
|
||||
SHLIB_LINK = $(libpq)
|
||||
|
||||
|
||||
HEADERS = $(wildcard *.h)
|
||||
|
||||
OBJS = \
|
||||
repmgr.o
|
||||
|
||||
include Makefile.global
|
||||
|
||||
ifeq ($(vpath_build),yes)
|
||||
HEADERS = $(wildcard *.h)
|
||||
else
|
||||
HEADERS_built = $(wildcard *.h)
|
||||
endif
|
||||
|
||||
$(info Building against PostgreSQL $(MAJORVERSION))
|
||||
|
||||
REPMGR_CLIENT_OBJS = repmgr-client.o \
|
||||
repmgr-action-primary.o repmgr-action-standby.o repmgr-action-witness.o \
|
||||
repmgr-action-bdr.o repmgr-action-cluster.o repmgr-action-node.o repmgr-action-daemon.o \
|
||||
repmgr-action-bdr.o repmgr-action-cluster.o repmgr-action-node.o \
|
||||
configfile.o log.o strutil.o controldata.o dirutil.o compat.o dbutils.o
|
||||
REPMGRD_OBJS = repmgrd.o repmgrd-physical.o repmgrd-bdr.o configfile.o log.o dbutils.o strutil.o controldata.o compat.o
|
||||
DATE=$(shell date "+%Y-%m-%d")
|
||||
@@ -91,7 +85,6 @@ additional-clean:
|
||||
rm -f repmgr-action-bdr.o
|
||||
rm -f repmgr-action-node.o
|
||||
rm -f repmgr-action-cluster.o
|
||||
rm -f repmgr-action-daemon.o
|
||||
rm -f repmgrd.o
|
||||
rm -f repmgrd-physical.o
|
||||
rm -f repmgrd-bdr.o
|
||||
|
||||
26
configfile.c
26
configfile.c
@@ -88,7 +88,8 @@ load_config(const char *config_file, bool verbose, bool terse, t_configuration_o
|
||||
|
||||
if (pwd != NULL)
|
||||
{
|
||||
appendPQExpBufferStr(&fullpath, pwd);
|
||||
appendPQExpBuffer(&fullpath,
|
||||
"%s", pwd);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -104,7 +105,9 @@ load_config(const char *config_file, bool verbose, bool terse, t_configuration_o
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
appendPQExpBufferStr(&fullpath, cwd);
|
||||
appendPQExpBuffer(&fullpath,
|
||||
"%s",
|
||||
cwd);
|
||||
}
|
||||
|
||||
appendPQExpBuffer(&fullpath,
|
||||
@@ -285,7 +288,6 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
||||
memset(options->data_directory, 0, sizeof(options->data_directory));
|
||||
memset(options->config_directory, 0, sizeof(options->data_directory));
|
||||
memset(options->pg_bindir, 0, sizeof(options->pg_bindir));
|
||||
memset(options->repmgr_bindir, 0, sizeof(options->repmgr_bindir));
|
||||
options->replication_type = REPLICATION_TYPE_PHYSICAL;
|
||||
|
||||
/*-------------
|
||||
@@ -333,7 +335,6 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
||||
* standby switchover settings
|
||||
*------------------------
|
||||
*/
|
||||
options->shutdown_check_timeout = DEFAULT_SHUTDOWN_CHECK_TIMEOUT;
|
||||
options->standby_reconnect_timeout = DEFAULT_STANDBY_RECONNECT_TIMEOUT;
|
||||
|
||||
/*-----------------
|
||||
@@ -488,8 +489,6 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
||||
}
|
||||
else if (strcmp(name, "pg_bindir") == 0)
|
||||
strncpy(options->pg_bindir, value, MAXPGPATH);
|
||||
else if (strcmp(name, "repmgr_bindir") == 0)
|
||||
strncpy(options->repmgr_bindir, value, MAXPGPATH);
|
||||
|
||||
else if (strcmp(name, "replication_type") == 0)
|
||||
{
|
||||
@@ -546,8 +545,6 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
||||
options->standby_follow_timeout = repmgr_atoi(value, name, error_list, 0);
|
||||
|
||||
/* standby switchover settings */
|
||||
else if (strcmp(name, "shutdown_check_timeout") == 0)
|
||||
options->shutdown_check_timeout = repmgr_atoi(value, name, error_list, 0);
|
||||
else if (strcmp(name, "standby_reconnect_timeout") == 0)
|
||||
options->standby_reconnect_timeout = repmgr_atoi(value, name, error_list, 0);
|
||||
|
||||
@@ -1055,13 +1052,11 @@ parse_time_unit_parameter(const char *name, const char *value, char *dest, ItemL
|
||||
* - repmgrd_standby_startup_timeout
|
||||
* - retry_promote_interval_secs
|
||||
*
|
||||
* non-changeable options (repmgrd references these from the "repmgr.nodes"
|
||||
* table, not the configuration file)
|
||||
* non-changeable options
|
||||
*
|
||||
* - node_id
|
||||
* - node_name
|
||||
* - data_directory
|
||||
* - location
|
||||
* - priority
|
||||
* - replication_type
|
||||
*
|
||||
@@ -1108,8 +1103,8 @@ reload_config(t_configuration_options *orig_options, t_server_type server_type)
|
||||
|
||||
initPQExpBuffer(&errors);
|
||||
|
||||
appendPQExpBufferStr(&errors,
|
||||
"following errors were detected:\n");
|
||||
appendPQExpBuffer(&errors,
|
||||
"following errors were detected:\n");
|
||||
|
||||
for (cell = config_errors.head; cell; cell = cell->next)
|
||||
{
|
||||
@@ -1277,7 +1272,7 @@ reload_config(t_configuration_options *orig_options, t_server_type server_type)
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* promote_delay (for testing use only; not documented */
|
||||
/* promote_delay */
|
||||
if (orig_options->promote_delay != new_options.promote_delay)
|
||||
{
|
||||
orig_options->promote_delay = new_options.promote_delay;
|
||||
@@ -1531,9 +1526,6 @@ parse_bool(const char *s, const char *config_item, ItemList *error_list)
|
||||
{
|
||||
PQExpBufferData errors;
|
||||
|
||||
if (s == NULL)
|
||||
return true;
|
||||
|
||||
if (strcasecmp(s, "0") == 0)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -75,7 +75,6 @@ typedef struct
|
||||
char data_directory[MAXPGPATH];
|
||||
char config_directory[MAXPGPATH];
|
||||
char pg_bindir[MAXPGPATH];
|
||||
char repmgr_bindir[MAXPGPATH];
|
||||
int replication_type;
|
||||
|
||||
/* log settings */
|
||||
@@ -104,7 +103,6 @@ typedef struct
|
||||
int standby_follow_timeout;
|
||||
|
||||
/* standby switchover settings */
|
||||
int shutdown_check_timeout;
|
||||
int standby_reconnect_timeout;
|
||||
|
||||
/* node rejoin settings */
|
||||
@@ -172,7 +170,7 @@ typedef struct
|
||||
|
||||
#define T_CONFIGURATION_OPTIONS_INITIALIZER { \
|
||||
/* node information */ \
|
||||
UNKNOWN_NODE_ID, "", "", "", "", "", "", "", REPLICATION_TYPE_PHYSICAL, \
|
||||
UNKNOWN_NODE_ID, "", "", "", "", "", "", REPLICATION_TYPE_PHYSICAL, \
|
||||
/* log settings */ \
|
||||
"", "", "", DEFAULT_LOG_STATUS_INTERVAL, \
|
||||
/* standby clone settings */ \
|
||||
@@ -183,7 +181,6 @@ typedef struct
|
||||
DEFAULT_PRIMARY_FOLLOW_TIMEOUT, \
|
||||
DEFAULT_STANDBY_FOLLOW_TIMEOUT, \
|
||||
/* standby switchover settings */ \
|
||||
DEFAULT_SHUTDOWN_CHECK_TIMEOUT, \
|
||||
DEFAULT_STANDBY_RECONNECT_TIMEOUT, \
|
||||
/* node rejoin settings */ \
|
||||
DEFAULT_NODE_REJOIN_TIMEOUT, \
|
||||
|
||||
18
configure
vendored
18
configure
vendored
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for repmgr 4.2.
|
||||
# Generated by GNU Autoconf 2.69 for repmgr 4.1.1.
|
||||
#
|
||||
# Report bugs to <pgsql-bugs@postgresql.org>.
|
||||
#
|
||||
@@ -582,8 +582,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='repmgr'
|
||||
PACKAGE_TARNAME='repmgr'
|
||||
PACKAGE_VERSION='4.2'
|
||||
PACKAGE_STRING='repmgr 4.2'
|
||||
PACKAGE_VERSION='4.1.1'
|
||||
PACKAGE_STRING='repmgr 4.1.1'
|
||||
PACKAGE_BUGREPORT='pgsql-bugs@postgresql.org'
|
||||
PACKAGE_URL='https://2ndquadrant.com/en/resources/repmgr/'
|
||||
|
||||
@@ -1178,7 +1178,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures repmgr 4.2 to adapt to many kinds of systems.
|
||||
\`configure' configures repmgr 4.1.1 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@@ -1239,7 +1239,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of repmgr 4.2:";;
|
||||
short | recursive ) echo "Configuration of repmgr 4.1.1:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@@ -1313,7 +1313,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
repmgr configure 4.2
|
||||
repmgr configure 4.1.1
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@@ -1332,7 +1332,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by repmgr $as_me 4.2, which was
|
||||
It was created by repmgr $as_me 4.1.1, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@@ -2359,7 +2359,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by repmgr $as_me 4.2, which was
|
||||
This file was extended by repmgr $as_me 4.1.1, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@@ -2422,7 +2422,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
repmgr config.status 4.2
|
||||
repmgr config.status 4.1.1
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
AC_INIT([repmgr], [4.2], [pgsql-bugs@postgresql.org], [repmgr], [https://2ndquadrant.com/en/resources/repmgr/])
|
||||
AC_INIT([repmgr], [4.1.1], [pgsql-bugs@postgresql.org], [repmgr], [https://2ndquadrant.com/en/resources/repmgr/])
|
||||
|
||||
AC_COPYRIGHT([Copyright (c) 2010-2018, 2ndQuadrant Ltd.])
|
||||
|
||||
|
||||
@@ -227,15 +227,7 @@ get_controlfile(const char *DataDir)
|
||||
|
||||
control_file_info->control_file_processed = true;
|
||||
|
||||
if (version_num >= 110000)
|
||||
{
|
||||
ControlFileData11 *ptr = (struct ControlFileData11 *)ControlFileDataPtr;
|
||||
control_file_info->system_identifier = ptr->system_identifier;
|
||||
control_file_info->state = ptr->state;
|
||||
control_file_info->checkPoint = ptr->checkPoint;
|
||||
control_file_info->data_checksum_version = ptr->data_checksum_version;
|
||||
}
|
||||
else if (version_num >= 90500)
|
||||
if (version_num >= 90500)
|
||||
{
|
||||
ControlFileData95 *ptr = (struct ControlFileData95 *)ControlFileDataPtr;
|
||||
control_file_info->system_identifier = ptr->system_identifier;
|
||||
|
||||
@@ -265,71 +265,6 @@ typedef struct ControlFileData95
|
||||
|
||||
} ControlFileData95;
|
||||
|
||||
/*
|
||||
* Following field removed in 11:
|
||||
*
|
||||
* XLogRecPtr prevCheckPoint;
|
||||
*
|
||||
* In 10, following field appended *after* "data_checksum_version":
|
||||
*
|
||||
* char mock_authentication_nonce[MOCK_AUTH_NONCE_LEN];
|
||||
*
|
||||
* (but we don't care about that)
|
||||
*/
|
||||
|
||||
typedef struct ControlFileData11
|
||||
{
|
||||
uint64 system_identifier;
|
||||
|
||||
uint32 pg_control_version; /* PG_CONTROL_VERSION */
|
||||
uint32 catalog_version_no; /* see catversion.h */
|
||||
|
||||
DBState state; /* see enum above */
|
||||
pg_time_t time; /* time stamp of last pg_control update */
|
||||
XLogRecPtr checkPoint; /* last check point record ptr */
|
||||
|
||||
CheckPoint95 checkPointCopy; /* copy of last check point record */
|
||||
|
||||
XLogRecPtr unloggedLSN; /* current fake LSN value, for unlogged rels */
|
||||
|
||||
XLogRecPtr minRecoveryPoint;
|
||||
TimeLineID minRecoveryPointTLI;
|
||||
XLogRecPtr backupStartPoint;
|
||||
XLogRecPtr backupEndPoint;
|
||||
bool backupEndRequired;
|
||||
|
||||
int wal_level;
|
||||
bool wal_log_hints;
|
||||
int MaxConnections;
|
||||
int max_worker_processes;
|
||||
int max_prepared_xacts;
|
||||
int max_locks_per_xact;
|
||||
bool track_commit_timestamp;
|
||||
|
||||
uint32 maxAlign; /* alignment requirement for tuples */
|
||||
double floatFormat; /* constant 1234567.0 */
|
||||
|
||||
uint32 blcksz; /* data block size for this DB */
|
||||
uint32 relseg_size; /* blocks per segment of large relation */
|
||||
|
||||
uint32 xlog_blcksz; /* block size within WAL files */
|
||||
uint32 xlog_seg_size; /* size of each WAL segment */
|
||||
|
||||
uint32 nameDataLen; /* catalog name field width */
|
||||
uint32 indexMaxKeys; /* max number of columns in an index */
|
||||
|
||||
uint32 toast_max_chunk_size; /* chunk size in TOAST tables */
|
||||
uint32 loblksize; /* chunk size in pg_largeobject */
|
||||
|
||||
bool enableIntTimes; /* int64 storage enabled? */
|
||||
|
||||
bool float4ByVal; /* float4 pass-by-value? */
|
||||
bool float8ByVal; /* float8, int8, etc pass-by-value? */
|
||||
|
||||
uint32 data_checksum_version;
|
||||
|
||||
} ControlFileData11;
|
||||
|
||||
|
||||
|
||||
extern DBState get_db_state(const char *data_directory);
|
||||
|
||||
600
dbutils.c
600
dbutils.c
@@ -115,20 +115,20 @@ wrap_ddl_query(PQExpBufferData *query_buf, int replication_type, const char *fmt
|
||||
if (replication_type == REPLICATION_TYPE_BDR)
|
||||
{
|
||||
if (bdr_version_num < 3)
|
||||
appendPQExpBufferStr(query_buf, "SELECT bdr.bdr_replicate_ddl_command($repmgr$");
|
||||
appendPQExpBuffer(query_buf, "SELECT bdr.bdr_replicate_ddl_command($repmgr$");
|
||||
else
|
||||
appendPQExpBufferStr(query_buf, "SELECT bdr.replicate_ddl_command($repmgr$");
|
||||
appendPQExpBuffer(query_buf, "SELECT bdr.replicate_ddl_command($repmgr$");
|
||||
}
|
||||
|
||||
va_start(arglist, fmt);
|
||||
vsnprintf(buf, MAXLEN, fmt, arglist);
|
||||
va_end(arglist);
|
||||
|
||||
appendPQExpBufferStr(query_buf, buf);
|
||||
appendPQExpBuffer(query_buf, "%s", buf);
|
||||
|
||||
if (replication_type == REPLICATION_TYPE_BDR)
|
||||
{
|
||||
appendPQExpBufferStr(query_buf, "$repmgr$)");
|
||||
appendPQExpBuffer(query_buf, "$repmgr$)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1070,9 +1070,9 @@ get_cluster_size(PGconn *conn, char *size)
|
||||
bool success = true;
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
appendPQExpBufferStr(&query,
|
||||
"SELECT pg_catalog.pg_size_pretty(pg_catalog.sum(pg_catalog.pg_database_size(oid))::bigint) "
|
||||
" FROM pg_catalog.pg_database ");
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT pg_catalog.pg_size_pretty(pg_catalog.sum(pg_catalog.pg_database_size(oid))::bigint) "
|
||||
" FROM pg_catalog.pg_database ");
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_cluster_size():\n%s", query.data);
|
||||
|
||||
@@ -1228,13 +1228,13 @@ _get_primary_connection(PGconn *conn,
|
||||
log_verbose(LOG_INFO, _("searching for primary node"));
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT node_id, conninfo, "
|
||||
" CASE WHEN type = 'primary' THEN 1 ELSE 2 END AS type_priority"
|
||||
" FROM repmgr.nodes "
|
||||
" WHERE active IS TRUE "
|
||||
" AND type != 'witness' "
|
||||
"ORDER BY active DESC, type_priority, priority, node_id");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT node_id, conninfo, "
|
||||
" CASE WHEN type = 'primary' THEN 1 ELSE 2 END AS type_priority"
|
||||
" FROM repmgr.nodes "
|
||||
" WHERE active IS TRUE "
|
||||
" AND type != 'witness' "
|
||||
"ORDER BY active DESC, type_priority, priority, node_id");
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_primary_connection():\n%s", query.data);
|
||||
|
||||
@@ -1341,11 +1341,11 @@ get_primary_node_id(PGconn *conn)
|
||||
int retval = NODE_NOT_FOUND;
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
appendPQExpBufferStr(&query,
|
||||
"SELECT node_id "
|
||||
" FROM repmgr.nodes "
|
||||
" WHERE type = 'primary' "
|
||||
" AND active IS TRUE ");
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT node_id "
|
||||
" FROM repmgr.nodes "
|
||||
" WHERE type = 'primary' "
|
||||
" AND active IS TRUE ");
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_primary_node_id():\n%s", query.data);
|
||||
|
||||
@@ -1384,38 +1384,38 @@ get_replication_info(PGconn *conn, ReplInfo *replication_info)
|
||||
server_version_num = get_server_version(conn, NULL);
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT ts, "
|
||||
" last_wal_receive_lsn, "
|
||||
" last_wal_replay_lsn, "
|
||||
" last_xact_replay_timestamp, "
|
||||
" CASE WHEN (last_wal_receive_lsn = last_wal_replay_lsn) "
|
||||
" THEN 0::INT "
|
||||
" ELSE "
|
||||
" EXTRACT(epoch FROM (pg_catalog.clock_timestamp() - last_xact_replay_timestamp))::INT "
|
||||
" END AS replication_lag_time, "
|
||||
" COALESCE(last_wal_receive_lsn, '0/0') >= last_wal_replay_lsn AS receiving_streamed_wal "
|
||||
" FROM ( ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT ts, "
|
||||
" last_wal_receive_lsn, "
|
||||
" last_wal_replay_lsn, "
|
||||
" last_xact_replay_timestamp, "
|
||||
" CASE WHEN (last_wal_receive_lsn = last_wal_replay_lsn) "
|
||||
" THEN 0::INT "
|
||||
" ELSE "
|
||||
" EXTRACT(epoch FROM (pg_catalog.clock_timestamp() - last_xact_replay_timestamp))::INT "
|
||||
" END AS replication_lag_time, "
|
||||
" COALESCE(last_wal_receive_lsn, '0/0') >= last_wal_replay_lsn AS receiving_streamed_wal "
|
||||
" FROM ( ");
|
||||
|
||||
if (server_version_num >= 100000)
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT CURRENT_TIMESTAMP AS ts, "
|
||||
" pg_catalog.pg_last_wal_receive_lsn() AS last_wal_receive_lsn, "
|
||||
" pg_catalog.pg_last_wal_replay_lsn() AS last_wal_replay_lsn, "
|
||||
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT CURRENT_TIMESTAMP AS ts, "
|
||||
" pg_catalog.pg_last_wal_receive_lsn() AS last_wal_receive_lsn, "
|
||||
" pg_catalog.pg_last_wal_replay_lsn() AS last_wal_replay_lsn, "
|
||||
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp ");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT CURRENT_TIMESTAMP AS ts, "
|
||||
" pg_catalog.pg_last_xlog_receive_location() AS last_wal_receive_lsn, "
|
||||
" pg_catalog.pg_last_xlog_replay_location() AS last_wal_replay_lsn, "
|
||||
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT CURRENT_TIMESTAMP AS ts, "
|
||||
" pg_catalog.pg_last_xlog_receive_location() AS last_wal_receive_lsn, "
|
||||
" pg_catalog.pg_last_xlog_replay_location() AS last_wal_replay_lsn, "
|
||||
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp ");
|
||||
}
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" ) q ");
|
||||
appendPQExpBuffer(&query,
|
||||
" ) q ");
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_replication_info():\n%s", query.data);
|
||||
|
||||
@@ -1538,21 +1538,21 @@ get_replication_lag_seconds(PGconn *conn)
|
||||
|
||||
if (server_version_num >= 100000)
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT CASE WHEN (pg_catalog.pg_last_wal_receive_lsn() = pg_catalog.pg_last_wal_replay_lsn()) ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT CASE WHEN (pg_catalog.pg_last_wal_receive_lsn() = pg_catalog.pg_last_wal_replay_lsn()) ");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT CASE WHEN (pg_catalog.pg_last_xlog_receive_location() = pg_catalog.pg_last_xlog_replay_location()) ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT CASE WHEN (pg_catalog.pg_last_xlog_receive_location() = pg_catalog.pg_last_xlog_replay_location()) ");
|
||||
}
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" THEN 0 "
|
||||
" ELSE EXTRACT(epoch FROM (pg_catalog.clock_timestamp() - pg_catalog.pg_last_xact_replay_timestamp()))::INT "
|
||||
" END "
|
||||
" AS lag_seconds");
|
||||
appendPQExpBuffer(&query,
|
||||
" THEN 0 "
|
||||
" ELSE EXTRACT(epoch FROM (pg_catalog.clock_timestamp() - pg_catalog.pg_last_xact_replay_timestamp()))::INT "
|
||||
" END "
|
||||
" AS lag_seconds");
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
log_verbose(LOG_DEBUG, "get_replication_lag_seconds():\n%s", query.data);
|
||||
@@ -1627,6 +1627,7 @@ repmgrd_set_local_node_id(PGconn *conn, int local_node_id)
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
repmgrd_get_local_node_id(PGconn *conn)
|
||||
{
|
||||
@@ -1685,135 +1686,6 @@ server_in_exclusive_backup_mode(PGconn *conn)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
repmgrd_set_pid(PGconn *conn, pid_t repmgrd_pid, const char *pidfile)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
PGresult *res = NULL;
|
||||
|
||||
log_verbose(LOG_DEBUG, "repmgrd_set_pid(): pid is %i", (int) repmgrd_pid);
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT repmgr.set_repmgrd_pid(%i, '%s')",
|
||||
(int) repmgrd_pid, pidfile);
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_error(_("unable to execute \"SELECT repmgr.set_repmgrd_pid()\""));
|
||||
log_detail("%s", PQerrorMessage(conn));
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pid_t
|
||||
repmgrd_get_pid(PGconn *conn)
|
||||
{
|
||||
PGresult *res = NULL;
|
||||
pid_t repmgrd_pid = UNKNOWN_PID;
|
||||
|
||||
res = PQexec(conn, "SELECT repmgr.get_repmgrd_pid()");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_error(_("unable to execute \"SELECT repmgr.get_repmgrd_pid()\""));
|
||||
log_detail("%s", PQerrorMessage(conn));
|
||||
}
|
||||
else if (!PQgetisnull(res, 0, 0))
|
||||
{
|
||||
repmgrd_pid = atoi(PQgetvalue(res, 0, 0));
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
return repmgrd_pid;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
repmgrd_is_running(PGconn *conn)
|
||||
{
|
||||
PGresult *res = NULL;
|
||||
bool is_running = false;
|
||||
|
||||
res = PQexec(conn, "SELECT repmgr.repmgrd_is_running()");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_error(_("unable to execute \"SELECT repmgr.repmgrd_is_running()\""));
|
||||
log_detail("%s", PQerrorMessage(conn));
|
||||
}
|
||||
else if (!PQgetisnull(res, 0, 0))
|
||||
{
|
||||
is_running = atobool(PQgetvalue(res, 0, 0));
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
return is_running;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
repmgrd_is_paused(PGconn *conn)
|
||||
{
|
||||
PGresult *res = NULL;
|
||||
bool is_paused = false;
|
||||
|
||||
res = PQexec(conn, "SELECT repmgr.repmgrd_is_paused()");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_error(_("unable to execute \"SELECT repmgr.repmgrd_is_paused()\""));
|
||||
log_detail("%s", PQerrorMessage(conn));
|
||||
}
|
||||
else if (!PQgetisnull(res, 0, 0))
|
||||
{
|
||||
is_paused = atobool(PQgetvalue(res, 0, 0));
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
return is_paused;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
repmgrd_pause(PGconn *conn, bool pause)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
PGresult *res = NULL;
|
||||
bool success = true;
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT repmgr.repmgrd_pause(%s)",
|
||||
pause == true ? "TRUE" : "FALSE");
|
||||
res = PQexec(conn, query.data);
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_error(_("unable to execute \"SELECT repmgr.repmgrd_pause()\""));
|
||||
log_detail("%s", PQerrorMessage(conn));
|
||||
|
||||
success = false;
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/* ================ */
|
||||
/* result functions */
|
||||
/* ================ */
|
||||
@@ -1842,12 +1714,12 @@ get_repmgr_extension_status(PGconn *conn)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT ae.name, e.extname "
|
||||
" FROM pg_catalog.pg_available_extensions ae "
|
||||
"LEFT JOIN pg_catalog.pg_extension e "
|
||||
" ON e.extname=ae.name "
|
||||
" WHERE ae.name='repmgr' ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT ae.name, e.extname "
|
||||
" FROM pg_catalog.pg_available_extensions ae "
|
||||
"LEFT JOIN pg_catalog.pg_extension e "
|
||||
" ON e.extname=ae.name "
|
||||
" WHERE ae.name='repmgr' ");
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
|
||||
@@ -2226,38 +2098,37 @@ _populate_node_records(PGresult *res, NodeInfoList *node_list)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
void
|
||||
get_all_node_records(PGconn *conn, NodeInfoList *node_list)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
PGresult *res = NULL;
|
||||
bool success = true;
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT " REPMGR_NODES_COLUMNS
|
||||
" FROM repmgr.nodes n "
|
||||
"ORDER BY n.node_id ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT " REPMGR_NODES_COLUMNS
|
||||
" FROM repmgr.nodes n "
|
||||
"ORDER BY n.node_id ");
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_all_node_records():\n%s", query.data);
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
|
||||
/* this will return an empty list if there was an error executing the query */
|
||||
_populate_node_records(res, node_list);
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_db_error(conn, query.data, _("get_all_node_records(): unable to execute query"));
|
||||
success = false;
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
return success;
|
||||
}
|
||||
/* this will return an empty list if there was an error executing the query */
|
||||
_populate_node_records(res, node_list);
|
||||
|
||||
PQclear(res);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
get_downstream_node_records(PGconn *conn, int node_id, NodeInfoList *node_list)
|
||||
@@ -2340,10 +2211,10 @@ get_node_records_by_priority(PGconn *conn, NodeInfoList *node_list)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT " REPMGR_NODES_COLUMNS
|
||||
" FROM repmgr.nodes n "
|
||||
"ORDER BY n.priority DESC, n.node_name ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT " REPMGR_NODES_COLUMNS
|
||||
" FROM repmgr.nodes n "
|
||||
"ORDER BY n.priority DESC, n.node_name ");
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_node_records_by_priority():\n%s", query.data);
|
||||
|
||||
@@ -2377,13 +2248,13 @@ get_all_node_records_with_upstream(PGconn *conn, NodeInfoList *node_list)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT n.node_id, n.type, n.upstream_node_id, n.node_name, n.conninfo, n.repluser, "
|
||||
" n.slot_name, n.location, n.priority, n.active, n.config_file, un.node_name AS upstream_node_name "
|
||||
" FROM repmgr.nodes n "
|
||||
" LEFT JOIN repmgr.nodes un "
|
||||
" ON un.node_id = n.upstream_node_id"
|
||||
" ORDER BY n.node_id ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT n.node_id, n.type, n.upstream_node_id, n.node_name, n.conninfo, n.repluser, "
|
||||
" n.slot_name, n.location, n.priority, n.active, n.config_file, un.node_name AS upstream_node_name "
|
||||
" FROM repmgr.nodes n "
|
||||
" LEFT JOIN repmgr.nodes un "
|
||||
" ON un.node_id = n.upstream_node_id"
|
||||
" ORDER BY n.node_id ");
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_all_node_records_with_upstream():\n%s", query.data);
|
||||
|
||||
@@ -2526,30 +2397,31 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
||||
|
||||
if (strcmp(action, "create") == 0)
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
"INSERT INTO repmgr.nodes "
|
||||
" (node_id, type, upstream_node_id, "
|
||||
" node_name, conninfo, repluser, slot_name, "
|
||||
" location, priority, active, config_file) "
|
||||
"VALUES ($11, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ");
|
||||
appendPQExpBuffer(&query,
|
||||
"INSERT INTO repmgr.nodes "
|
||||
" (node_id, type, upstream_node_id, "
|
||||
" node_name, conninfo, repluser, slot_name, "
|
||||
" location, priority, active, config_file) "
|
||||
"VALUES ($11, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
"UPDATE repmgr.nodes SET "
|
||||
" type = $1, "
|
||||
" upstream_node_id = $2, "
|
||||
" node_name = $3, "
|
||||
" conninfo = $4, "
|
||||
" repluser = $5, "
|
||||
" slot_name = $6, "
|
||||
" location = $7, "
|
||||
" priority = $8, "
|
||||
" active = $9, "
|
||||
" config_file = $10 "
|
||||
" WHERE node_id = $11 ");
|
||||
appendPQExpBuffer(&query,
|
||||
"UPDATE repmgr.nodes SET "
|
||||
" type = $1, "
|
||||
" upstream_node_id = $2, "
|
||||
" node_name = $3, "
|
||||
" conninfo = $4, "
|
||||
" repluser = $5, "
|
||||
" slot_name = $6, "
|
||||
" location = $7, "
|
||||
" priority = $8, "
|
||||
" active = $9, "
|
||||
" config_file = $10 "
|
||||
" WHERE node_id = $11 ");
|
||||
}
|
||||
|
||||
|
||||
res = PQexecParams(conn,
|
||||
query.data,
|
||||
param_count,
|
||||
@@ -2986,31 +2858,31 @@ get_node_replication_stats(PGconn *conn, int server_version_num, t_node_info *no
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT pg_catalog.current_setting('max_wal_senders')::INT AS max_wal_senders, "
|
||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_stat_replication) AS attached_wal_receivers, ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT pg_catalog.current_setting('max_wal_senders')::INT AS max_wal_senders, "
|
||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_stat_replication) AS attached_wal_receivers, ");
|
||||
|
||||
/* no replication slots in PostgreSQL 9.3 */
|
||||
if (server_version_num < 90400)
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
" 0 AS max_replication_slots, "
|
||||
" 0 AS total_replication_slots, "
|
||||
" 0 AS active_replication_slots, "
|
||||
" 0 AS inactive_replication_slots, ");
|
||||
appendPQExpBuffer(&query,
|
||||
" 0 AS max_replication_slots, "
|
||||
" 0 AS total_replication_slots, "
|
||||
" 0 AS active_replication_slots, "
|
||||
" 0 AS inactive_replication_slots, ");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
" current_setting('max_replication_slots')::INT AS max_replication_slots, "
|
||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots) AS total_replication_slots, "
|
||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots WHERE active IS TRUE) AS active_replication_slots, "
|
||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots WHERE active IS FALSE) AS inactive_replication_slots, ");
|
||||
appendPQExpBuffer(&query,
|
||||
" current_setting('max_replication_slots')::INT AS max_replication_slots, "
|
||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots) AS total_replication_slots, "
|
||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots WHERE active IS TRUE) AS active_replication_slots, "
|
||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots WHERE active IS FALSE) AS inactive_replication_slots, ");
|
||||
}
|
||||
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" pg_catalog.pg_is_in_recovery() AS in_recovery");
|
||||
appendPQExpBuffer(&query,
|
||||
" pg_catalog.pg_is_in_recovery() AS in_recovery");
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_node_replication_stats():\n%s", query.data);
|
||||
|
||||
@@ -3151,26 +3023,26 @@ get_datadir_configuration_files(PGconn *conn, KeyValueList *list)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
"WITH files AS ( "
|
||||
" WITH dd AS ( "
|
||||
" SELECT setting "
|
||||
" FROM pg_catalog.pg_settings "
|
||||
" WHERE name = 'data_directory') "
|
||||
" SELECT distinct(sourcefile) AS config_file"
|
||||
" FROM dd, pg_catalog.pg_settings ps "
|
||||
" WHERE ps.sourcefile IS NOT NULL "
|
||||
" AND ps.sourcefile ~ ('^' || dd.setting) "
|
||||
" UNION "
|
||||
" SELECT ps.setting AS config_file"
|
||||
" FROM dd, pg_catalog.pg_settings ps "
|
||||
" WHERE ps.name IN ('config_file', 'hba_file', 'ident_file') "
|
||||
" AND ps.setting ~ ('^' || dd.setting) "
|
||||
") "
|
||||
" SELECT config_file, "
|
||||
" pg_catalog.regexp_replace(config_file, '^.*\\/','') AS filename "
|
||||
" FROM files "
|
||||
"ORDER BY config_file");
|
||||
appendPQExpBuffer(&query,
|
||||
"WITH files AS ( "
|
||||
" WITH dd AS ( "
|
||||
" SELECT setting "
|
||||
" FROM pg_catalog.pg_settings "
|
||||
" WHERE name = 'data_directory') "
|
||||
" SELECT distinct(sourcefile) AS config_file"
|
||||
" FROM dd, pg_catalog.pg_settings ps "
|
||||
" WHERE ps.sourcefile IS NOT NULL "
|
||||
" AND ps.sourcefile ~ ('^' || dd.setting) "
|
||||
" UNION "
|
||||
" SELECT ps.setting AS config_file"
|
||||
" FROM dd, pg_catalog.pg_settings ps "
|
||||
" WHERE ps.name IN ('config_file', 'hba_file', 'ident_file') "
|
||||
" AND ps.setting ~ ('^' || dd.setting) "
|
||||
") "
|
||||
" SELECT config_file, "
|
||||
" pg_catalog.regexp_replace(config_file, '^.*\\/','') AS filename "
|
||||
" FROM files "
|
||||
"ORDER BY config_file");
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
|
||||
@@ -3207,18 +3079,18 @@ get_configuration_file_locations(PGconn *conn, t_configfile_list *list)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" WITH dd AS ( "
|
||||
" SELECT setting AS data_directory"
|
||||
" FROM pg_catalog.pg_settings "
|
||||
" WHERE name = 'data_directory' "
|
||||
" ) "
|
||||
" SELECT DISTINCT(sourcefile), "
|
||||
" pg_catalog.regexp_replace(sourcefile, '^.*\\/', '') AS filename, "
|
||||
" sourcefile ~ ('^' || dd.data_directory) AS in_data_dir "
|
||||
" FROM dd, pg_catalog.pg_settings ps "
|
||||
" WHERE sourcefile IS NOT NULL "
|
||||
" ORDER BY 1 ");
|
||||
appendPQExpBuffer(&query,
|
||||
" WITH dd AS ( "
|
||||
" SELECT setting AS data_directory"
|
||||
" FROM pg_catalog.pg_settings "
|
||||
" WHERE name = 'data_directory' "
|
||||
" ) "
|
||||
" SELECT DISTINCT(sourcefile), "
|
||||
" pg_catalog.regexp_replace(sourcefile, '^.*\\/', '') AS filename, "
|
||||
" sourcefile ~ ('^' || dd.data_directory) AS in_data_dir "
|
||||
" FROM dd, pg_catalog.pg_settings ps "
|
||||
" WHERE sourcefile IS NOT NULL "
|
||||
" ORDER BY 1 ");
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_configuration_file_locations():\n %s",
|
||||
query.data);
|
||||
@@ -3257,18 +3129,19 @@ get_configuration_file_locations(PGconn *conn, t_configfile_list *list)
|
||||
/* Fetch locations of pg_hba.conf and pg_ident.conf */
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" WITH dd AS ( "
|
||||
" SELECT setting AS data_directory"
|
||||
" FROM pg_catalog.pg_settings "
|
||||
" WHERE name = 'data_directory' "
|
||||
" ) "
|
||||
" SELECT ps.setting, "
|
||||
" pg_catalog.regexp_replace(setting, '^.*\\/', '') AS filename, "
|
||||
" ps.setting ~ ('^' || dd.data_directory) AS in_data_dir "
|
||||
" FROM dd, pg_catalog.pg_settings ps "
|
||||
" WHERE ps.name IN ('hba_file', 'ident_file') "
|
||||
" ORDER BY 1 ");
|
||||
appendPQExpBuffer(&query,
|
||||
" WITH dd AS ( "
|
||||
" SELECT setting AS data_directory"
|
||||
" FROM pg_catalog.pg_settings "
|
||||
" WHERE name = 'data_directory' "
|
||||
" ) "
|
||||
" SELECT ps.setting, "
|
||||
" pg_catalog.regexp_replace(setting, '^.*\\/', '') AS filename, "
|
||||
" ps.setting ~ ('^' || dd.data_directory) AS in_data_dir "
|
||||
" FROM dd, pg_catalog.pg_settings ps "
|
||||
" WHERE ps.name IN ('hba_file', 'ident_file') "
|
||||
" ORDER BY 1 ");
|
||||
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_configuration_file_locations():\n %s",
|
||||
query.data);
|
||||
@@ -3442,15 +3315,15 @@ _create_event(PGconn *conn, t_configuration_options *options, int node_id, char
|
||||
int binary[4] = {1, 0, 0, 0};
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
appendPQExpBufferStr(&query,
|
||||
" INSERT INTO repmgr.events ( "
|
||||
" node_id, "
|
||||
" event, "
|
||||
" successful, "
|
||||
" details "
|
||||
" ) "
|
||||
" VALUES ($1, $2, $3, $4) "
|
||||
" RETURNING event_timestamp ");
|
||||
appendPQExpBuffer(&query,
|
||||
" INSERT INTO repmgr.events ( "
|
||||
" node_id, "
|
||||
" event, "
|
||||
" successful, "
|
||||
" details "
|
||||
" ) "
|
||||
" VALUES ($1, $2, $3, $4) "
|
||||
" RETURNING event_timestamp ");
|
||||
|
||||
log_verbose(LOG_DEBUG, "_create_event():\n %s", query.data);
|
||||
|
||||
@@ -3681,12 +3554,12 @@ get_event_records(PGconn *conn, int node_id, const char *node_name, const char *
|
||||
initPQExpBuffer(&where_clause);
|
||||
|
||||
/* LEFT JOIN used here as a node record may have been removed */
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT e.node_id, n.node_name, e.event, e.successful, "
|
||||
" pg_catalog.to_char(e.event_timestamp, 'YYYY-MM-DD HH24:MI:SS') AS timestamp, "
|
||||
" e.details "
|
||||
" FROM repmgr.events e "
|
||||
"LEFT JOIN repmgr.nodes n ON e.node_id = n.node_id ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT e.node_id, n.node_name, e.event, e.successful, "
|
||||
" pg_catalog.to_char(e.event_timestamp, 'YYYY-MM-DD HH24:MI:SS') AS timestamp, "
|
||||
" e.details "
|
||||
" FROM repmgr.events e "
|
||||
"LEFT JOIN repmgr.nodes n ON e.node_id = n.node_id ");
|
||||
|
||||
if (node_id != UNKNOWN_NODE_ID)
|
||||
{
|
||||
@@ -3732,8 +3605,8 @@ get_event_records(PGconn *conn, int node_id, const char *node_name, const char *
|
||||
appendPQExpBuffer(&query, "\n%s\n",
|
||||
where_clause.data);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" ORDER BY e.event_timestamp DESC");
|
||||
appendPQExpBuffer(&query,
|
||||
" ORDER BY e.event_timestamp DESC");
|
||||
|
||||
if (all == false && limit > 0)
|
||||
{
|
||||
@@ -3935,10 +3808,10 @@ get_free_replication_slot_count(PGconn *conn)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT pg_catalog.current_setting('max_replication_slots')::INT - "
|
||||
" pg_catalog.count(*) AS free_slots"
|
||||
" FROM pg_catalog.pg_replication_slots");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT pg_catalog.current_setting('max_replication_slots')::INT - "
|
||||
" pg_catalog.count(*) AS free_slots"
|
||||
" FROM pg_catalog.pg_replication_slots");
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
|
||||
@@ -3974,11 +3847,11 @@ get_inactive_replication_slots(PGconn *conn, KeyValueList *list)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT slot_name, slot_type "
|
||||
" FROM pg_catalog.pg_replication_slots "
|
||||
" WHERE active IS FALSE "
|
||||
" ORDER BY slot_name ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT slot_name, slot_type "
|
||||
" FROM pg_catalog.pg_replication_slots "
|
||||
" WHERE active IS FALSE "
|
||||
" ORDER BY slot_name ");
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
|
||||
@@ -4293,7 +4166,7 @@ add_monitoring_record(PGconn *primary_conn,
|
||||
|
||||
|
||||
int
|
||||
get_number_of_monitoring_records_to_delete(PGconn *primary_conn, int keep_history, int node_id)
|
||||
get_number_of_monitoring_records_to_delete(PGconn *primary_conn, int keep_history)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
int record_count = -1;
|
||||
@@ -4307,16 +4180,9 @@ get_number_of_monitoring_records_to_delete(PGconn *primary_conn, int keep_histor
|
||||
" WHERE pg_catalog.age(pg_catalog.now(), last_monitor_time) >= '%d days'::interval",
|
||||
keep_history);
|
||||
|
||||
if (node_id != UNKNOWN_NODE_ID)
|
||||
{
|
||||
appendPQExpBuffer(&query,
|
||||
" AND standby_node_id = %i", node_id);
|
||||
}
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_number_of_monitoring_records_to_delete():\n %s", query.data);
|
||||
|
||||
res = PQexec(primary_conn, query.data);
|
||||
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_db_error(primary_conn, query.data,
|
||||
@@ -4335,7 +4201,7 @@ get_number_of_monitoring_records_to_delete(PGconn *primary_conn, int keep_histor
|
||||
|
||||
|
||||
bool
|
||||
delete_monitoring_records(PGconn *primary_conn, int keep_history, int node_id)
|
||||
delete_monitoring_records(PGconn *primary_conn, int keep_history)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
bool success = true;
|
||||
@@ -4343,23 +4209,17 @@ delete_monitoring_records(PGconn *primary_conn, int keep_history, int node_id)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
if (keep_history > 0 || node_id != UNKNOWN_NODE_ID)
|
||||
if (keep_history > 0)
|
||||
{
|
||||
appendPQExpBuffer(&query,
|
||||
"DELETE FROM repmgr.monitoring_history "
|
||||
" WHERE pg_catalog.age(pg_catalog.now(), last_monitor_time) >= '%d days'::INTERVAL ",
|
||||
keep_history);
|
||||
|
||||
if (node_id != UNKNOWN_NODE_ID)
|
||||
{
|
||||
appendPQExpBuffer(&query,
|
||||
" AND standby_node_id = %i", node_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
"TRUNCATE TABLE repmgr.monitoring_history");
|
||||
appendPQExpBuffer(&query,
|
||||
"TRUNCATE TABLE repmgr.monitoring_history");
|
||||
}
|
||||
|
||||
res = PQexec(primary_conn, query.data);
|
||||
@@ -4634,10 +4494,10 @@ _is_bdr_db(PGconn *conn, PQExpBufferData *output, bool quiet)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT (pg_catalog.regexp_matches(extversion, '^\\d+'))[1] AS major_version "
|
||||
" FROM pg_catalog.pg_extension "
|
||||
" WHERE extname = 'bdr' ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT (pg_catalog.regexp_matches(extversion, '^\\d+'))[1] AS major_version "
|
||||
" FROM pg_catalog.pg_extension "
|
||||
" WHERE extname = 'bdr' ");
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
termPQExpBuffer(&query);
|
||||
@@ -4662,7 +4522,7 @@ _is_bdr_db(PGconn *conn, PQExpBufferData *output, bool quiet)
|
||||
const char *warning = _("BDR extension is not available for this database");
|
||||
|
||||
if (output != NULL)
|
||||
appendPQExpBufferStr(output, warning);
|
||||
appendPQExpBuffer(output, "%s", warning);
|
||||
else if (quiet == false)
|
||||
log_warning("%s", warning);
|
||||
|
||||
@@ -4673,8 +4533,8 @@ _is_bdr_db(PGconn *conn, PQExpBufferData *output, bool quiet)
|
||||
{
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
"SELECT bdr.bdr_is_active_in_db()");
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT bdr.bdr_is_active_in_db()");
|
||||
res = PQexec(conn, query.data);
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
@@ -4685,7 +4545,7 @@ _is_bdr_db(PGconn *conn, PQExpBufferData *output, bool quiet)
|
||||
const char *warning = _("BDR extension available for this database, but the database is not configured for BDR");
|
||||
|
||||
if (output != NULL)
|
||||
appendPQExpBufferStr(output, warning);
|
||||
appendPQExpBuffer(output, "%s", warning);
|
||||
else if (quiet == false)
|
||||
log_warning("%s", warning);
|
||||
}
|
||||
@@ -4780,10 +4640,10 @@ is_bdr_repmgr(PGconn *conn)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
"SELECT pg_catalog.count(*)"
|
||||
" FROM repmgr.nodes n"
|
||||
" WHERE n.type != 'bdr' ");
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT pg_catalog.count(*)"
|
||||
" FROM repmgr.nodes n"
|
||||
" WHERE n.type != 'bdr' ");
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
termPQExpBuffer(&query);
|
||||
@@ -4828,11 +4688,11 @@ get_default_bdr_replication_set(PGconn *conn)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT rs.set_name "
|
||||
" FROM pglogical.replication_set rs "
|
||||
" INNER JOIN bdr.node_group ng "
|
||||
" ON ng.node_group_default_repset = rs.set_id ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT rs.set_name "
|
||||
" FROM pglogical.replication_set rs "
|
||||
" INNER JOIN bdr.node_group ng "
|
||||
" ON ng.node_group_default_repset = rs.set_id ");
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
termPQExpBuffer(&query);
|
||||
@@ -4967,13 +4827,13 @@ bdr_node_name_matches(PGconn *conn, const char *node_name, PQExpBufferData *bdr_
|
||||
|
||||
if (bdr_version_num < 3)
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
"SELECT bdr.bdr_get_local_node_name() AS node_name");
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT bdr.bdr_get_local_node_name() AS node_name");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
"SELECT node_name FROM bdr.local_node_info()");
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT node_name FROM bdr.local_node_info()");
|
||||
}
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
@@ -5096,13 +4956,13 @@ add_extension_tables_to_bdr_replication_set(PGconn *conn)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT c.relname "
|
||||
" FROM pg_class c "
|
||||
"INNER JOIN pg_namespace n "
|
||||
" ON c.relnamespace = n.oid "
|
||||
" WHERE n.nspname = 'repmgr' "
|
||||
" AND c.relkind = 'r' ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT c.relname "
|
||||
" FROM pg_class c "
|
||||
"INNER JOIN pg_namespace n "
|
||||
" ON c.relnamespace = n.oid "
|
||||
" WHERE n.nspname = 'repmgr' "
|
||||
" AND c.relkind = 'r' ");
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
termPQExpBuffer(&query);
|
||||
@@ -5138,17 +4998,17 @@ get_all_bdr_node_records(PGconn *conn, BdrNodeInfoList *node_list)
|
||||
|
||||
if (bdr_version_num < 3)
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT " BDR2_NODES_COLUMNS
|
||||
" FROM bdr.bdr_nodes "
|
||||
"ORDER BY node_seq_id ");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT " BDR2_NODES_COLUMNS
|
||||
" FROM bdr.bdr_nodes "
|
||||
"ORDER BY node_seq_id ");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT " BDR3_NODES_COLUMNS
|
||||
" FROM bdr.node_summary ns "
|
||||
" ORDER BY node_name");
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT " BDR3_NODES_COLUMNS
|
||||
" FROM bdr.node_summary ns "
|
||||
" ORDER BY node_name");
|
||||
}
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_all_bdr_node_records():\n%s", query.data);
|
||||
|
||||
26
dbutils.h
26
dbutils.h
@@ -327,21 +327,6 @@ typedef struct
|
||||
UNKNOWN_TIMELINE_ID, \
|
||||
InvalidXLogRecPtr \
|
||||
}
|
||||
|
||||
|
||||
typedef struct RepmgrdInfo {
|
||||
int node_id;
|
||||
int pid;
|
||||
char pid_text[MAXLEN];
|
||||
char pid_file[MAXLEN];
|
||||
bool pg_running;
|
||||
char pg_running_text[MAXLEN];
|
||||
bool running;
|
||||
char repmgrd_running[MAXLEN];
|
||||
bool paused;
|
||||
} RepmgrdInfo;
|
||||
|
||||
|
||||
/* global variables */
|
||||
|
||||
extern int server_version_num;
|
||||
@@ -414,11 +399,6 @@ bool identify_system(PGconn *repl_conn, t_system_identification *identification
|
||||
bool repmgrd_set_local_node_id(PGconn *conn, int local_node_id);
|
||||
int repmgrd_get_local_node_id(PGconn *conn);
|
||||
BackupState server_in_exclusive_backup_mode(PGconn *conn);
|
||||
void repmgrd_set_pid(PGconn *conn, pid_t repmgrd_pid, const char *pidfile);
|
||||
pid_t repmgrd_get_pid(PGconn *conn);
|
||||
bool repmgrd_is_running(PGconn *conn);
|
||||
bool repmgrd_is_paused(PGconn *conn);
|
||||
bool repmgrd_pause(PGconn *conn, bool pause);
|
||||
|
||||
/* extension functions */
|
||||
ExtensionStatus get_repmgr_extension_status(PGconn *conn);
|
||||
@@ -441,7 +421,7 @@ t_node_info *get_node_record_pointer(PGconn *conn, int node_id);
|
||||
bool get_local_node_record(PGconn *conn, int node_id, t_node_info *node_info);
|
||||
bool get_primary_node_record(PGconn *conn, t_node_info *node_info);
|
||||
|
||||
bool get_all_node_records(PGconn *conn, NodeInfoList *node_list);
|
||||
void get_all_node_records(PGconn *conn, NodeInfoList *node_list);
|
||||
void get_downstream_node_records(PGconn *conn, int node_id, NodeInfoList *nodes);
|
||||
void get_active_sibling_node_records(PGconn *conn, int node_id, int upstream_node_id, NodeInfoList *node_list);
|
||||
void get_node_records_by_priority(PGconn *conn, NodeInfoList *node_list);
|
||||
@@ -511,8 +491,8 @@ add_monitoring_record(PGconn *primary_conn,
|
||||
long long unsigned int apply_lag_bytes
|
||||
);
|
||||
|
||||
int get_number_of_monitoring_records_to_delete(PGconn *primary_conn, int keep_history, int node_id);
|
||||
bool delete_monitoring_records(PGconn *primary_conn, int keep_history, int node_id);
|
||||
int get_number_of_monitoring_records_to_delete(PGconn *primary_conn, int keep_history);
|
||||
bool delete_monitoring_records(PGconn *primary_conn, int keep_history);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,17 +12,10 @@
|
||||
|
||||
<sect1 id="packages-centos" xreflabel="CentOS packages">
|
||||
<title>CentOS Packages</title>
|
||||
|
||||
<indexterm>
|
||||
<primary>packages</primary>
|
||||
<secondary>CentOS packages</secondary>
|
||||
</indexterm>
|
||||
|
||||
<indexterm>
|
||||
<primary>CentOS</primary>
|
||||
<secondary>package information</secondary>
|
||||
</indexterm>
|
||||
|
||||
<para>
|
||||
Currently, &repmgr; RPM packages are provided for versions 6.x and 7.x of CentOS. These should also
|
||||
work on matching versions of Red Hat Enterprise Linux, Scientific Linux and Oracle Enterprise Linux;
|
||||
@@ -244,12 +237,6 @@
|
||||
<primary>packages</primary>
|
||||
<secondary>Debian/Ubuntu packages</secondary>
|
||||
</indexterm>
|
||||
|
||||
<indexterm>
|
||||
<primary>Debian/Ubuntu</primary>
|
||||
<secondary>package information</secondary>
|
||||
</indexterm>
|
||||
|
||||
<para>
|
||||
&repmgr; <literal>.deb</literal> packages are provided via the
|
||||
PostgreSQL Community APT repository, and are available for each community-supported
|
||||
|
||||
@@ -15,136 +15,6 @@
|
||||
See also: <xref linkend="upgrading-repmgr">
|
||||
</para>
|
||||
|
||||
<sect1 id="release-4.2">
|
||||
<title>Release 4.2</title>
|
||||
<para><emphasis>???, 2018</emphasis></para>
|
||||
<para>
|
||||
</para>
|
||||
|
||||
<sect2>
|
||||
<title>Configuration file changes</title>
|
||||
<para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
New parameter <varname>shutdown_check_timeout</varname> (default: 60 seconds) added;
|
||||
this provides an explicit timeout for
|
||||
<command><link linkend="repmgr-standby-switchover">repmgr standby switchover</link></command>
|
||||
to check that the demotion candidate (current primary) has shut down. Previously, the parameters
|
||||
<literal>reconnect_attempts</literal> and <literal>reconnect_interval</literal>
|
||||
were used to calculate a timeout, but these are actually
|
||||
intended for primary failure detection. (GitHub #504).
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
New parameter <varname>repmgr_bindir</varname> added, to facilitate remote invocation of repmgr
|
||||
when the repmgr binary is located somewhere other than the PostgreSQL binary directory, as it
|
||||
cannot be assumed all package maintainers will install &repmgr; there.
|
||||
</para>
|
||||
<para>
|
||||
This parameter is optional; if not set (the default), &repmgr; will fall back
|
||||
to <option>pg_bindir</option> (if set).
|
||||
</para>
|
||||
<para>
|
||||
(GitHub #246).
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
<title>repmgr enhancements</title>
|
||||
<para>
|
||||
<itemizedlist>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
<command><link linkend="repmgr-cluster-cleanup">repmgr cluster cleanup</link></command>
|
||||
now accepts the <option>--node-id</option> option to delete records for only one
|
||||
node. (GitHub #493).
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
When running
|
||||
<command><link linkend="repmgr-cluster-matrix">repmgr cluster matrix</link></command> and
|
||||
<command><link linkend="repmgr-cluster-crosscheck">repmgr cluster crosscheck</link></command>,
|
||||
&repmgr; will report nodes unreachable via SSH, and emit return code <literal>ERR_BAD_SSH</literal>.
|
||||
(GitHub #246).
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
Users relying on
|
||||
<command><link linkend="repmgr-cluster-crosscheck">repmgr cluster crosscheck</link></command>
|
||||
to return a non-zero return code as a way of detecting connectivity errors should be aware
|
||||
that <literal>ERR_BAD_SSH</literal> will be returned if there is an SSH connection error
|
||||
from the node where the command is executed, even if the command is able to establish
|
||||
that PostgreSQL connectivity is fine. Therefore the exact return code should be checked
|
||||
to determine what kind of connectivity error has been detected.
|
||||
</para>
|
||||
</note>
|
||||
</listitem>
|
||||
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
|
||||
<sect2>
|
||||
<title>repmgrd enhancements</title>
|
||||
<para>
|
||||
<itemizedlist>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
<application>repmgrd</application> can now be "paused", i.e. instructed
|
||||
not to take any action such as a failover, even if the prerequisites for such an
|
||||
action are detected.
|
||||
</para>
|
||||
<para>
|
||||
This removes the need to stop <application>repmgrd</application> on all nodes when
|
||||
performing a planned operation such as a switchover.
|
||||
</para>
|
||||
<para>
|
||||
For further details, see <link linkend="repmgrd-pausing">Pausing repmgrd</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
<title>Bug fixes</title>
|
||||
<para>
|
||||
<itemizedlist>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
&repmgr;: fix "Missing replication slots" label in
|
||||
<command><link linkend="repmgr-node-check">repmgr node check</link></command>. (GitHub #507)
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
<application>repmgrd</application>: fix parsing of <option>-d/--daemonize</option> option.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="release-4.1.1">
|
||||
<title>Release 4.1.1</title>
|
||||
<para><emphasis>Wed September 5, 2018</emphasis></para>
|
||||
@@ -163,9 +33,10 @@
|
||||
<para>
|
||||
<itemizedlist>
|
||||
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
<command><link linkend="repmgr-standby-switchover">repmgr standby switchover --dry-run</link></command>
|
||||
<command><link linkend="repmgr-standby-clone">repmgr standby switchover --dry-run</link></command>
|
||||
no longer copies external configuration files to test they can be copied; this avoids making
|
||||
any changes to the target system. (GitHub #491).
|
||||
</para>
|
||||
@@ -174,7 +45,7 @@
|
||||
<listitem>
|
||||
<para>
|
||||
<command><link linkend="repmgr-cluster-cleanup">repmgr cluster cleanup</link></command>:
|
||||
add <literal>cluster_cleanup</literal> event. (GitHub #492).
|
||||
add <literal>cluster_cleanup</literal> event. (GitHub #492)
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
|
||||
@@ -352,12 +352,10 @@
|
||||
provide additional parameters for <command>pg_basebackup</command> to customise the
|
||||
cloning process.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
By default, <command>pg_basebackup</command> performs a checkpoint before beginning the backup
|
||||
process. However, a normal checkpoint may take some time to complete;
|
||||
a fast checkpoint can be forced with <command><link linkend="repmgr-standby-clone">repmgr standby clone</link></command>'s
|
||||
<literal>-c/--fast-checkpoint</literal> option.
|
||||
a fast checkpoint can be forced with the <literal>-c/--fast-checkpoint</literal> option.
|
||||
Note that this may impact performance of the server being cloned from (typically the primary)
|
||||
so should be used with care.
|
||||
</para>
|
||||
@@ -372,18 +370,6 @@
|
||||
Other options can be passed to <command>pg_basebackup</command> by including them
|
||||
in the <filename>repmgr.conf</filename> setting <varname>pg_basebackup_options</varname>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Not that by default, &repmgr; executes <command>pg_basebackup</command> with <option>-X/--wal-method</option>
|
||||
(PostgreSQL 9.6 and earlier: <option>-X/--xlog-method</option>) set to <literal>stream</literal>.
|
||||
From PostgreSQL 9.6, if replication slots are in use, it will also create a replication slot before
|
||||
running the base backup, and execute <command>pg_basebackup</command> with the
|
||||
<option>-S/--slot</option> option set to the name of the previously created replication slot.
|
||||
</para>
|
||||
<para>
|
||||
These parameters can set by the user in <varname>pg_basebackup_options</varname>, in which case they
|
||||
will override the &repmgr; default values. However normally there's no reason to do this.
|
||||
</para>
|
||||
<para>
|
||||
If using a separate directory to store WAL files, provide the option <literal>--waldir</literal>
|
||||
(<literal>--xlogdir</literal> in PostgreSQL 9.6 and earlier) with the absolute path to the
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
<link linkend="repmgr-node-rejoin"><command>repmgr node rejoin</command></link>.
|
||||
</para>
|
||||
<para>
|
||||
By default, &repmgr; will use PostgreSQL's <command>pg_ctl</command> utility to control the PostgreSQL
|
||||
By default, &repmgr; will use PostgreSQL's <command>pg_ctl</command> to control the PostgreSQL
|
||||
server. However this can lead to various problems, particularly when PostgreSQL has been
|
||||
installed from packages, and especially so if <application>systemd</application> is in use.
|
||||
installed from packages, and expecially so if <application>systemd</application> is in use.
|
||||
</para>
|
||||
|
||||
|
||||
<note>
|
||||
<para>
|
||||
If using <application>systemd</application>, ensure you have <varname>RemoveIPC</varname> set to <literal>off</literal>.
|
||||
If using <application>systemd</application>, ensure you have <varname>RemoteIPC</varname> set to <literal>off</literal>.
|
||||
See the <ulink url="https://wiki.postgresql.org/wiki/Systemd">systemd</ulink>
|
||||
entry in the <ulink url="https://wiki.postgresql.org/wiki/Main_Page">PostgreSQL wiki</ulink> for details.
|
||||
</para>
|
||||
@@ -99,7 +99,7 @@
|
||||
Defaults:postgres !requiretty
|
||||
postgres ALL = NOPASSWD: /usr/bin/systemctl stop postgresql-9.6, \
|
||||
/usr/bin/systemctl start postgresql-9.6, \
|
||||
/usr/bin/systemctl restart postgresql-9.6, \
|
||||
/usr/bin/systemctl restart postgresql-9.6 \
|
||||
/usr/bin/systemctl reload postgresql-9.6</programlisting>
|
||||
</para>
|
||||
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
<!ENTITY repmgrd-cascading-replication SYSTEM "repmgrd-cascading-replication.sgml">
|
||||
<!ENTITY repmgrd-network-split SYSTEM "repmgrd-network-split.sgml">
|
||||
<!ENTITY repmgrd-witness-server SYSTEM "repmgrd-witness-server.sgml">
|
||||
<!ENTITY repmgrd-pausing SYSTEM "repmgrd-pausing.sgml">
|
||||
<!ENTITY repmgrd-bdr SYSTEM "repmgrd-bdr.sgml">
|
||||
|
||||
<!ENTITY repmgr-primary-register SYSTEM "repmgr-primary-register.sgml">
|
||||
@@ -79,9 +78,6 @@
|
||||
<!ENTITY repmgr-cluster-crosscheck SYSTEM "repmgr-cluster-crosscheck.sgml">
|
||||
<!ENTITY repmgr-cluster-event SYSTEM "repmgr-cluster-event.sgml">
|
||||
<!ENTITY repmgr-cluster-cleanup SYSTEM "repmgr-cluster-cleanup.sgml">
|
||||
<!ENTITY repmgr-daemon-status SYSTEM "repmgr-daemon-status.sgml">
|
||||
<!ENTITY repmgr-daemon-pause SYSTEM "repmgr-daemon-pause.sgml">
|
||||
<!ENTITY repmgr-daemon-unpause SYSTEM "repmgr-daemon-unpause.sgml">
|
||||
|
||||
<!ENTITY appendix-release-notes SYSTEM "appendix-release-notes.sgml">
|
||||
<!ENTITY appendix-faq SYSTEM "appendix-faq.sgml">
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<title>2ndQuadrant public RPM yum repository</title>
|
||||
|
||||
<para>
|
||||
Beginning with <ulink url="https://repmgr.org/docs/4.1/release-4.0.5.html">repmgr 4.0.5</ulink>,
|
||||
Beginning with <ulink url="https://repmgr.org/docs/4.0/release-4.0.5.html">repmgr 4.0.5</ulink>,
|
||||
<ulink url="https://2ndquadrant.com/">2ndQuadrant</ulink> provides a dedicated <literal>yum</literal>
|
||||
<ulink url="https://dl.2ndquadrant.com/">public repository</ulink> for 2ndQuadrant software,
|
||||
including &repmgr;. We recommend using this for all future &repmgr; releases.
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A dedicated system user for &repmgr; is <emphasis>not</emphasis> required; as many &repmgr; and
|
||||
A dedicated system user for &repmgr; is *not* required; as many &repmgr; and
|
||||
<application>repmgrd</application> actions require direct access to the PostgreSQL data directory,
|
||||
these commands should be executed by the <literal>postgres</literal> user.
|
||||
</para>
|
||||
@@ -61,13 +61,6 @@
|
||||
</itemizedlist>
|
||||
</para>
|
||||
|
||||
<tip>
|
||||
<simpara>
|
||||
Consider setting <varname>ConnectTimeout</varname> to a low value in your SSH configuration.
|
||||
This will make it faster to detect any SSH connection errors.
|
||||
</simpara>
|
||||
</tip>
|
||||
|
||||
<tip>
|
||||
<simpara>
|
||||
We recommend using a session multiplexer utility such as <command>screen</command> or
|
||||
|
||||
@@ -237,6 +237,13 @@
|
||||
server. See sections <xref linkend="configuration"> and <xref linkend="configuration-file">
|
||||
for further details about <filename>repmgr.conf</filename>.
|
||||
</para>
|
||||
<tip>
|
||||
<simpara>
|
||||
For Debian-based distributions we recommend explictly setting
|
||||
<option>pg_bindir</option> to the directory where <command>pg_ctl</command> and other binaries
|
||||
not in the standard path are located. For PostgreSQL 9.6 this would be <filename>/usr/lib/postgresql/9.6/bin/</filename>.
|
||||
</simpara>
|
||||
</tip>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
@@ -255,24 +262,6 @@
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<tip>
|
||||
<simpara>
|
||||
For Debian-based distributions we recommend explictly setting
|
||||
<option>pg_bindir</option> to the directory where <command>pg_ctl</command> and other binaries
|
||||
not in the standard path are located. For PostgreSQL 9.6 this would be <filename>/usr/lib/postgresql/9.6/bin/</filename>.
|
||||
</simpara>
|
||||
</tip>
|
||||
|
||||
<tip>
|
||||
<simpara>
|
||||
If your distribution places the &repmgr; binaries in a location other than the
|
||||
PostgreSQL installation directory, specify this with <option>repmgr_bindir</option>
|
||||
to enable &repmgr; to perform operations (e.g.
|
||||
<command><link linkend="repmgr-cluster-crosscheck">repmgr cluster crosscheck</link></command>)
|
||||
on other nodes.
|
||||
</simpara>
|
||||
</tip>
|
||||
|
||||
<para>
|
||||
See the file
|
||||
<ulink url="https://raw.githubusercontent.com/2ndQuadrant/repmgr/master/repmgr.conf.sample">repmgr.conf.sample</>
|
||||
|
||||
@@ -51,20 +51,6 @@
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Options</title>
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--node-id</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Only delete monitoring records for the specified node.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>See also</title>
|
||||
|
||||
@@ -55,37 +55,12 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>ERR_BAD_SSH (12)</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
One or more nodes could not be accessed via SSH.
|
||||
</para>
|
||||
<note>
|
||||
<simpara>
|
||||
This only applies to nodes unreachable from the node where
|
||||
this command is executed.
|
||||
</simpara>
|
||||
<simpara>
|
||||
It's also possible that the crosscheck establishes that
|
||||
connections between PostgreSQL on all nodes are functioning,
|
||||
even if SSH access between some nodes is not possible.
|
||||
</simpara>
|
||||
</note>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>ERR_NODE_STATUS (25)</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
PostgreSQL on one or more nodes could not be reached.
|
||||
One or more nodes could not be reached.
|
||||
</para>
|
||||
<note>
|
||||
<simpara>
|
||||
This error code overrides <option>ERR_BAD_SSH</option>.
|
||||
</simpara>
|
||||
</note>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
@@ -115,26 +115,12 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>ERR_BAD_SSH (12)</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
One or more nodes could not be accessed via SSH.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>ERR_NODE_STATUS (25)</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
PostgreSQL on one or more nodes could not be reached.
|
||||
One or more nodes could not be reached.
|
||||
</para>
|
||||
<note>
|
||||
<simpara>
|
||||
This error code overrides <option>ERR_BAD_SSH</option>.
|
||||
</simpara>
|
||||
</note>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
@@ -81,56 +81,36 @@
|
||||
|
||||
<refsect1>
|
||||
<title>Options</title>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--csv</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
<command>repmgr cluster show</command> accepts an optional parameter <literal>--csv</literal>, which
|
||||
outputs the replication cluster's status in a simple CSV format, suitable for
|
||||
parsing by scripts, e.g.:
|
||||
<programlisting>
|
||||
<para>
|
||||
<command>repmgr cluster show</command> accepts an optional parameter <literal>--csv</literal>, which
|
||||
outputs the replication cluster's status in a simple CSV format, suitable for
|
||||
parsing by scripts:
|
||||
<programlisting>
|
||||
$ repmgr -f /etc/repmgr.conf cluster show --csv
|
||||
1,-1,-1
|
||||
2,0,0
|
||||
3,0,1</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
The columns have following meanings:
|
||||
<itemizedlist spacing="compact" mark="bullet">
|
||||
<listitem>
|
||||
<simpara>
|
||||
node ID
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
availability (0 = available, -1 = unavailable)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
recovery state (0 = not in recovery, 1 = in recovery, -1 = unknown)
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--verbose</option></term>
|
||||
</para>
|
||||
<para>
|
||||
The columns have following meanings:
|
||||
<itemizedlist spacing="compact" mark="bullet">
|
||||
<listitem>
|
||||
<para>
|
||||
Display the full text of any database connection error messages
|
||||
</para>
|
||||
<simpara>
|
||||
node ID
|
||||
</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
availability (0 = available, -1 = unavailable)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
recovery state (0 = not in recovery, 1 = in recovery, -1 = unknown)
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
|
||||
@@ -165,7 +145,7 @@
|
||||
<refsect1>
|
||||
<title>See also</title>
|
||||
<para>
|
||||
<xref linkend="repmgr-node-status">, <xref linkend="repmgr-node-check">, <xref linkend="repmgr-daemon-status">
|
||||
<xref linkend="repmgr-node-status">, <xref linkend="repmgr-node-check">
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
<refentry id="repmgr-daemon-pause">
|
||||
<indexterm>
|
||||
<primary>repmgr daemon pause</primary>
|
||||
</indexterm>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>repmgr daemon pause</refentrytitle>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>repmgr daemon pause</refname>
|
||||
<refpurpose>Instruct all <application>repmgrd</application> instances in the replication cluster to pause failover operations</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<para>
|
||||
This command can be run on any active node in the replication cluster to instruct all
|
||||
running <application>repmgrd</application> instances to "pause" themselves, i.e. take no
|
||||
action (such as promoting themselves or following a new primary) if a failover event is detected.
|
||||
</para>
|
||||
<para>
|
||||
This functionality is useful for performing maintenance operations, such as switchovers
|
||||
or upgrades, which might otherwise trigger a failover if <application>repmgrd</application>
|
||||
is running normally.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
It's important to wait a few seconds after restarting PostgreSQL on any node before running
|
||||
<command>repmgr daemon pause</command>, as the <application>repmgrd</application> instance
|
||||
on the restarted node will take a second or two before it has updated its status.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
<xref linkend="repmgr-daemon-unpause"> will instruct all previously paused <application>repmgrd</application>
|
||||
instances to resume normal failover operation.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Execution</title>
|
||||
<para>
|
||||
<command>repmgr daemon pause</command> can be executed on any active node in the
|
||||
replication cluster. A valid <filename>repmgr.conf</filename> file is required.
|
||||
It will have no effect on previously paused nodes.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Example</title>
|
||||
<para>
|
||||
<programlisting>
|
||||
$ repmgr -f /etc/repmgr.conf daemon pause
|
||||
NOTICE: node 1 (node1) paused
|
||||
NOTICE: node 2 (node2) paused
|
||||
NOTICE: node 3 (node3) paused</programlisting>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Options</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>--dry-run</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Check if nodes are reachable but don't pause <application>repmgrd</application>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Exit codes</title>
|
||||
<para>
|
||||
Following exit codes can be emitted by <command>repmgr daemon unpause</command>:
|
||||
</para>
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>SUCCESS (0)</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
<application>repmgrd</application> could be paused on all nodes.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>ERR_REPMGRD_PAUSE (26)</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
<application>repmgrd</application> could not be paused on one or mode nodes.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>See also</title>
|
||||
<para>
|
||||
<xref linkend="repmgr-daemon-unpause">, <xref linkend="repmgr-daemon-status">
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
<refentry id="repmgr-daemon-status">
|
||||
<indexterm>
|
||||
<primary>repmgr daemon status</primary>
|
||||
</indexterm>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>repmgr daemon status</refentrytitle>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>repmgr daemon status</refname>
|
||||
<refpurpose>display information about the status of <application>repmgrd</application> on each node in the cluster</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<para>
|
||||
This command provides an overview over all active nodes in the cluster and the state
|
||||
of each node's <application>repmgrd</application> instance. It can be used to check
|
||||
the result of <xref linkend="repmgr-daemon-pause"> and <xref linkend="repmgr-daemon-unpause">
|
||||
operations.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Execution</title>
|
||||
<para>
|
||||
<command>repmgr daemon status</command> can be executed on any active node in the
|
||||
replication cluster. A valid <filename>repmgr.conf</filename> file is required.
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
After restarting PostgreSQL on any node, the <application>repmgrd</application> instance
|
||||
will take a second or two before it is able to update its status. Until then,
|
||||
<application>repmgrd</application> will be shown as not running.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Examples</title>
|
||||
<para>
|
||||
<application>repmgrd</application> running normally on all nodes:
|
||||
<programlisting>$ repmgr -f /etc/repmgr.conf daemon status
|
||||
ID | Name | Role | Status | repmgrd | PID | Paused?
|
||||
----+-------+---------+---------+---------+------+---------
|
||||
1 | node1 | primary | running | running | 7851 | no
|
||||
2 | node2 | standby | running | running | 7889 | no
|
||||
3 | node3 | standby | running | running | 7918 | no</programlisting>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<application>repmgrd</application> paused on all nodes (using <xref linkend="repmgr-daemon-pause">):
|
||||
<programlisting>$ repmgr -f /etc/repmgr.conf daemon status
|
||||
ID | Name | Role | Status | repmgrd | PID | Paused?
|
||||
----+-------+---------+---------+---------+------+---------
|
||||
1 | node1 | primary | running | running | 7851 | yes
|
||||
2 | node2 | standby | running | running | 7889 | yes
|
||||
3 | node3 | standby | running | running | 7918 | yes</programlisting>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<application>repmgrd</application> not running on one node:
|
||||
<programlisting>$ repmgr -f /etc/repmgr.conf daemon status
|
||||
ID | Name | Role | Status | repmgrd | PID | Paused?
|
||||
----+-------+---------+---------+-------------+------+---------
|
||||
1 | node1 | primary | running | running | 7851 | yes
|
||||
2 | node2 | standby | running | not running | n/a | n/a
|
||||
3 | node3 | standby | running | running | 7918 | yes</programlisting>
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Options</title>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--csv</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
<command>repmgr daemon status</command> accepts an optional parameter <literal>--csv</literal>, which
|
||||
outputs the replication cluster's status in a simple CSV format, suitable for
|
||||
parsing by scripts, e.g.:
|
||||
<programlisting>
|
||||
$ repmgr -f /etc/repmgr.conf daemon status --csv
|
||||
1,node1,primary,1,1,10204,1
|
||||
2,node2,standby,1,0,-1,1
|
||||
3,node3,standby,1,1,10225,1</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
The columns have following meanings:
|
||||
<itemizedlist spacing="compact" mark="bullet">
|
||||
<listitem>
|
||||
<simpara>
|
||||
node ID
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
node name
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
node type (primary or standby)
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
PostgreSQL server running
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<application>repmgrd</application> running (1 = running, 0 = not running)
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<application>repmgrd</application> PID (-1 if not running)
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<application>repmgrd</application> paused (1 = paused, 0 = not paused)
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--verbose</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Display the full text of any database connection error messages
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
||||
<refsect1>
|
||||
<title>See also</title>
|
||||
<para>
|
||||
<xref linkend="repmgr-daemon-pause">, <xref linkend="repmgr-daemon-unpause">, <xref linkend="repmgr-cluster-show">
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
@@ -1,103 +0,0 @@
|
||||
<refentry id="repmgr-daemon-unpause">
|
||||
<indexterm>
|
||||
<primary>repmgr daemon unpause</primary>
|
||||
</indexterm>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>repmgr daemon unpause</refentrytitle>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>repmgr daemon unpause</refname>
|
||||
<refpurpose>Instruct all <application>repmgrd</application> instances in the replication cluster to resume failover operations</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<para>
|
||||
This command can be run on any active node in the replication cluster to instruct all
|
||||
running <application>repmgrd</application> instances to "unpause"
|
||||
(following a previous execution of <xref linkend="repmgr-daemon-pause">)
|
||||
and resume normal failover/monitoring operation.
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
It's important to wait a few seconds after restarting PostgreSQL on any node before running
|
||||
<command>repmgr daemon pause</command>, as the <application>repmgrd</application> instance
|
||||
on the restarted node will take a second or two before it has updated its status.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Execution</title>
|
||||
<para>
|
||||
<command>repmgr daemon unpause</command> can be executed on any active node in the
|
||||
replication cluster. A valid <filename>repmgr.conf</filename> file is required.
|
||||
It will have no effect on nodes which are not already paused.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Example</title>
|
||||
<para>
|
||||
<programlisting>
|
||||
$ repmgr -f /etc/repmgr.conf daemon unpause
|
||||
NOTICE: node 1 (node1) unpaused
|
||||
NOTICE: node 2 (node2) unpaused
|
||||
NOTICE: node 3 (node3) unpaused</programlisting>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Options</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>--dry-run</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Check if nodes are reachable but don't unpause <application>repmgrd</application>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Exit codes</title>
|
||||
<para>
|
||||
Following exit codes can be emitted by <command>repmgr daemon unpause</command>:
|
||||
</para>
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>SUCCESS (0)</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
<application>repmgrd</application> could be unpaused on all nodes.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>ERR_REPMGRD_PAUSE (26)</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
<application>repmgrd</application> could not be unpaused on one or mode nodes.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>See also</title>
|
||||
<para>
|
||||
<xref linkend="repmgr-daemon-pause">, <xref linkend="repmgr-daemon-status">
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
Replication lag: OK (N/A - node is primary)
|
||||
WAL archiving: OK (0 pending files)
|
||||
Downstream servers: OK (2 of 2 downstream nodes attached)
|
||||
Replication slots: OK (node has no replication slots)
|
||||
Missing replication slots: OK (node has no missing replication slots)</programlisting>
|
||||
Replication slots: OK (node has no replication slots)</programlisting>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
|
||||
@@ -67,10 +67,10 @@
|
||||
<term><option>--force-rewind[=/path/to/pg_rewind]</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Execute <application>pg_rewind</application>.
|
||||
Execute <application>pg_rewind</application> if necessary.
|
||||
</para>
|
||||
<para>
|
||||
It is only necessary to provide the <application>pg_rewind</application> path
|
||||
It is only necessary to provide the <application>pg_rewind</application>
|
||||
if using PostgreSQL 9.3 or 9.4, and <application>pg_rewind</application>
|
||||
is not installed in the PostgreSQL <filename>bin</filename> directory.
|
||||
</para>
|
||||
@@ -193,7 +193,7 @@
|
||||
</note>
|
||||
|
||||
<para>
|
||||
To have <command>repmgr node rejoin</command> use <command>pg_rewind</command>,
|
||||
To have <command>repmgr node rejoin</command> use <command>pg_rewind</command> if required,
|
||||
pass the command line option <literal>--force-rewind</literal>, which will tell &repmgr;
|
||||
to execute <command>pg_rewind</command> to ensure the node can be rejoined successfully.
|
||||
</para>
|
||||
@@ -226,15 +226,6 @@
|
||||
INFO: pg_rewind would now be executed
|
||||
DETAIL: pg_rewind command is:
|
||||
pg_rewind -D '/var/lib/postgresql/data' --source-server='host=node1 dbname=repmgr user=repmgr'</programlisting>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
If <option>--force-rewind</option> is used with the <option>--dry-run</option> option,
|
||||
this checks the prerequisites for using <application>pg_rewind</application>, but cannot
|
||||
predict the outcome of actually executing <application>pg_rewind</application>.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<programlisting>
|
||||
$ repmgr node rejoin -f /etc/repmgr.conf -d 'host=node1 dbname=repmgr user=repmgr' \
|
||||
--force-rewind --config-files=postgresql.local.conf,postgresql.conf --verbose
|
||||
|
||||
@@ -35,10 +35,6 @@
|
||||
&repmgr; will attempt to check for potential issues but cannot guarantee
|
||||
a successful switchover.
|
||||
</para>
|
||||
<para>
|
||||
&repmgr; will refuse to perform the switchover if an exclusive backup is running on
|
||||
the current primary.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
For more details on performing a switchover, including preparation and configuration,
|
||||
@@ -47,14 +43,11 @@
|
||||
|
||||
<note>
|
||||
<para>
|
||||
From <link linkend="release-4.2">repmgr 4.2</link>, &repmgr; will instruct any running
|
||||
<application>repmgrd</application> instances to pause operations while the switchover
|
||||
is being carried out, to prevent <application>repmgrd</application> from
|
||||
unintentionally promoting a node. For more details, see <xref linkend="repmgrd-pausing">.
|
||||
<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.
|
||||
</para>
|
||||
<para>
|
||||
Users of &repmgr; versions prior to 4.2 should ensure that <application>repmgrd</application>
|
||||
is not running on any nodes while a switchover is being executed.
|
||||
&repmgr; will not perform the switchover if an exclusive backup is running on the current primary.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
@@ -68,9 +61,8 @@
|
||||
<term><option>--always-promote</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Promote standby to primary, even if it is behind or has diverged
|
||||
from the original primary. The original primary will be shut down in any case,
|
||||
and will need to be manually reintegrated into the replication cluster.
|
||||
Promote standby to primary, even if it is behind original primary
|
||||
(original primary will be shut down in any case).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -130,21 +122,6 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--repmgrd-no-pause</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Don't pause <application>repmgrd</application> while executing a switchover.
|
||||
</para>
|
||||
<para>
|
||||
This option should not be used unless you take steps by other means
|
||||
to ensure <application>repmgrd</application> is paused or not
|
||||
running on all nodes.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--siblings-follow</option></term>
|
||||
<listitem>
|
||||
@@ -164,7 +141,19 @@
|
||||
Note that following parameters in <filename>repmgr.conf</filename> are relevant to the
|
||||
switchover operation:
|
||||
<itemizedlist spacing="compact" mark="bullet">
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<literal>reconnect_attempts</literal>: number of times to check the original primary
|
||||
for a clean shutdown after executing the shutdown command, before aborting
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<literal>reconnect_interval</literal>: interval (in seconds) to check the original
|
||||
primary for a clean shutdown after executing the shutdown command (up to a maximum
|
||||
of <literal>reconnect_attempts</literal> tries)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<literal>replication_lag_critical</literal>:
|
||||
@@ -174,29 +163,10 @@
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<literal>shutdown_check_timeout</literal>: maximum number of seconds to wait for the
|
||||
demotion candidate (current primary) to shut down, before aborting the switchover.
|
||||
</simpara>
|
||||
<simpara>
|
||||
Note that this parameter is set on the node where <command>repmgr standby switchover</command>
|
||||
is executed (promotion candidate); setting it on the demotion candidate (former primary) will
|
||||
have no effect.
|
||||
</simpara>
|
||||
<note>
|
||||
<para>
|
||||
In versions prior to <link linkend="release-4.2">&repmgr; 4.2</link>, <command>repmgr standby switchover</command> would
|
||||
use the values defined in <literal>reconnect_attempts</literal> and <literal>reconnect_interval</literal>
|
||||
to determine the timeout for demotion candidate shutdown.
|
||||
</para>
|
||||
</note>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<literal>standby_reconnect_timeout</literal>:
|
||||
maximum number of seconds to attempt to wait for the demotion candidate (former primary)
|
||||
number of seconds to attempt to wait for the demoted primary
|
||||
to reconnect to the promoted primary (default: 60 seconds)
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
@@ -86,7 +86,6 @@
|
||||
&repmgrd-cascading-replication;
|
||||
&repmgrd-network-split;
|
||||
&repmgrd-witness-server;
|
||||
&repmgrd-pausing;
|
||||
&repmgrd-degraded-monitoring;
|
||||
&repmgrd-monitoring;
|
||||
&repmgrd-bdr;
|
||||
@@ -113,9 +112,6 @@
|
||||
&repmgr-cluster-crosscheck;
|
||||
&repmgr-cluster-event;
|
||||
&repmgr-cluster-cleanup;
|
||||
&repmgr-daemon-status;
|
||||
&repmgr-daemon-pause;
|
||||
&repmgr-daemon-unpause;
|
||||
</part>
|
||||
|
||||
&appendix-release-notes;
|
||||
|
||||
@@ -34,6 +34,24 @@
|
||||
the <ulink url="https://www.postgresql.org/docs/current/static/runtime-config-client.html#GUC-SHARED-PRELOAD-LIBRARIES">PostgreSQL documentation</ulink>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To apply configuration file changes to a running <application>repmgrd</application>
|
||||
daemon, execute the operating system's r<application>repmgrd</application> service reload command
|
||||
(see <xref linkend="appendix-packages"> for examples),
|
||||
or for instances which were manually started, execute <command>kill -HUP</command>, e.g.
|
||||
<command>kill -HUP `cat /tmp/repmgrd.pid`</command>.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
Check the <application>repmgrd</application> log to see what changes were
|
||||
applied, or if any issues were encountered when reloading the configuration.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
Note that only a subset of configuration file parameters can be changed on a
|
||||
running <application>repmgrd</application> daemon.
|
||||
</para>
|
||||
|
||||
|
||||
<sect2 id="repmgrd-automatic-failover-configuration">
|
||||
<title>automatic failover configuration</title>
|
||||
@@ -149,203 +167,6 @@
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="repmgrd-reloading-configuration"xreflabel="reloading repmgrd configuration">
|
||||
<indexterm>
|
||||
<primary>repmgrd</primary>
|
||||
<secondary>applying configuration changes</secondary>
|
||||
</indexterm>
|
||||
<title>Applying configuration changes to repmgrd</title>
|
||||
<para>
|
||||
To apply configuration file changes to a running <application>repmgrd</application>
|
||||
daemon, execute the operating system's <application>repmgrd</application> service reload command
|
||||
(see <xref linkend="appendix-packages"> for examples),
|
||||
or for instances which were manually started, execute <command>kill -HUP</command>, e.g.
|
||||
<command>kill -HUP `cat /tmp/repmgrd.pid`</command>.
|
||||
</para>
|
||||
<tip>
|
||||
<para>
|
||||
Check the <application>repmgrd</application> log to see what changes were
|
||||
applied, or if any issues were encountered when reloading the configuration.
|
||||
</para>
|
||||
</tip>
|
||||
<para>
|
||||
Note that only the following subset of configuration file parameters can be changed on a
|
||||
running <application>repmgrd</application> daemon:
|
||||
</para>
|
||||
<itemizedlist spacing="compact" mark="bullet">
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>async_query_timeout</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>bdr_local_monitoring_only</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>bdr_recovery_timeout</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>conninfo</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>degraded_monitoring_timeout</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>event_notification_command</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>event_notifications</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>failover</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>follow_command</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>log_facility</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>log_file</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>log_level</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>log_status_interval</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>monitor_interval_secs</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>monitoring_history</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>primary_notification_timeout</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>promote_command</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>reconnect_attempts</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>reconnect_interval</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>repmgrd_standby_startup_timeout</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
The following set of configuration file parameters must be updated via
|
||||
<command><link linkend="repmgr-standby-register">repmgr standby register --force</link></command>,
|
||||
as they require changes to the <literal>repmgr.nodes</literal> table so they are visible to
|
||||
all nodes in the replication cluster:
|
||||
</para>
|
||||
<itemizedlist spacing="compact" mark="bullet">
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>node_id</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>node_name</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>data_directory</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>location</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>priority</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
</itemizedlist>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
After executing <command><link linkend="repmgr-standby-register">repmgr standby register --force</link></command>,
|
||||
<application>repmgrd</application> <emphasis>must</emphasis> be restarted for the changes to take effect.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="repmgrd-daemon">
|
||||
@@ -454,7 +275,7 @@ REPMGRD_ENABLED=no
|
||||
#REPMGRD_CONF="/path/to/repmgr.conf"
|
||||
|
||||
# additional options
|
||||
REPMGRD_OPTS="--daemonize=false"
|
||||
#REPMGRD_OPTS=""
|
||||
|
||||
# user to run repmgrd as
|
||||
#REPMGRD_USER=postgres
|
||||
@@ -469,19 +290,6 @@ REPMGRD_OPTS="--daemonize=false"
|
||||
Set <varname>REPMGRD_ENABLED</varname> to <literal>yes</literal>, and <varname>REPMGRD_CONF</varname>
|
||||
to the <filename>repmgr.conf</filename> file you are using.
|
||||
</para>
|
||||
<tip>
|
||||
<para>
|
||||
See <xref linkend="packages-debian-ubuntu"> for details of the Debian/Ubuntu packages and
|
||||
typical file locations (including <filename>repmgr.conf</filename>).
|
||||
</para>
|
||||
</tip>
|
||||
<para>
|
||||
From <application>repmgrd</application> 4.1, ensure <varname>REPMGRD_OPTS</varname> includes
|
||||
<option>--daemonize=false</option>, as daemonization is handled by the service command.
|
||||
We recommend setting <varname>repmgrd_pid_file</varname> in <filename>repmgr.conf</filename> to the
|
||||
same value set in <varname>REPMGRD_PIDFILE</varname> to prevent another <application>repmgrd</application>
|
||||
instance from being started manually.
|
||||
</para>
|
||||
<para>
|
||||
If using <application>systemd</application>, you may need to execute <command>systemctl daemon-reload</command>.
|
||||
Also, if you attempted to start <application>repmgrd</application> using <command>systemctl start repmgrd</command>,
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
<chapter id="repmgrd-pausing" xreflabel="Pausing repmgrd">
|
||||
|
||||
<indexterm>
|
||||
<primary>repmgrd</primary>
|
||||
<secondary>pausing</secondary>
|
||||
</indexterm>
|
||||
|
||||
<indexterm>
|
||||
<primary>pausing repmgrd</primary>
|
||||
</indexterm>
|
||||
|
||||
<title>Pausing repmgrd</title>
|
||||
|
||||
<para>
|
||||
In normal operation, <application>repmgrd</application> monitors the state of the
|
||||
PostgreSQL node it is running on, and will take appropriate action if problems
|
||||
are detected, e.g. (if so configured) promote the node to primary, if the existing
|
||||
primary has been determined as failed.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
However, <application>repmgrd</application> is unable to distinguish between
|
||||
planned outages (such as performing a <link linkend="performing-switchover">switchover</link>
|
||||
or upgrading a server), and an actual server outage. In versions prior to &repmgr; 4.2
|
||||
it was necessary to stop <application>repmgrd</application> on all nodes (or at least
|
||||
on all nodes where <application>repmgrd</application> is
|
||||
<link linkend="repmgrd-automatic-failover">configured for automatic failover</link>)
|
||||
to prevent <application>repmgrd</application> from making changes to the
|
||||
replication cluster.
|
||||
</para>
|
||||
<para>
|
||||
From <link linkend="release-4.2">&repmgr; 4.2</link>, <application>repmgrd</application>
|
||||
can now be "paused", i.e. instructed not to take any action such as performing a failover.
|
||||
This can be done from any node in the cluster, removing the need to stop/restart
|
||||
each <application>repmgrd</application> individually.
|
||||
</para>
|
||||
|
||||
<sect1 id="repmgrd-pausing-prerequisites">
|
||||
<title>Prerequisites for pausing <application>repmgrd</application></title>
|
||||
<para>
|
||||
In order to be able to pause/unpause <application>repmgrd</application>, following
|
||||
prerequisites must be met:
|
||||
<itemizedlist spacing="compact" mark="bullet">
|
||||
|
||||
<listitem>
|
||||
<simpara><link linkend="release-4.2">&repmgr; 4.2</link> or later must be installed on all nodes.</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>The same major &repmgr; version (e.g. 4.2) must be installed on all nodes (and preferably the same minor version).</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
PostgreSQL on all nodes must be accessible from the node where the
|
||||
<literal>pause</literal>/<literal>unpause</literal> operation is executed, using the
|
||||
<varname>conninfo</varname> string shown by <link linkend="repmgr-cluster-show"><command>repmgr cluster show</command></link>.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
These conditions are required for normal &repmgr; operation in any case.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="repmgrd-pausing-execution">
|
||||
<title>Pausing/unpausing <application>repmgrd</application></title>
|
||||
<para>
|
||||
To pause <application>repmgrd</application>, execute <link linkend="repmgr-daemon-pause"><command>repmgr daemon pause</command></link>, e.g.:
|
||||
<programlisting>
|
||||
$ repmgr -f /etc/repmgr.conf daemon pause
|
||||
NOTICE: node 1 (node1) paused
|
||||
NOTICE: node 2 (node2) paused
|
||||
NOTICE: node 3 (node3) paused</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
The state of <application>repmgrd</application> on each node can be checked with
|
||||
<link linkend="repmgr-daemon-status"><command>repmgr daemon status</command></link>, e.g.:
|
||||
<programlisting>$ repmgr -f /etc/repmgr.conf daemon status
|
||||
ID | Name | Role | Status | repmgrd | PID | Paused?
|
||||
----+-------+---------+---------+---------+------+---------
|
||||
1 | node1 | primary | running | running | 7851 | yes
|
||||
2 | node2 | standby | running | running | 7889 | yes
|
||||
3 | node3 | standby | running | running | 7918 | yes</programlisting>
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
If executing a switchover with <link linkend="repmgr-standby-switchover"><command>repmgr standby switchover</command></link>,
|
||||
&repmgr; will automatically pause/unpause <application>repmgrd</application> as part of the switchover process.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<para>
|
||||
If the primary (in this example, <literal>node1</literal>) is stopped, <application>repmgrd</application>
|
||||
running on one of the standbys (here: <literal>node2</literal>) will react like this:
|
||||
<programlisting>
|
||||
[2018-09-20 12:22:21] [WARNING] unable to connect to upstream node "node1" (node ID: 1)
|
||||
[2018-09-20 12:22:21] [INFO] checking state of node 1, 1 of 5 attempts
|
||||
[2018-09-20 12:22:21] [INFO] sleeping 1 seconds until next reconnection attempt
|
||||
...
|
||||
[2018-09-20 12:22:24] [INFO] sleeping 1 seconds until next reconnection attempt
|
||||
[2018-09-20 12:22:25] [INFO] checking state of node 1, 5 of 5 attempts
|
||||
[2018-09-20 12:22:25] [WARNING] unable to reconnect to node 1 after 5 attempts
|
||||
[2018-09-20 12:22:25] [NOTICE] node is paused
|
||||
[2018-09-20 12:22:33] [INFO] node "node2" (node ID: 2) monitoring upstream node "node1" (node ID: 1) in degraded state
|
||||
[2018-09-20 12:22:33] [DETAIL] repmgrd paused by administrator
|
||||
[2018-09-20 12:22:33] [HINT] execute "repmgr daemon unpause" to resume normal failover mode</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
If the primary becomes available again (e.g. following a software upgrade), <application>repmgrd</application>
|
||||
will automatically reconnect, e.g.:
|
||||
<programlisting>
|
||||
[2018-09-20 13:12:41] [NOTICE] reconnected to upstream node 1 after 8 seconds, resuming monitoring</programlisting>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To unpause <application>repmgrd</application>, execute <link linkend="repmgr-daemon-unpause"><command>repmgr daemon unpause</command></link>, e.g.:
|
||||
<programlisting>
|
||||
$ repmgr -f /etc/repmgr.conf daemon pause
|
||||
NOTICE: node 1 (node1) unpaused
|
||||
NOTICE: node 2 (node2) unpaused
|
||||
NOTICE: node 3 (node3) unpaused</programlisting>
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
If the previous primary is no longer accessible when <application>repmgrd</application>
|
||||
is unpaused, no failover action will be taken. Instead, a new primary must be manually promoted using
|
||||
<link linkend="repmgr-standby-promote"><command>repmgr standby promote</command></link>,
|
||||
and any standbys attached to the new primary with
|
||||
<link linkend="repmgr-standby-follow"><command>repmgr standby follow</command></link>.
|
||||
</para>
|
||||
<para>
|
||||
This is to prevent <link linkend="repmgr-daemon-unpause"><command>repmgr daemon unpause</command></link>
|
||||
resulting in the automatic promotion of a new primary, which may be a problem particularly
|
||||
in larger clusters, where <application>repmgrd</application> could select a different promotion
|
||||
candidate to the one intended by the administrator.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<sect2 id="repmgrd-pausing-details">
|
||||
<title>Details on the <application>repmgrd</application> pausing mechanism</title>
|
||||
|
||||
<para>
|
||||
The pause state of each node will be stored over a PostgreSQL restart.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<link linkend="repmgr-daemon-pause"><command>repmgr daemon pause</command></link> and
|
||||
<link linkend="repmgr-daemon-unpause"><command>repmgr daemon unpause</command></link> can be
|
||||
executed even if <application>repmgrd</application> is not running; in this case,
|
||||
<application>repmgrd</application> will start up in whichever pause state has been set.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
<link linkend="repmgr-daemon-pause"><command>repmgr daemon pause</command></link> and
|
||||
<link linkend="repmgr-daemon-unpause"><command>repmgr daemon unpause</command></link>
|
||||
<emphasis>do not</emphasis> stop/start <application>repmgrd</application>.
|
||||
</para>
|
||||
</note>
|
||||
</sect2>
|
||||
</sect1>
|
||||
</chapter>
|
||||
|
||||
@@ -19,10 +19,9 @@
|
||||
</para>
|
||||
<para>
|
||||
<command>repmgr standby switchover</command> differs from other &repmgr;
|
||||
actions in that it also performs actions on other servers (the demotion
|
||||
candidate, and optionally any other servers which are to follow the new primary),
|
||||
which means passwordless SSH access is required to those servers from the one where
|
||||
<command>repmgr standby switchover</command> is executed.
|
||||
actions in that it also performs actions on another server (the demotion
|
||||
candidate), which means passwordless SSH access is required to that server
|
||||
from the one where <command>repmgr standby switchover</command> is executed.
|
||||
</para>
|
||||
<note>
|
||||
<simpara>
|
||||
@@ -154,18 +153,12 @@
|
||||
manually with <command>repmgr node check --archive-ready</command>.
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
From <link linkend="release-4.2">repmgr 4.2</link>, &repmgr; will instruct any running
|
||||
<application>repmgrd</application> instances to pause operations while the switchover
|
||||
is being carried out, to prevent <application>repmgrd</application> from
|
||||
unintentionally promoting a node. For more details, see <xref linkend="repmgrd-pausing">.
|
||||
</para>
|
||||
<para>
|
||||
Users of &repmgr; versions prior to 4.2 should ensure that <application>repmgrd</application>
|
||||
is not running on any nodes while a switchover is being executed.
|
||||
</para>
|
||||
</note>
|
||||
<note>
|
||||
<para>
|
||||
Ensure that <application>repmgrd</application> is *not* running anywhere to prevent it unintentionally
|
||||
promoting a node. This restriction will be removed in a future &repmgr; version.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
|
||||
<para>
|
||||
@@ -310,21 +303,7 @@
|
||||
2 | node2 | primary | * running | | default | host=node2 dbname=repmgr user=repmgr
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
If <application>repmgrd</application> is in use, it's worth double-checking that
|
||||
all nodes are unpaused by executing <command><link linkend="repmgr-daemon-status">repmgr-daemon-status</link></command>.
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
Users of &repmgr; versions prior to 4.2 will need to manually restart <application>repmgrd</application>
|
||||
on all nodes after the switchover is completed.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</sect1>
|
||||
|
||||
|
||||
<sect1 id="switchover-caveats" xreflabel="Caveats">
|
||||
<indexterm>
|
||||
<primary>switchover</primary>
|
||||
@@ -350,76 +329,17 @@
|
||||
for details.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<application>repmgrd</application> should not be running with setting <varname>failover=automatic</varname>
|
||||
in <filename>repmgr.conf</filename> when a switchover is carried out, otherwise the
|
||||
<application>repmgrd</application> daemon may try and promote a standby by itself.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
We hope to remove some of these restrictions in future versions of &repmgr;.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="switchover-troubleshooting" xreflabel="Troubleshooting">
|
||||
<indexterm>
|
||||
<primary>switchover</primary>
|
||||
<secondary>troubleshooting</secondary>
|
||||
</indexterm>
|
||||
<title>Troubleshooting switchover issues</title>
|
||||
|
||||
<para>
|
||||
As <link linkend="performing-switchover">emphasised previously</link>, performing a switchover
|
||||
is a non-trivial operation and there are a number of potential issues which can occur.
|
||||
While &repmgr; attempts to perform sanity checks, there's no guaranteed way of determining the success of
|
||||
a switchover without actually carrying it out.
|
||||
</para>
|
||||
|
||||
<sect2 id="switchover-troubleshooting-primary-shutdown">
|
||||
<title>Demotion candidate (old primary) does not shut down</title>
|
||||
<para>
|
||||
&repmgr; may abort a switchover with a message like:
|
||||
<programlisting>
|
||||
ERROR: shutdown of the primary server could not be confirmed
|
||||
HINT: check the primary server status before performing any further actions</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
This means the shutdown of the old primary has taken longer than &repmgr; expected,
|
||||
and it has given up waiting.
|
||||
</para>
|
||||
<para>
|
||||
In this case, check the PostgreSQL log on the primary server to see what is going
|
||||
on. It's entirely possible the shutdown process is just taking longer than the
|
||||
timeout set by the configuration parameter <varname>shutdown_check_timeout</varname>
|
||||
(default: 60 seconds), in which case you may need to adjust this parameter.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
Note that <varname>shutdown_check_timeout</varname>is set on the node where
|
||||
<command>repmgr standby switchover</command> is executed (promotion candidate); setting it on the
|
||||
demotion candidate (former primary) will have no effect.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
If the primary server has shut down cleanly, and no other node has been promoted,
|
||||
it is safe to restart it, in which case the replication cluster will be restored
|
||||
to its original configuration.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="switchover-troubleshooting-exclusive-backup">
|
||||
<title>Switchover aborts with an "exclusive backup" error</title>
|
||||
<para>
|
||||
&repmgr; may abort a switchover with a message like:
|
||||
<programlisting>
|
||||
ERROR: unable to perform a switchover while primary server is in exclusive backup mode
|
||||
HINT: stop backup before attempting the switchover</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
This means an exclusive backup is running on the current primary; interrupting this
|
||||
will not only abort the backup, but potentially leave the primary with an ambiguous
|
||||
backup state.
|
||||
</para>
|
||||
<para>
|
||||
To proceed, either wait until the backup has finished, or cancel it with the command
|
||||
<command>SELECT pg_stop_backup()</command>. For more details see the PostgreSQL
|
||||
documentation section
|
||||
<ulink url="https://www.postgresql.org/docs/current/static/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP-EXCLUSIVE">Making an exclusive low level backup</ulink>.
|
||||
</para>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
<title>Upgrading repmgr</title>
|
||||
|
||||
<para>
|
||||
&repmgr; is updated regularly with minor releases (e.g. 4.0.1 to 4.0.2)
|
||||
&repmgr; is updated regularly with point releases (e.g. 4.0.1 to 4.0.2)
|
||||
containing bugfixes and other minor improvements. Any substantial new
|
||||
functionality will be included in a major release (e.g. 4.0 to 4.1).
|
||||
functionality will be included in a feature release (e.g. 4.0.x to 4.1.x).
|
||||
</para>
|
||||
|
||||
<sect1 id="upgrading-repmgr-extension" xreflabel="Upgrading repmgr 4.x and later">
|
||||
@@ -19,201 +19,43 @@
|
||||
</indexterm>
|
||||
<title>Upgrading repmgr 4.x and later</title>
|
||||
<para>
|
||||
From version 4, &repmgr; consists of three elements:
|
||||
<itemizedlist spacing="compact" mark="bullet">
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
the <application>repmgr</application> and <application>repmgrd</application> executables
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
the objects for the &repmgr; PostgreSQL extension (SQL files for creating/updating
|
||||
repmgr metadata, and the extension control file)
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
the shared library module used by <application>repmgrd</application> which
|
||||
is resident in the PostgreSQL backend
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
With <emphasis>minor releases</emphasis>, usually changes are only made to the <application>repmgr</application>
|
||||
and <application>repmgrd</application> executables. In this case, the upgrade is quite straightforward,
|
||||
and is simply a case of installing the new version, and restarting <application>repmgrd</application>
|
||||
(if running).
|
||||
&repmgr; 4.x is implemented as a PostgreSQL extension; normally the upgrade consists
|
||||
of the two following steps:
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
Install the updated package (or compile the updated source)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<application>repmgrd</application> (if running) must be restarted.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
For major releases, e.g. from <literal>4.0.x</literal> to <literal>4.1</literal>,
|
||||
execute <command>ALTER EXTENSION repmgr UPDATE</command>
|
||||
on the primary node in the database where the &repmgr; extension is installed.
|
||||
</simpara>
|
||||
<simpara>
|
||||
This will update the extension metadata and, if necessary, apply
|
||||
changes to the &repmgr; extension objects.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
For <emphasis>major releases</emphasis>, the &repmgr; PostgreSQL extension will need to be updated
|
||||
to the latest version. Additionally, if the shared library module has been updated (this is sometimes,
|
||||
but not always the case), PostgreSQL itself will need to be restarted on each node.
|
||||
Always check the <link linkend="appendix-release-notes">release notes</link> for every
|
||||
release as they may contain upgrade instructions particular to individual versions.
|
||||
</para>
|
||||
<important>
|
||||
<para>
|
||||
Always check the <link linkend="appendix-release-notes">release notes</link> for every
|
||||
release as they may contain upgrade instructions particular to individual versions.
|
||||
</para>
|
||||
</important>
|
||||
|
||||
<sect2 id="upgrading-minor-version" xreflabel="Upgrading a minor version release">
|
||||
<indexterm>
|
||||
<primary>upgrading</primary>
|
||||
<secondary>minor release</secondary>
|
||||
</indexterm>
|
||||
<title>Upgrading a minor version release</title>
|
||||
|
||||
<para>
|
||||
The process for installing minor version upgrades is quite straightforward:
|
||||
|
||||
<itemizedlist spacing="compact" mark="bullet">
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
install the new &repmgr; version
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
restart <application>repmgrd</application> on all nodes where it is running
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
</itemizedlist>
|
||||
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
Some packaging systems (e.g. <link linkend="packages-debian-ubuntu">Debian/Ubuntu</link>
|
||||
may restart <application>repmgrd</application> as part of the package upgrade process.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<para>
|
||||
Minor version upgrades can be performed in any order on the nodes in the replication
|
||||
cluster.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A PostgreSQL restart is <emphasis>not</emphasis> required for minor version upgrades.
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
The same &repmgr; "major version" (e.g. <literal>4.2</literal>) must be
|
||||
installed on all nodes in the replication cluster. While it's possible to have differing
|
||||
&repmgr; "minor versions" (e.g. <literal>4.2.1</literal>) on different nodes,
|
||||
we strongly recommend updating all nodes to the latest minor version.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="upgrading-major-version" xreflabel="Upgrading a major version release">
|
||||
<indexterm>
|
||||
<primary>upgrading</primary>
|
||||
<secondary>major release</secondary>
|
||||
</indexterm>
|
||||
<title>Upgrading a major version release</title>
|
||||
<para>
|
||||
"major version" upgrades need to be planned more carefully, as they may include
|
||||
changes to the &repmgr; metadata (which need to be propagated from the primary to all
|
||||
standbys) and/or changes to the shared object file used by <application>repmgrd</application>
|
||||
(which require a PostgreSQL restart).
|
||||
</para>
|
||||
<para>
|
||||
With this in mind,
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<orderedlist>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
Stop <application>repmgrd</application> (if in use) on all nodes where it is running.
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
Disable the <application>repmgrd</application> service on all nodes where it is in use;
|
||||
this is to prevent packages from prematurely restarting <application>repmgrd</application>.
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
Install the updated package (or compile the updated source) on all nodes.
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
If running a <literal>systemd</literal>-based Linux distribution, execute (as <literal>root</literal>,
|
||||
or with appropriate <literal>sudo</literal> permissions):
|
||||
<programlisting>
|
||||
systemctl daemon-reload</programlisting>
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
If the &repmgr; shared library module has been updated (check the <link linkend="appendix-release-notes">release notes</link>!),
|
||||
restart PostgreSQL, then <application>repmgrd</application> (if in use) on each node,
|
||||
The order in which this is applied to individual nodes is not critical,
|
||||
and it's also fine to restart PostgreSQL on all nodes first before starting <application>repmgrd</application>.
|
||||
</simpara>
|
||||
<simpara>
|
||||
Note that if the upgrade requires a PostgreSQL restart, <application>repmgrd</application>
|
||||
will only function correctly once all nodes have been restarted.
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
On the primary node, execute
|
||||
<programlisting>
|
||||
ALTER EXTENSION repmgr UPDATE</programlisting>
|
||||
in the database where &repmgr; is installed.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<simpara>
|
||||
Reenable the <application>repmgrd</application> service on all nodes where it is in use.
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
</orderedlist>
|
||||
</para>
|
||||
<tip>
|
||||
<para>
|
||||
If the &repmgr; upgrade requires a PostgreSQL restart, combine the &repmgr; upgrade
|
||||
with a PostgreSQL minor version upgrade, which will require a restart in any case.
|
||||
New PostgreSQL minor version are usually released every couple of months.
|
||||
</para>
|
||||
</tip>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="upgrading-check-repmgrd" xreflabel="Checking repmgrd status after an upgrade">
|
||||
<indexterm>
|
||||
<primary>upgrading</primary>
|
||||
<secondary>checking repmgrd status</secondary>
|
||||
</indexterm>
|
||||
<title>Checking repmgrd status after an upgrade</title>
|
||||
<para>
|
||||
From &repmgr; 4.2, once the upgrade is complete, execute the <command><link linkend="repmgr-daemon-status">repmgr daemon status</link></command>
|
||||
command (on any node) to show an overview of the status of <application>repmgrd</application> on all nodes.
|
||||
</para>
|
||||
</sect2>
|
||||
<para>
|
||||
Note that it may be necessary to restart the PostgreSQL server if the upgrade contains
|
||||
changes to the shared object file used by <application>repmgrd</application>; check the
|
||||
release notes for details.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="upgrading-and-pg-upgrade" xreflabel="pg_upgrade and repmgr">
|
||||
@@ -253,13 +95,6 @@ ALTER EXTENSION repmgr UPDATE</programlisting>
|
||||
be recreated by <application>pg_upgrade</application>. These will need to
|
||||
be recreated manually.
|
||||
</para>
|
||||
<tip>
|
||||
<para>
|
||||
Use <command><link linkend="repmgr-node-check">repmgr node check</link></command>
|
||||
to determine which replacation slots need to be recreated.
|
||||
</para>
|
||||
</tip>
|
||||
|
||||
</sect1>
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
<!ENTITY repmgrversion "4.2">
|
||||
<!ENTITY repmgrversion "4.1.1">
|
||||
|
||||
@@ -47,6 +47,5 @@
|
||||
#define ERR_FOLLOW_FAIL 23
|
||||
#define ERR_REJOIN_FAIL 24
|
||||
#define ERR_NODE_STATUS 25
|
||||
#define ERR_REPMGRD_PAUSE 26
|
||||
|
||||
#endif /* _ERRCODE_H_ */
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION repmgr" to load this file. \quit
|
||||
|
||||
CREATE FUNCTION get_repmgrd_pid()
|
||||
RETURNS INT
|
||||
AS 'MODULE_PATHNAME', 'get_repmgrd_pid'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION get_repmgrd_pidfile()
|
||||
RETURNS TEXT
|
||||
AS 'MODULE_PATHNAME', 'get_repmgrd_pidfile'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION set_repmgrd_pid(INT, TEXT)
|
||||
RETURNS VOID
|
||||
AS 'MODULE_PATHNAME', 'set_repmgrd_pid'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION repmgrd_is_running()
|
||||
RETURNS BOOL
|
||||
AS 'MODULE_PATHNAME', 'repmgrd_is_running'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION repmgrd_pause(BOOL)
|
||||
RETURNS VOID
|
||||
AS 'MODULE_PATHNAME', 'repmgrd_pause'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION repmgrd_is_paused()
|
||||
RETURNS BOOL
|
||||
AS 'MODULE_PATHNAME', 'repmgrd_is_paused'
|
||||
LANGUAGE C STRICT;
|
||||
@@ -145,6 +145,7 @@ CREATE FUNCTION unset_bdr_failover_handler()
|
||||
AS 'MODULE_PATHNAME', 'unset_bdr_failover_handler'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
|
||||
CREATE VIEW repmgr.replication_status AS
|
||||
SELECT m.primary_node_id, m.standby_node_id, n.node_name AS standby_name,
|
||||
n.type AS node_type, n.active, last_monitor_time,
|
||||
|
||||
197
repmgr--4.2.sql
197
repmgr--4.2.sql
@@ -1,197 +0,0 @@
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION repmgr" to load this file. \quit
|
||||
|
||||
CREATE TABLE repmgr.nodes (
|
||||
node_id INTEGER PRIMARY KEY,
|
||||
upstream_node_id INTEGER NULL REFERENCES nodes (node_id) DEFERRABLE,
|
||||
active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
node_name TEXT NOT NULL,
|
||||
type TEXT NOT NULL CHECK (type IN('primary','standby','witness','bdr')),
|
||||
location TEXT NOT NULL DEFAULT 'default',
|
||||
priority INT NOT NULL DEFAULT 100,
|
||||
conninfo TEXT NOT NULL,
|
||||
repluser VARCHAR(63) NOT NULL,
|
||||
slot_name TEXT NULL,
|
||||
config_file TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE repmgr.events (
|
||||
node_id INTEGER NOT NULL,
|
||||
event TEXT NOT NULL,
|
||||
successful BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
event_timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
details TEXT NULL
|
||||
);
|
||||
|
||||
DO $repmgr$
|
||||
DECLARE
|
||||
DECLARE server_version_num INT;
|
||||
BEGIN
|
||||
SELECT setting
|
||||
FROM pg_catalog.pg_settings
|
||||
WHERE name = 'server_version_num'
|
||||
INTO server_version_num;
|
||||
IF server_version_num >= 90400 THEN
|
||||
EXECUTE $repmgr_func$
|
||||
CREATE TABLE repmgr.monitoring_history (
|
||||
primary_node_id INTEGER NOT NULL,
|
||||
standby_node_id INTEGER NOT NULL,
|
||||
last_monitor_time TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
last_apply_time TIMESTAMP WITH TIME ZONE,
|
||||
last_wal_primary_location PG_LSN NOT NULL,
|
||||
last_wal_standby_location PG_LSN,
|
||||
replication_lag BIGINT NOT NULL,
|
||||
apply_lag BIGINT NOT NULL
|
||||
)
|
||||
$repmgr_func$;
|
||||
ELSE
|
||||
EXECUTE $repmgr_func$
|
||||
CREATE TABLE repmgr.monitoring_history (
|
||||
primary_node_id INTEGER NOT NULL,
|
||||
standby_node_id INTEGER NOT NULL,
|
||||
last_monitor_time TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
last_apply_time TIMESTAMP WITH TIME ZONE,
|
||||
last_wal_primary_location TEXT NOT NULL,
|
||||
last_wal_standby_location TEXT,
|
||||
replication_lag BIGINT NOT NULL,
|
||||
apply_lag BIGINT NOT NULL
|
||||
)
|
||||
$repmgr_func$;
|
||||
END IF;
|
||||
END$repmgr$;
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_monitoring_history_time
|
||||
ON repmgr.monitoring_history (last_monitor_time, standby_node_id);
|
||||
|
||||
CREATE VIEW repmgr.show_nodes AS
|
||||
SELECT n.node_id,
|
||||
n.node_name,
|
||||
n.active,
|
||||
n.upstream_node_id,
|
||||
un.node_name AS upstream_node_name,
|
||||
n.type,
|
||||
n.priority,
|
||||
n.conninfo
|
||||
FROM repmgr.nodes n
|
||||
LEFT JOIN repmgr.nodes un
|
||||
ON un.node_id = n.upstream_node_id;
|
||||
|
||||
|
||||
/* XXX update upgrade scripts! */
|
||||
CREATE TABLE repmgr.voting_term (
|
||||
term INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX voting_term_restrict
|
||||
ON repmgr.voting_term ((TRUE));
|
||||
|
||||
CREATE RULE voting_term_delete AS
|
||||
ON DELETE TO repmgr.voting_term
|
||||
DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
/* ================= */
|
||||
/* repmgrd functions */
|
||||
/* ================= */
|
||||
|
||||
/* monitoring functions */
|
||||
|
||||
CREATE FUNCTION set_local_node_id(INT)
|
||||
RETURNS VOID
|
||||
AS 'MODULE_PATHNAME', 'set_local_node_id'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION get_local_node_id()
|
||||
RETURNS INT
|
||||
AS 'MODULE_PATHNAME', 'get_local_node_id'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION standby_set_last_updated()
|
||||
RETURNS TIMESTAMP WITH TIME ZONE
|
||||
AS 'MODULE_PATHNAME', 'standby_set_last_updated'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION standby_get_last_updated()
|
||||
RETURNS TIMESTAMP WITH TIME ZONE
|
||||
AS 'MODULE_PATHNAME', 'standby_get_last_updated'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
/* failover functions */
|
||||
|
||||
CREATE FUNCTION notify_follow_primary(INT)
|
||||
RETURNS VOID
|
||||
AS 'MODULE_PATHNAME', 'notify_follow_primary'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION get_new_primary()
|
||||
RETURNS INT
|
||||
AS 'MODULE_PATHNAME', 'get_new_primary'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION reset_voting_status()
|
||||
RETURNS VOID
|
||||
AS 'MODULE_PATHNAME', 'reset_voting_status'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION am_bdr_failover_handler(INT)
|
||||
RETURNS BOOL
|
||||
AS 'MODULE_PATHNAME', 'am_bdr_failover_handler'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION unset_bdr_failover_handler()
|
||||
RETURNS VOID
|
||||
AS 'MODULE_PATHNAME', 'unset_bdr_failover_handler'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION get_repmgrd_pid()
|
||||
RETURNS INT
|
||||
AS 'MODULE_PATHNAME', 'get_repmgrd_pid'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION get_repmgrd_pidfile()
|
||||
RETURNS TEXT
|
||||
AS 'MODULE_PATHNAME', 'get_repmgrd_pidfile'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION set_repmgrd_pid(INT, TEXT)
|
||||
RETURNS VOID
|
||||
AS 'MODULE_PATHNAME', 'set_repmgrd_pid'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION repmgrd_is_running()
|
||||
RETURNS BOOL
|
||||
AS 'MODULE_PATHNAME', 'repmgrd_is_running'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION repmgrd_pause(BOOL)
|
||||
RETURNS VOID
|
||||
AS 'MODULE_PATHNAME', 'repmgrd_pause'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION repmgrd_is_paused()
|
||||
RETURNS BOOL
|
||||
AS 'MODULE_PATHNAME', 'repmgrd_is_paused'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
|
||||
CREATE VIEW repmgr.replication_status AS
|
||||
SELECT m.primary_node_id, m.standby_node_id, n.node_name AS standby_name,
|
||||
n.type AS node_type, n.active, last_monitor_time,
|
||||
CASE WHEN n.type='standby' THEN m.last_wal_primary_location ELSE NULL END AS last_wal_primary_location,
|
||||
m.last_wal_standby_location,
|
||||
CASE WHEN n.type='standby' THEN pg_catalog.pg_size_pretty(m.replication_lag) ELSE NULL END AS replication_lag,
|
||||
CASE WHEN n.type='standby' THEN
|
||||
CASE WHEN replication_lag > 0 THEN age(now(), m.last_apply_time) ELSE '0'::INTERVAL END
|
||||
ELSE NULL
|
||||
END AS replication_time_lag,
|
||||
CASE WHEN n.type='standby' THEN pg_catalog.pg_size_pretty(m.apply_lag) ELSE NULL END AS apply_lag,
|
||||
AGE(NOW(), CASE WHEN pg_catalog.pg_is_in_recovery() THEN repmgr.standby_get_last_updated() ELSE m.last_monitor_time END) AS communication_time_lag
|
||||
FROM repmgr.monitoring_history m
|
||||
JOIN repmgr.nodes n ON m.standby_node_id = n.node_id
|
||||
WHERE (m.standby_node_id, m.last_monitor_time) IN (
|
||||
SELECT m1.standby_node_id, MAX(m1.last_monitor_time)
|
||||
FROM repmgr.monitoring_history m1 GROUP BY 1
|
||||
);
|
||||
|
||||
@@ -191,7 +191,7 @@ do_bdr_register(void)
|
||||
{
|
||||
NodeInfoList local_node_records = T_NODE_INFO_LIST_INITIALIZER;
|
||||
|
||||
(void) get_all_node_records(conn, &local_node_records);
|
||||
get_all_node_records(conn, &local_node_records);
|
||||
|
||||
if (local_node_records.node_count == 0)
|
||||
{
|
||||
@@ -239,7 +239,7 @@ do_bdr_register(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
(void) get_all_node_records(bdr_node_conn, &existing_nodes);
|
||||
get_all_node_records(bdr_node_conn, &existing_nodes);
|
||||
|
||||
for (cell = existing_nodes.head; cell; cell = cell->next)
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#define SHOW_HEADER_COUNT 7
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SHOW_ID = 0,
|
||||
@@ -50,13 +51,21 @@ typedef enum
|
||||
} EventHeader;
|
||||
|
||||
|
||||
|
||||
struct ColHeader
|
||||
{
|
||||
char title[MAXLEN];
|
||||
int max_length;
|
||||
int cur_length;
|
||||
};
|
||||
|
||||
struct ColHeader headers_show[SHOW_HEADER_COUNT];
|
||||
struct ColHeader headers_event[EVENT_HEADER_COUNT];
|
||||
|
||||
|
||||
|
||||
static int build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, ItemList *warnings, int *error_code);
|
||||
static int build_cluster_crosscheck(t_node_status_cube ***cube_dest, int *name_length, ItemList *warnings, int *error_code);
|
||||
static int build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length);
|
||||
static int build_cluster_crosscheck(t_node_status_cube ***cube_dest, int *name_length);
|
||||
static void cube_set_node_status(t_node_status_cube **cube, int n, int node_id, int matrix_node_id, int connection_node_id, int connection_status);
|
||||
|
||||
/*
|
||||
@@ -75,7 +84,6 @@ do_cluster_show(void)
|
||||
ItemList warnings = {NULL, NULL};
|
||||
bool success = false;
|
||||
bool error_found = false;
|
||||
bool connection_error_found = false;
|
||||
|
||||
/* Connect to local database to obtain cluster connection data */
|
||||
log_verbose(LOG_INFO, _("connecting to database"));
|
||||
@@ -133,26 +141,14 @@ do_cluster_show(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
char error[MAXLEN];
|
||||
|
||||
strncpy(error, PQerrorMessage(cell->node_info->conn), MAXLEN);
|
||||
cell->node_info->node_status = NODE_STATUS_DOWN;
|
||||
cell->node_info->recovery_type = RECTYPE_UNKNOWN;
|
||||
|
||||
connection_error_found = true;
|
||||
|
||||
if (runtime_options.verbose)
|
||||
{
|
||||
char error[MAXLEN];
|
||||
|
||||
strncpy(error, PQerrorMessage(cell->node_info->conn), MAXLEN);
|
||||
item_list_append_format(&warnings,
|
||||
"when attempting to connect to node \"%s\" (ID: %i), following error encountered :\n\"%s\"",
|
||||
cell->node_info->node_name, cell->node_info->node_id, trim(error));
|
||||
}
|
||||
else
|
||||
{
|
||||
item_list_append_format(&warnings,
|
||||
"unable to connect to node \"%s\" (ID: %i)",
|
||||
cell->node_info->node_name, cell->node_info->node_id);
|
||||
}
|
||||
item_list_append_format(&warnings,
|
||||
"when attempting to connect to node \"%s\" (ID: %i), following error encountered :\n\"%s\"",
|
||||
cell->node_info->node_name, cell->node_info->node_id, trim(error));
|
||||
}
|
||||
|
||||
initPQExpBuffer(&details);
|
||||
@@ -174,16 +170,16 @@ do_cluster_show(void)
|
||||
switch (cell->node_info->recovery_type)
|
||||
{
|
||||
case RECTYPE_PRIMARY:
|
||||
appendPQExpBufferStr(&details, "* running");
|
||||
appendPQExpBuffer(&details, "* running");
|
||||
break;
|
||||
case RECTYPE_STANDBY:
|
||||
appendPQExpBufferStr(&details, "! running as standby");
|
||||
appendPQExpBuffer(&details, "! running as standby");
|
||||
item_list_append_format(&warnings,
|
||||
"node \"%s\" (ID: %i) is registered as primary but running as standby",
|
||||
cell->node_info->node_name, cell->node_info->node_id);
|
||||
break;
|
||||
case RECTYPE_UNKNOWN:
|
||||
appendPQExpBufferStr(&details, "! unknown");
|
||||
appendPQExpBuffer(&details, "! unknown");
|
||||
item_list_append_format(&warnings,
|
||||
"node \"%s\" (ID: %i) has unknown replication status",
|
||||
cell->node_info->node_name, cell->node_info->node_id);
|
||||
@@ -194,14 +190,14 @@ do_cluster_show(void)
|
||||
{
|
||||
if (cell->node_info->recovery_type == RECTYPE_PRIMARY)
|
||||
{
|
||||
appendPQExpBufferStr(&details, "! running");
|
||||
appendPQExpBuffer(&details, "! running");
|
||||
item_list_append_format(&warnings,
|
||||
"node \"%s\" (ID: %i) is running but the repmgr node record is inactive",
|
||||
cell->node_info->node_name, cell->node_info->node_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&details, "! running as standby");
|
||||
appendPQExpBuffer(&details, "! running as standby");
|
||||
item_list_append_format(&warnings,
|
||||
"node \"%s\" (ID: %i) is registered as an inactive primary but running as standby",
|
||||
cell->node_info->node_name, cell->node_info->node_id);
|
||||
@@ -214,7 +210,7 @@ do_cluster_show(void)
|
||||
/* node is unreachable but marked active */
|
||||
if (cell->node_info->active == true)
|
||||
{
|
||||
appendPQExpBufferStr(&details, "? unreachable");
|
||||
appendPQExpBuffer(&details, "? unreachable");
|
||||
item_list_append_format(&warnings,
|
||||
"node \"%s\" (ID: %i) is registered as an active primary but is unreachable",
|
||||
cell->node_info->node_name, cell->node_info->node_id);
|
||||
@@ -222,7 +218,7 @@ do_cluster_show(void)
|
||||
/* node is unreachable and marked as inactive */
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&details, "- failed");
|
||||
appendPQExpBuffer(&details, "- failed");
|
||||
error_found = true;
|
||||
}
|
||||
}
|
||||
@@ -238,16 +234,16 @@ do_cluster_show(void)
|
||||
switch (cell->node_info->recovery_type)
|
||||
{
|
||||
case RECTYPE_STANDBY:
|
||||
appendPQExpBufferStr(&details, " running");
|
||||
appendPQExpBuffer(&details, " running");
|
||||
break;
|
||||
case RECTYPE_PRIMARY:
|
||||
appendPQExpBufferStr(&details, "! running as primary");
|
||||
appendPQExpBuffer(&details, "! running as primary");
|
||||
item_list_append_format(&warnings,
|
||||
"node \"%s\" (ID: %i) is registered as standby but running as primary",
|
||||
cell->node_info->node_name, cell->node_info->node_id);
|
||||
break;
|
||||
case RECTYPE_UNKNOWN:
|
||||
appendPQExpBufferStr(&details, "! unknown");
|
||||
appendPQExpBuffer(&details, "! unknown");
|
||||
item_list_append_format(
|
||||
&warnings,
|
||||
"node \"%s\" (ID: %i) has unknown replication status",
|
||||
@@ -259,14 +255,14 @@ do_cluster_show(void)
|
||||
{
|
||||
if (cell->node_info->recovery_type == RECTYPE_STANDBY)
|
||||
{
|
||||
appendPQExpBufferStr(&details, "! running");
|
||||
appendPQExpBuffer(&details, "! running");
|
||||
item_list_append_format(&warnings,
|
||||
"node \"%s\" (ID: %i) is running but the repmgr node record is inactive",
|
||||
cell->node_info->node_name, cell->node_info->node_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&details, "! running as primary");
|
||||
appendPQExpBuffer(&details, "! running as primary");
|
||||
item_list_append_format(&warnings,
|
||||
"node \"%s\" (ID: %i) is running as primary but the repmgr node record is inactive",
|
||||
cell->node_info->node_name, cell->node_info->node_id);
|
||||
@@ -279,14 +275,14 @@ do_cluster_show(void)
|
||||
/* node is unreachable but marked active */
|
||||
if (cell->node_info->active == true)
|
||||
{
|
||||
appendPQExpBufferStr(&details, "? unreachable");
|
||||
appendPQExpBuffer(&details, "? unreachable");
|
||||
item_list_append_format(&warnings,
|
||||
"node \"%s\" (ID: %i) is registered as an active standby but is unreachable",
|
||||
cell->node_info->node_name, cell->node_info->node_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&details, "- failed");
|
||||
appendPQExpBuffer(&details, "- failed");
|
||||
error_found = true;
|
||||
}
|
||||
}
|
||||
@@ -300,11 +296,11 @@ do_cluster_show(void)
|
||||
{
|
||||
if (cell->node_info->active == true)
|
||||
{
|
||||
appendPQExpBufferStr(&details, "* running");
|
||||
appendPQExpBuffer(&details, "* running");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&details, "! running");
|
||||
appendPQExpBuffer(&details, "! running");
|
||||
error_found = true;
|
||||
}
|
||||
}
|
||||
@@ -313,11 +309,11 @@ do_cluster_show(void)
|
||||
{
|
||||
if (cell->node_info->active == true)
|
||||
{
|
||||
appendPQExpBufferStr(&details, "? unreachable");
|
||||
appendPQExpBuffer(&details, "? unreachable");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&details, "- failed");
|
||||
appendPQExpBuffer(&details, "- failed");
|
||||
error_found = true;
|
||||
}
|
||||
}
|
||||
@@ -326,7 +322,7 @@ do_cluster_show(void)
|
||||
case UNKNOWN:
|
||||
{
|
||||
/* this should never happen */
|
||||
appendPQExpBufferStr(&details, "? unknown node type");
|
||||
appendPQExpBuffer(&details, "? unknown node type");
|
||||
error_found = true;
|
||||
}
|
||||
break;
|
||||
@@ -355,10 +351,36 @@ do_cluster_show(void)
|
||||
|
||||
}
|
||||
|
||||
/* Print column header row (text mode only) */
|
||||
if (runtime_options.output_mode == OM_TEXT)
|
||||
{
|
||||
print_status_header(SHOW_HEADER_COUNT, headers_show);
|
||||
for (i = 0; i < SHOW_HEADER_COUNT; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
printf(" ");
|
||||
else
|
||||
printf(" | ");
|
||||
|
||||
printf("%-*s",
|
||||
headers_show[i].max_length,
|
||||
headers_show[i].title);
|
||||
}
|
||||
printf("\n");
|
||||
printf("-");
|
||||
|
||||
for (i = 0; i < SHOW_HEADER_COUNT; i++)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = 0; j < headers_show[i].max_length; j++)
|
||||
printf("-");
|
||||
|
||||
if (i < (SHOW_HEADER_COUNT - 1))
|
||||
printf("-+-");
|
||||
else
|
||||
printf("-");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
for (cell = nodes.head; cell; cell = cell->next)
|
||||
@@ -415,11 +437,6 @@ do_cluster_show(void)
|
||||
{
|
||||
printf(_(" - %s\n"), cell->string);
|
||||
}
|
||||
|
||||
if (runtime_options.verbose == false && connection_error_found == true)
|
||||
{
|
||||
log_hint(_("execute with --verbose option to see connection error messages"));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -602,12 +619,9 @@ do_cluster_crosscheck(void)
|
||||
|
||||
t_node_status_cube **cube;
|
||||
|
||||
bool connection_error_found = false;
|
||||
int error_code = SUCCESS;
|
||||
ItemList warnings = {NULL, NULL};
|
||||
|
||||
n = build_cluster_crosscheck(&cube, &name_length, &warnings, &error_code);
|
||||
bool error_found = false;
|
||||
|
||||
n = build_cluster_crosscheck(&cube, &name_length);
|
||||
if (runtime_options.output_mode == OM_CSV)
|
||||
{
|
||||
for (i = 0; i < n; i++)
|
||||
@@ -629,11 +643,6 @@ do_cluster_crosscheck(void)
|
||||
cube[i]->node_id,
|
||||
cube[j]->node_id,
|
||||
max_node_status);
|
||||
|
||||
if (max_node_status == -1)
|
||||
{
|
||||
connection_error_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -691,16 +700,16 @@ do_cluster_crosscheck(void)
|
||||
{
|
||||
case -2:
|
||||
c = '?';
|
||||
error_found = true;
|
||||
break;
|
||||
case -1:
|
||||
c = 'x';
|
||||
connection_error_found = true;
|
||||
error_found = true;
|
||||
break;
|
||||
case 0:
|
||||
c = '*';
|
||||
break;
|
||||
default:
|
||||
log_error("unexpected node status value %i", max_node_status);
|
||||
exit(ERR_INTERNAL);
|
||||
}
|
||||
|
||||
@@ -709,13 +718,6 @@ do_cluster_crosscheck(void)
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (warnings.head != NULL && runtime_options.terse == false)
|
||||
{
|
||||
log_warning(_("following problems detected:"));
|
||||
print_item_list(&warnings);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* clean up allocated cube array */
|
||||
@@ -742,23 +744,13 @@ do_cluster_crosscheck(void)
|
||||
free(cube);
|
||||
}
|
||||
|
||||
/* errors detected by build_cluster_crosscheck() have priority */
|
||||
if (connection_error_found == true)
|
||||
if (error_found == true)
|
||||
{
|
||||
error_code = ERR_NODE_STATUS;
|
||||
exit(ERR_NODE_STATUS);
|
||||
}
|
||||
|
||||
exit(error_code);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* CLUSTER MATRIX
|
||||
*
|
||||
* Parameters:
|
||||
* --csv
|
||||
*/
|
||||
void
|
||||
do_cluster_matrix()
|
||||
{
|
||||
@@ -771,30 +763,18 @@ do_cluster_matrix()
|
||||
|
||||
t_node_matrix_rec **matrix_rec_list;
|
||||
|
||||
bool connection_error_found = false;
|
||||
int error_code = SUCCESS;
|
||||
ItemList warnings = {NULL, NULL};
|
||||
bool error_found = false;
|
||||
|
||||
n = build_cluster_matrix(&matrix_rec_list, &name_length, &warnings, &error_code);
|
||||
n = build_cluster_matrix(&matrix_rec_list, &name_length);
|
||||
|
||||
if (runtime_options.output_mode == OM_CSV)
|
||||
{
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
for (j = 0; j < n; j++)
|
||||
{
|
||||
printf("%d,%d,%d\n",
|
||||
matrix_rec_list[i]->node_id,
|
||||
matrix_rec_list[i]->node_status_list[j]->node_id,
|
||||
matrix_rec_list[i]->node_status_list[j]->node_status);
|
||||
|
||||
if (matrix_rec_list[i]->node_status_list[j]->node_status == -2
|
||||
|| matrix_rec_list[i]->node_status_list[j]->node_status == -1)
|
||||
{
|
||||
connection_error_found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -823,16 +803,16 @@ do_cluster_matrix()
|
||||
{
|
||||
case -2:
|
||||
c = '?';
|
||||
error_found = true;
|
||||
break;
|
||||
case -1:
|
||||
c = 'x';
|
||||
connection_error_found = true;
|
||||
error_found = true;
|
||||
break;
|
||||
case 0:
|
||||
c = '*';
|
||||
break;
|
||||
default:
|
||||
log_error("unexpected node status value %i", matrix_rec_list[i]->node_status_list[j]->node_status);
|
||||
exit(ERR_INTERNAL);
|
||||
}
|
||||
|
||||
@@ -840,13 +820,6 @@ do_cluster_matrix()
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (warnings.head != NULL && runtime_options.terse == false)
|
||||
{
|
||||
log_warning(_("following problems detected:"));
|
||||
print_item_list(&warnings);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
@@ -861,13 +834,10 @@ do_cluster_matrix()
|
||||
|
||||
free(matrix_rec_list);
|
||||
|
||||
/* actual database connection errors have priority */
|
||||
if (connection_error_found == true)
|
||||
if (error_found == true)
|
||||
{
|
||||
error_code = ERR_NODE_STATUS;
|
||||
exit(ERR_NODE_STATUS);
|
||||
}
|
||||
|
||||
exit(error_code);
|
||||
}
|
||||
|
||||
|
||||
@@ -896,7 +866,7 @@ matrix_set_node_status(t_node_matrix_rec **matrix_rec_list, int n, int node_id,
|
||||
|
||||
|
||||
static int
|
||||
build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, ItemList *warnings, int *error_code)
|
||||
build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length)
|
||||
{
|
||||
PGconn *conn = NULL;
|
||||
int i = 0,
|
||||
@@ -925,12 +895,7 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite
|
||||
local_node_id = runtime_options.node_id;
|
||||
}
|
||||
|
||||
if (get_all_node_records(conn, &nodes) == false)
|
||||
{
|
||||
/* get_all_node_records() will display the error */
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
get_all_node_records(conn, &nodes);
|
||||
|
||||
PQfinish(conn);
|
||||
conn = NULL;
|
||||
@@ -944,7 +909,7 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite
|
||||
/*
|
||||
* Allocate an empty matrix record list
|
||||
*
|
||||
* -2 == NULL ? -1 == Error x 0 == OK
|
||||
* -2 == NULL ? -1 == Error x 0 == OK *
|
||||
*/
|
||||
|
||||
matrix_rec_list = (t_node_matrix_rec **) pg_malloc0(sizeof(t_node_matrix_rec) * nodes.node_count);
|
||||
@@ -1007,7 +972,7 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite
|
||||
|
||||
host = param_get(&remote_conninfo, "host");
|
||||
|
||||
node_conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
||||
node_conn = establish_db_connection(cell->node_info->conninfo, false);
|
||||
|
||||
connection_status =
|
||||
(PQstatus(node_conn) == CONNECTION_OK) ? 0 : -1;
|
||||
@@ -1044,12 +1009,24 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite
|
||||
* remote repmgr - those are the only values it needs to work, and
|
||||
* saves us making assumptions about the location of repmgr.conf
|
||||
*/
|
||||
appendPQExpBufferChar(&command, '"');
|
||||
appendPQExpBuffer(&command,
|
||||
"\"%s -d '%s' ",
|
||||
make_pg_path(progname()),
|
||||
cell->node_info->conninfo);
|
||||
|
||||
make_remote_repmgr_path(&command, cell->node_info);
|
||||
|
||||
appendPQExpBufferStr(&command,
|
||||
" cluster show --csv -L NOTICE --terse\"");
|
||||
if (strlen(pg_bindir))
|
||||
{
|
||||
appendPQExpBuffer(&command,
|
||||
"--pg_bindir=");
|
||||
appendShellString(&command,
|
||||
pg_bindir);
|
||||
appendPQExpBuffer(&command,
|
||||
" ");
|
||||
}
|
||||
|
||||
appendPQExpBuffer(&command,
|
||||
" cluster show --csv\"");
|
||||
|
||||
log_verbose(LOG_DEBUG, "build_cluster_matrix(): executing:\n %s", command.data);
|
||||
|
||||
@@ -1064,50 +1041,32 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite
|
||||
|
||||
termPQExpBuffer(&command);
|
||||
|
||||
/* no output returned - probably SSH error */
|
||||
if (p[0] == '\0' || p[0] == '\n')
|
||||
for (j = 0; j < nodes.node_count; j++)
|
||||
{
|
||||
item_list_append_format(warnings,
|
||||
"node %i inaccessible via SSH",
|
||||
connection_node_id);
|
||||
*error_code = ERR_BAD_SSH;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < nodes.node_count; j++)
|
||||
if (sscanf(p, "%d,%d", &x, &y) != 2)
|
||||
{
|
||||
if (sscanf(p, "%d,%d", &x, &y) != 2)
|
||||
{
|
||||
matrix_set_node_status(matrix_rec_list,
|
||||
nodes.node_count,
|
||||
connection_node_id,
|
||||
x,
|
||||
-2);
|
||||
|
||||
item_list_append_format(warnings,
|
||||
"unable to parse --csv output for node %i; output returned was:\n\"%s\"",
|
||||
connection_node_id, p);
|
||||
*error_code = ERR_INTERNAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix_set_node_status(matrix_rec_list,
|
||||
nodes.node_count,
|
||||
connection_node_id,
|
||||
x,
|
||||
(y == -1) ? -1 : 0);
|
||||
}
|
||||
|
||||
while (*p && (*p != '\n'))
|
||||
p++;
|
||||
if (*p == '\n')
|
||||
p++;
|
||||
fprintf(stderr, _("cannot parse --csv output: %s\n"), p);
|
||||
PQfinish(node_conn);
|
||||
exit(ERR_INTERNAL);
|
||||
}
|
||||
|
||||
matrix_set_node_status(matrix_rec_list,
|
||||
nodes.node_count,
|
||||
connection_node_id,
|
||||
x,
|
||||
(y == -1) ? -1 : 0);
|
||||
|
||||
while (*p && (*p != '\n'))
|
||||
p++;
|
||||
if (*p == '\n')
|
||||
p++;
|
||||
}
|
||||
|
||||
termPQExpBuffer(&command_output);
|
||||
PQfinish(node_conn);
|
||||
free_conninfo_params(&remote_conninfo);
|
||||
|
||||
node_conn = NULL;
|
||||
}
|
||||
|
||||
*matrix_rec_dest = matrix_rec_list;
|
||||
@@ -1120,7 +1079,7 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite
|
||||
|
||||
|
||||
static int
|
||||
build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length, ItemList *warnings, int *error_code)
|
||||
build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length)
|
||||
{
|
||||
PGconn *conn = NULL;
|
||||
int h,
|
||||
@@ -1141,12 +1100,7 @@ build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length, Item
|
||||
else
|
||||
conn = establish_db_connection_by_params(&source_conninfo, true);
|
||||
|
||||
if (get_all_node_records(conn, &nodes) == false)
|
||||
{
|
||||
/* get_all_node_records() will display the error */
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
get_all_node_records(conn, &nodes);
|
||||
|
||||
PQfinish(conn);
|
||||
conn = NULL;
|
||||
@@ -1233,13 +1187,28 @@ build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length, Item
|
||||
|
||||
initPQExpBuffer(&command);
|
||||
|
||||
make_remote_repmgr_path(&command, cell->node_info);
|
||||
appendPQExpBuffer(&command,
|
||||
"%s -d '%s' --node-id=%i ",
|
||||
make_pg_path(progname()),
|
||||
cell->node_info->conninfo,
|
||||
remote_node_id);
|
||||
|
||||
appendPQExpBufferStr(&command,
|
||||
" cluster matrix --csv -L NOTICE --terse");
|
||||
if (strlen(pg_bindir))
|
||||
{
|
||||
appendPQExpBuffer(&command,
|
||||
"--pg_bindir=");
|
||||
appendShellString(&command,
|
||||
pg_bindir);
|
||||
appendPQExpBuffer(&command,
|
||||
" ");
|
||||
}
|
||||
|
||||
appendPQExpBuffer(&command,
|
||||
"cluster matrix --csv 2>/dev/null");
|
||||
|
||||
initPQExpBuffer(&command_output);
|
||||
|
||||
/* fix to work with --node-id */
|
||||
if (cube[i]->node_id == config_file_options.node_id)
|
||||
{
|
||||
(void) local_command_simple(command.data,
|
||||
@@ -1280,13 +1249,9 @@ build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length, Item
|
||||
|
||||
p = command_output.data;
|
||||
|
||||
if (p[0] == '\0' || p[0] == '\n')
|
||||
if (!strlen(command_output.data))
|
||||
{
|
||||
item_list_append_format(warnings,
|
||||
"node %i inaccessible via SSH",
|
||||
remote_node_id);
|
||||
termPQExpBuffer(&command_output);
|
||||
*error_code = ERR_BAD_SSH;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1298,24 +1263,17 @@ build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length, Item
|
||||
|
||||
if (sscanf(p, "%d,%d,%d", &matrix_rec_node_id, &node_status_node_id, &node_status) != 3)
|
||||
{
|
||||
cube_set_node_status(cube,
|
||||
nodes.node_count,
|
||||
remote_node_id,
|
||||
matrix_rec_node_id,
|
||||
node_status_node_id,
|
||||
-2);
|
||||
*error_code = ERR_INTERNAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
cube_set_node_status(cube,
|
||||
nodes.node_count,
|
||||
remote_node_id,
|
||||
matrix_rec_node_id,
|
||||
node_status_node_id,
|
||||
node_status);
|
||||
fprintf(stderr, _("cannot parse --csv output: %s\n"), p);
|
||||
exit(ERR_INTERNAL);
|
||||
}
|
||||
|
||||
cube_set_node_status(cube,
|
||||
nodes.node_count,
|
||||
remote_node_id,
|
||||
matrix_rec_node_id,
|
||||
node_status_node_id,
|
||||
node_status);
|
||||
|
||||
while (*p && (*p != '\n'))
|
||||
p++;
|
||||
if (*p == '\n')
|
||||
@@ -1386,9 +1344,7 @@ do_cluster_cleanup(void)
|
||||
|
||||
log_debug(_("number of days of monitoring history to retain: %i"), runtime_options.keep_history);
|
||||
|
||||
entries_to_delete = get_number_of_monitoring_records_to_delete(primary_conn,
|
||||
runtime_options.keep_history,
|
||||
runtime_options.node_id);
|
||||
entries_to_delete = get_number_of_monitoring_records_to_delete(primary_conn, runtime_options.keep_history);
|
||||
|
||||
if (entries_to_delete < 0)
|
||||
{
|
||||
@@ -1408,9 +1364,9 @@ do_cluster_cleanup(void)
|
||||
|
||||
initPQExpBuffer(&event_details);
|
||||
|
||||
if (delete_monitoring_records(primary_conn, runtime_options.keep_history, runtime_options.node_id) == false)
|
||||
if (delete_monitoring_records(primary_conn, runtime_options.keep_history) == false)
|
||||
{
|
||||
appendPQExpBufferStr(&event_details,
|
||||
appendPQExpBuffer(&event_details,
|
||||
_("unable to delete monitoring records"));
|
||||
|
||||
log_error("%s", event_details.data);
|
||||
@@ -1434,21 +1390,8 @@ do_cluster_cleanup(void)
|
||||
log_detail("%s", PQerrorMessage(primary_conn));
|
||||
}
|
||||
|
||||
if (runtime_options.keep_history == 0)
|
||||
{
|
||||
appendPQExpBufferStr(&event_details,
|
||||
_("all monitoring records deleted"));
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&event_details,
|
||||
_("monitoring records deleted"));
|
||||
}
|
||||
|
||||
if (runtime_options.node_id != UNKNOWN_NODE_ID)
|
||||
appendPQExpBuffer(&event_details,
|
||||
_(" for node %i"),
|
||||
runtime_options.node_id);
|
||||
appendPQExpBuffer(&event_details,
|
||||
_("monitoring records deleted"));
|
||||
|
||||
if (runtime_options.keep_history > 0)
|
||||
appendPQExpBuffer(&event_details,
|
||||
@@ -1462,11 +1405,18 @@ do_cluster_cleanup(void)
|
||||
true,
|
||||
event_details.data);
|
||||
|
||||
log_notice("%s", event_details.data);
|
||||
|
||||
termPQExpBuffer(&event_details);
|
||||
PQfinish(primary_conn);
|
||||
|
||||
if (runtime_options.keep_history > 0)
|
||||
{
|
||||
log_notice(_("monitoring records older than %i day(s) deleted"),
|
||||
runtime_options.keep_history);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info(_("all monitoring records deleted"));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,420 +0,0 @@
|
||||
/*
|
||||
* repmgr-action-daemon.c
|
||||
*
|
||||
* Implements repmgrd actions for the repmgr command line utility
|
||||
* Copyright (c) 2ndQuadrant, 2010-2018
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "repmgr.h"
|
||||
|
||||
#include "repmgr-client-global.h"
|
||||
#include "repmgr-action-daemon.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Possibly also show:
|
||||
* - repmgrd start time?
|
||||
* - repmgrd mode
|
||||
* - priority
|
||||
* - whether promotion candidate (due to zero priority/different location)
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STATUS_ID = 0,
|
||||
STATUS_NAME,
|
||||
STATUS_ROLE,
|
||||
STATUS_PG,
|
||||
STATUS_RUNNING,
|
||||
STATUS_PID,
|
||||
STATUS_PAUSED
|
||||
} StatusHeader;
|
||||
|
||||
#define STATUS_HEADER_COUNT 7
|
||||
|
||||
struct ColHeader headers_status[STATUS_HEADER_COUNT];
|
||||
|
||||
static void fetch_node_records(PGconn *conn, NodeInfoList *node_list);
|
||||
static void _do_repmgr_pause(bool pause);
|
||||
|
||||
|
||||
void
|
||||
do_daemon_status(void)
|
||||
{
|
||||
PGconn *conn = NULL;
|
||||
NodeInfoList nodes = T_NODE_INFO_LIST_INITIALIZER;
|
||||
NodeInfoListCell *cell = NULL;
|
||||
int i;
|
||||
RepmgrdInfo **repmgrd_info;
|
||||
ItemList warnings = {NULL, NULL};
|
||||
|
||||
/* Connect to local database to obtain cluster connection data */
|
||||
log_verbose(LOG_INFO, _("connecting to database"));
|
||||
|
||||
if (strlen(config_file_options.conninfo))
|
||||
conn = establish_db_connection(config_file_options.conninfo, true);
|
||||
else
|
||||
conn = establish_db_connection_by_params(&source_conninfo, true);
|
||||
|
||||
fetch_node_records(conn, &nodes);
|
||||
|
||||
repmgrd_info = (RepmgrdInfo **) pg_malloc0(sizeof(RepmgrdInfo *) * nodes.node_count);
|
||||
|
||||
if (repmgrd_info == NULL)
|
||||
{
|
||||
log_error(_("unable to allocate memory"));
|
||||
exit(ERR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
strncpy(headers_status[STATUS_ID].title, _("ID"), MAXLEN);
|
||||
strncpy(headers_status[STATUS_NAME].title, _("Name"), MAXLEN);
|
||||
strncpy(headers_status[STATUS_ROLE].title, _("Role"), MAXLEN);
|
||||
strncpy(headers_status[STATUS_PG].title, _("Status"), MAXLEN);
|
||||
strncpy(headers_status[STATUS_RUNNING].title, _("repmgrd"), MAXLEN);
|
||||
strncpy(headers_status[STATUS_PID].title, _("PID"), MAXLEN);
|
||||
strncpy(headers_status[STATUS_PAUSED].title, _("Paused?"), MAXLEN);
|
||||
|
||||
for (i = 0; i < STATUS_HEADER_COUNT; i++)
|
||||
{
|
||||
headers_status[i].max_length = strlen(headers_status[i].title);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
for (cell = nodes.head; cell; cell = cell->next)
|
||||
{
|
||||
int j;
|
||||
|
||||
repmgrd_info[i] = pg_malloc0(sizeof(RepmgrdInfo));
|
||||
repmgrd_info[i]->node_id = cell->node_info->node_id;
|
||||
repmgrd_info[i]->pid = UNKNOWN_PID;
|
||||
repmgrd_info[i]->paused = false;
|
||||
repmgrd_info[i]->running = false;
|
||||
repmgrd_info[i]->pg_running = true;
|
||||
|
||||
cell->node_info->conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
||||
|
||||
if (PQstatus(cell->node_info->conn) != CONNECTION_OK)
|
||||
{
|
||||
if (runtime_options.verbose)
|
||||
{
|
||||
char error[MAXLEN];
|
||||
|
||||
strncpy(error, PQerrorMessage(cell->node_info->conn), MAXLEN);
|
||||
|
||||
item_list_append_format(&warnings,
|
||||
"when attempting to connect to node \"%s\" (ID: %i), following error encountered :\n\"%s\"",
|
||||
cell->node_info->node_name, cell->node_info->node_id, trim(error));
|
||||
}
|
||||
else
|
||||
{
|
||||
item_list_append_format(&warnings,
|
||||
"unable to connect to node \"%s\" (ID: %i)",
|
||||
cell->node_info->node_name, cell->node_info->node_id);
|
||||
}
|
||||
|
||||
repmgrd_info[i]->pg_running = false;
|
||||
maxlen_snprintf(repmgrd_info[i]->pg_running_text, "%s", _("not running"));
|
||||
maxlen_snprintf(repmgrd_info[i]->repmgrd_running, "%s", _("n/a"));
|
||||
maxlen_snprintf(repmgrd_info[i]->pid_text, "%s", _("n/a"));
|
||||
}
|
||||
else
|
||||
{
|
||||
maxlen_snprintf(repmgrd_info[i]->pg_running_text, "%s", _("running"));
|
||||
|
||||
repmgrd_info[i]->pid = repmgrd_get_pid(cell->node_info->conn);
|
||||
|
||||
repmgrd_info[i]->running = repmgrd_is_running(cell->node_info->conn);
|
||||
|
||||
if (repmgrd_info[i]->running == true)
|
||||
{
|
||||
maxlen_snprintf(repmgrd_info[i]->repmgrd_running, "%s", _("running"));
|
||||
}
|
||||
else
|
||||
{
|
||||
maxlen_snprintf(repmgrd_info[i]->repmgrd_running, "%s", _("not running"));
|
||||
}
|
||||
|
||||
if (repmgrd_info[i]->pid == UNKNOWN_PID)
|
||||
{
|
||||
maxlen_snprintf(repmgrd_info[i]->pid_text, "%s", _("n/a"));
|
||||
}
|
||||
else
|
||||
{
|
||||
maxlen_snprintf(repmgrd_info[i]->pid_text, "%i", repmgrd_info[i]->pid);
|
||||
}
|
||||
|
||||
repmgrd_info[i]->paused = repmgrd_is_paused(cell->node_info->conn);
|
||||
|
||||
PQfinish(cell->node_info->conn);
|
||||
}
|
||||
|
||||
|
||||
headers_status[STATUS_NAME].cur_length = strlen(cell->node_info->node_name);
|
||||
headers_status[STATUS_ROLE].cur_length = strlen(get_node_type_string(cell->node_info->type));
|
||||
headers_status[STATUS_PID].cur_length = strlen(repmgrd_info[i]->pid_text);
|
||||
headers_status[STATUS_RUNNING].cur_length = strlen(repmgrd_info[i]->repmgrd_running);
|
||||
headers_status[STATUS_PG].cur_length = strlen(repmgrd_info[i]->pg_running_text);
|
||||
|
||||
for (j = 0; j < STATUS_HEADER_COUNT; j++)
|
||||
{
|
||||
if (headers_status[j].cur_length > headers_status[j].max_length)
|
||||
{
|
||||
headers_status[j].max_length = headers_status[j].cur_length;
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Print column header row (text mode only) */
|
||||
if (runtime_options.output_mode == OM_TEXT)
|
||||
{
|
||||
print_status_header(STATUS_HEADER_COUNT, headers_status);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
for (cell = nodes.head; cell; cell = cell->next)
|
||||
{
|
||||
if (runtime_options.output_mode == OM_CSV)
|
||||
{
|
||||
printf("%i,%s,%s,%i,%i,%i,%i\n",
|
||||
cell->node_info->node_id,
|
||||
cell->node_info->node_name,
|
||||
get_node_type_string(cell->node_info->type),
|
||||
repmgrd_info[i]->pg_running ? 1 : 0,
|
||||
repmgrd_info[i]->running ? 1 : 0,
|
||||
repmgrd_info[i]->pid,
|
||||
repmgrd_info[i]->paused ? 1 : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(" %-*i ", headers_status[STATUS_ID].max_length, cell->node_info->node_id);
|
||||
printf("| %-*s ", headers_status[STATUS_NAME].max_length, cell->node_info->node_name);
|
||||
printf("| %-*s ", headers_status[STATUS_ROLE].max_length, get_node_type_string(cell->node_info->type));
|
||||
|
||||
printf("| %-*s ", headers_status[STATUS_PG].max_length, repmgrd_info[i]->pg_running_text);
|
||||
printf("| %-*s ", headers_status[STATUS_RUNNING].max_length, repmgrd_info[i]->repmgrd_running);
|
||||
printf("| %-*s ", headers_status[STATUS_PID].max_length, repmgrd_info[i]->pid_text);
|
||||
|
||||
if (repmgrd_info[i]->pid == UNKNOWN_PID)
|
||||
printf("| %-*s ", headers_status[STATUS_PAUSED].max_length, "n/a");
|
||||
else
|
||||
printf("| %-*s ", headers_status[STATUS_PAUSED].max_length, repmgrd_info[i]->paused ? "yes" : "no");
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
free(repmgrd_info[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
free(repmgrd_info);
|
||||
|
||||
/* emit any warnings */
|
||||
|
||||
if (warnings.head != NULL && runtime_options.terse == false && runtime_options.output_mode != OM_CSV)
|
||||
{
|
||||
ItemListCell *cell = NULL;
|
||||
|
||||
printf(_("\nWARNING: following issues were detected\n"));
|
||||
for (cell = warnings.head; cell; cell = cell->next)
|
||||
{
|
||||
printf(_(" - %s\n"), cell->string);
|
||||
}
|
||||
|
||||
if (runtime_options.verbose == false)
|
||||
{
|
||||
log_hint(_("execute with --verbose option to see connection error messages"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
do_daemon_pause(void)
|
||||
{
|
||||
_do_repmgr_pause(true);
|
||||
}
|
||||
|
||||
void
|
||||
do_daemon_unpause(void)
|
||||
{
|
||||
_do_repmgr_pause(false);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_do_repmgr_pause(bool pause)
|
||||
{
|
||||
PGconn *conn = NULL;
|
||||
NodeInfoList nodes = T_NODE_INFO_LIST_INITIALIZER;
|
||||
NodeInfoListCell *cell = NULL;
|
||||
RepmgrdInfo **repmgrd_info;
|
||||
int i;
|
||||
int error_nodes = 0;
|
||||
|
||||
repmgrd_info = (RepmgrdInfo **) pg_malloc0(sizeof(RepmgrdInfo *) * nodes.node_count);
|
||||
|
||||
if (repmgrd_info == NULL)
|
||||
{
|
||||
log_error(_("unable to allocate memory"));
|
||||
exit(ERR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
/* Connect to local database to obtain cluster connection data */
|
||||
log_verbose(LOG_INFO, _("connecting to database"));
|
||||
|
||||
if (strlen(config_file_options.conninfo))
|
||||
conn = establish_db_connection(config_file_options.conninfo, true);
|
||||
else
|
||||
conn = establish_db_connection_by_params(&source_conninfo, true);
|
||||
|
||||
fetch_node_records(conn, &nodes);
|
||||
|
||||
i = 0;
|
||||
|
||||
for (cell = nodes.head; cell; cell = cell->next)
|
||||
{
|
||||
repmgrd_info[i] = pg_malloc0(sizeof(RepmgrdInfo));
|
||||
repmgrd_info[i]->node_id = cell->node_info->node_id;
|
||||
|
||||
log_verbose(LOG_DEBUG, "pausing node %i (%s)",
|
||||
cell->node_info->node_id,
|
||||
cell->node_info->node_name);
|
||||
cell->node_info->conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
||||
|
||||
if (PQstatus(cell->node_info->conn) != CONNECTION_OK)
|
||||
{
|
||||
log_warning(_("unable to connect to node %i"),
|
||||
cell->node_info->node_id);
|
||||
error_nodes++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (runtime_options.dry_run == true)
|
||||
{
|
||||
if (pause == true)
|
||||
{
|
||||
log_info(_("would pause node %i (%s) "),
|
||||
cell->node_info->node_id,
|
||||
cell->node_info->node_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info(_("would unpause node %i (%s) "),
|
||||
cell->node_info->node_id,
|
||||
cell->node_info->node_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool success = repmgrd_pause(cell->node_info->conn, pause);
|
||||
|
||||
if (success == false)
|
||||
error_nodes++;
|
||||
|
||||
log_notice(_("node %i (%s) %s"),
|
||||
cell->node_info->node_id,
|
||||
cell->node_info->node_name,
|
||||
success == true
|
||||
? pause == true ? "paused" : "unpaused"
|
||||
: pause == true ? "not paused" : "not unpaused");
|
||||
}
|
||||
PQfinish(cell->node_info->conn);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (error_nodes > 0)
|
||||
{
|
||||
if (pause == true)
|
||||
{
|
||||
log_error(_("unable to pause %i node(s)"), error_nodes);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error(_("unable to unpause %i node(s)"), error_nodes);
|
||||
}
|
||||
|
||||
log_hint(_("execute \"repmgr daemon status\" to view current status"));
|
||||
|
||||
exit(ERR_REPMGRD_PAUSE);
|
||||
}
|
||||
|
||||
exit(SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
fetch_node_records(PGconn *conn, NodeInfoList *node_list)
|
||||
{
|
||||
bool success = get_all_node_records(conn, node_list);
|
||||
|
||||
if (success == false)
|
||||
{
|
||||
/* get_all_node_records() will display any error message */
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
if (node_list->node_count == 0)
|
||||
{
|
||||
log_error(_("no node records were found"));
|
||||
log_hint(_("ensure at least one node is registered"));
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void do_daemon_help(void)
|
||||
{
|
||||
print_help_header();
|
||||
|
||||
printf(_("Usage:\n"));
|
||||
printf(_(" %s [OPTIONS] daemon status\n"), progname());
|
||||
printf(_(" %s [OPTIONS] daemon pause\n"), progname());
|
||||
printf(_(" %s [OPTIONS] daemon unpause\n"), progname());
|
||||
puts("");
|
||||
|
||||
printf(_("DAEMON STATUS\n"));
|
||||
puts("");
|
||||
printf(_(" \"daemon status\" shows the status of repmgrd on each node in the cluster\n"));
|
||||
puts("");
|
||||
printf(_(" --csv emit output as CSV\n"));
|
||||
printf(_(" --verbose show text of database connection error messages\n"));
|
||||
puts("");
|
||||
|
||||
printf(_("DAEMON PAUSE\n"));
|
||||
puts("");
|
||||
printf(_(" \"daemon pause\" instructs repmgrd on each node to pause failover detection\n"));
|
||||
puts("");
|
||||
printf(_(" --dry-run check if nodes are reachable but don't pause repmgrd\n"));
|
||||
puts("");
|
||||
|
||||
printf(_("DAEMON PAUSE\n"));
|
||||
puts("");
|
||||
printf(_(" \"daemon unpause\" instructs repmgrd on each node to resume failover detection\n"));
|
||||
puts("");
|
||||
printf(_(" --dry-run check if nodes are reachable but don't unpause repmgrd\n"));
|
||||
puts("");
|
||||
|
||||
|
||||
puts("");
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* repmgr-action-daemon.h
|
||||
* Copyright (c) 2ndQuadrant, 2010-2018
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _REPMGR_ACTION_DAEMON_H_
|
||||
#define _REPMGR_ACTION_DAEMON_H_
|
||||
|
||||
|
||||
extern void do_daemon_status(void);
|
||||
extern void do_daemon_pause(void);
|
||||
extern void do_daemon_unpause(void);
|
||||
|
||||
extern void do_daemon_help(void);
|
||||
#endif
|
||||
@@ -189,16 +189,16 @@ do_node_status(void)
|
||||
|
||||
if (enabled == true)
|
||||
{
|
||||
appendPQExpBufferStr(&archiving_status, "enabled");
|
||||
appendPQExpBuffer(&archiving_status, "enabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&archiving_status, "disabled");
|
||||
appendPQExpBuffer(&archiving_status, "disabled");
|
||||
}
|
||||
|
||||
if (enabled == false && recovery_type == RECTYPE_STANDBY)
|
||||
{
|
||||
appendPQExpBufferStr(&archiving_status, " (on standbys \"archive_mode\" must be set to \"always\" to be effective)");
|
||||
appendPQExpBuffer(&archiving_status, " (on standbys \"archive_mode\" must be set to \"always\" to be effective)");
|
||||
}
|
||||
|
||||
key_value_list_set(&node_status,
|
||||
@@ -506,7 +506,7 @@ do_node_status(void)
|
||||
|
||||
/* output missing slot information */
|
||||
|
||||
appendPQExpBufferChar(&output, '\n');
|
||||
appendPQExpBuffer(&output, "\n");
|
||||
appendPQExpBuffer(&output,
|
||||
"\"missing_replication_slots\",%i",
|
||||
missing_slots.node_count);
|
||||
@@ -590,13 +590,13 @@ _do_node_status_is_shutdown_cleanly(void)
|
||||
|
||||
initPQExpBuffer(&output);
|
||||
|
||||
appendPQExpBufferStr(&output,
|
||||
appendPQExpBuffer(&output,
|
||||
"--state=");
|
||||
|
||||
/* sanity-check we're dealing with a PostgreSQL directory */
|
||||
if (is_pg_dir(config_file_options.data_directory) == false)
|
||||
{
|
||||
appendPQExpBufferStr(&output, "UNKNOWN");
|
||||
appendPQExpBuffer(&output, "UNKNOWN");
|
||||
printf("%s\n", output.data);
|
||||
termPQExpBuffer(&output);
|
||||
return;
|
||||
@@ -659,10 +659,10 @@ _do_node_status_is_shutdown_cleanly(void)
|
||||
switch (node_status)
|
||||
{
|
||||
case NODE_STATUS_UP:
|
||||
appendPQExpBufferStr(&output, "RUNNING");
|
||||
appendPQExpBuffer(&output, "RUNNING");
|
||||
break;
|
||||
case NODE_STATUS_SHUTTING_DOWN:
|
||||
appendPQExpBufferStr(&output, "SHUTTING_DOWN");
|
||||
appendPQExpBuffer(&output, "SHUTTING_DOWN");
|
||||
break;
|
||||
case NODE_STATUS_DOWN:
|
||||
appendPQExpBuffer(&output,
|
||||
@@ -670,10 +670,10 @@ _do_node_status_is_shutdown_cleanly(void)
|
||||
format_lsn(checkPoint));
|
||||
break;
|
||||
case NODE_STATUS_UNCLEAN_SHUTDOWN:
|
||||
appendPQExpBufferStr(&output, "UNCLEAN_SHUTDOWN");
|
||||
appendPQExpBuffer(&output, "UNCLEAN_SHUTDOWN");
|
||||
break;
|
||||
case NODE_STATUS_UNKNOWN:
|
||||
appendPQExpBufferStr(&output, "UNKNOWN");
|
||||
appendPQExpBuffer(&output, "UNKNOWN");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -847,7 +847,7 @@ do_node_check(void)
|
||||
",\"%s\"",
|
||||
cell->details);
|
||||
}
|
||||
appendPQExpBufferChar(&output, '\n');
|
||||
appendPQExpBuffer(&output, "\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -869,7 +869,7 @@ do_node_check(void)
|
||||
" (%s)",
|
||||
cell->details);
|
||||
}
|
||||
appendPQExpBufferChar(&output, '\n');
|
||||
appendPQExpBuffer(&output, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -899,12 +899,12 @@ do_node_check_replication_connection(void)
|
||||
|
||||
|
||||
initPQExpBuffer(&output);
|
||||
appendPQExpBufferStr(&output,
|
||||
"--connection=");
|
||||
appendPQExpBuffer(&output,
|
||||
"--connection=");
|
||||
|
||||
if (runtime_options.remote_node_id == UNKNOWN_NODE_ID)
|
||||
{
|
||||
appendPQExpBufferStr(&output, "UNKNOWN");
|
||||
appendPQExpBuffer(&output, "UNKNOWN");
|
||||
printf("%s\n", output.data);
|
||||
termPQExpBuffer(&output);
|
||||
return;
|
||||
@@ -918,7 +918,7 @@ do_node_check_replication_connection(void)
|
||||
|
||||
if (record_status != RECORD_FOUND)
|
||||
{
|
||||
appendPQExpBufferStr(&output, "UNKNOWN");
|
||||
appendPQExpBuffer(&output, "UNKNOWN");
|
||||
printf("%s\n", output.data);
|
||||
termPQExpBuffer(&output);
|
||||
return;
|
||||
@@ -938,7 +938,7 @@ do_node_check_replication_connection(void)
|
||||
|
||||
if (PQstatus(repl_conn) != CONNECTION_OK)
|
||||
{
|
||||
appendPQExpBufferStr(&output, "BAD");
|
||||
appendPQExpBuffer(&output, "BAD");
|
||||
printf("%s\n", output.data);
|
||||
termPQExpBuffer(&output);
|
||||
return;
|
||||
@@ -946,7 +946,7 @@ do_node_check_replication_connection(void)
|
||||
|
||||
PQfinish(repl_conn);
|
||||
|
||||
appendPQExpBufferStr(&output, "OK");
|
||||
appendPQExpBuffer(&output, "OK");
|
||||
printf("%s\n", output.data);
|
||||
termPQExpBuffer(&output);
|
||||
|
||||
@@ -1042,8 +1042,9 @@ do_node_check_archive_ready(PGconn *conn, OutputMode mode, CheckStatusList *list
|
||||
break;
|
||||
case OM_NAGIOS:
|
||||
case OM_TEXT:
|
||||
appendPQExpBufferStr(&details,
|
||||
"unable to check archive_status directory");
|
||||
appendPQExpBuffer(
|
||||
&details,
|
||||
"unable to check archive_status directory");
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1171,8 +1172,8 @@ do_node_check_downstream(PGconn *conn, OutputMode mode, CheckStatusList *list_ou
|
||||
if (missing_nodes_count == 0)
|
||||
{
|
||||
if (expected_nodes_count == 0)
|
||||
appendPQExpBufferStr(&details,
|
||||
"this node has no downstream nodes");
|
||||
appendPQExpBuffer(&details,
|
||||
"this node has no downstream nodes");
|
||||
else
|
||||
appendPQExpBuffer(&details,
|
||||
"%i of %i downstream nodes attached",
|
||||
@@ -1193,18 +1194,20 @@ do_node_check_downstream(PGconn *conn, OutputMode mode, CheckStatusList *list_ou
|
||||
|
||||
if (mode != OM_NAGIOS)
|
||||
{
|
||||
appendPQExpBufferStr(&details, "; missing: ");
|
||||
appendPQExpBuffer(&details, "; missing: ");
|
||||
|
||||
for (missing_cell = missing_nodes.head; missing_cell; missing_cell = missing_cell->next)
|
||||
{
|
||||
if (first == false)
|
||||
appendPQExpBufferStr(&details,
|
||||
", ");
|
||||
appendPQExpBuffer(&details,
|
||||
", ");
|
||||
else
|
||||
first = false;
|
||||
|
||||
if (first == false)
|
||||
appendPQExpBufferStr(&details, missing_cell->string);
|
||||
appendPQExpBuffer(
|
||||
&details,
|
||||
"%s", missing_cell->string);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1304,8 +1307,8 @@ do_node_check_replication_lag(PGconn *conn, OutputMode mode, t_node_info *node_i
|
||||
switch (mode)
|
||||
{
|
||||
case OM_OPTFORMAT:
|
||||
appendPQExpBufferStr(&details,
|
||||
"--lag=0");
|
||||
appendPQExpBuffer(&details,
|
||||
"--lag=0");
|
||||
break;
|
||||
case OM_NAGIOS:
|
||||
appendPQExpBuffer(&details,
|
||||
@@ -1316,13 +1319,13 @@ do_node_check_replication_lag(PGconn *conn, OutputMode mode, t_node_info *node_i
|
||||
case OM_TEXT:
|
||||
if (node_info->type == WITNESS)
|
||||
{
|
||||
appendPQExpBufferStr(&details,
|
||||
"N/A - node is witness");
|
||||
appendPQExpBuffer(&details,
|
||||
"N/A - node is witness");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&details,
|
||||
"N/A - node is primary");
|
||||
appendPQExpBuffer(&details,
|
||||
"N/A - node is primary");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -1403,8 +1406,9 @@ do_node_check_replication_lag(PGconn *conn, OutputMode mode, t_node_info *node_i
|
||||
break;
|
||||
case OM_NAGIOS:
|
||||
case OM_TEXT:
|
||||
appendPQExpBufferStr(&details,
|
||||
"unable to query replication lag");
|
||||
appendPQExpBuffer(
|
||||
&details,
|
||||
"unable to query replication lag");
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1504,39 +1508,39 @@ do_node_check_role(PGconn *conn, OutputMode mode, t_node_info *node_info, CheckS
|
||||
if (recovery_type == RECTYPE_STANDBY)
|
||||
{
|
||||
status = CHECK_STATUS_CRITICAL;
|
||||
appendPQExpBufferStr(&details,
|
||||
_("node is registered as primary but running as standby"));
|
||||
appendPQExpBuffer(&details,
|
||||
_("node is registered as primary but running as standby"));
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&details,
|
||||
_("node is primary"));
|
||||
appendPQExpBuffer(&details,
|
||||
_("node is primary"));
|
||||
}
|
||||
break;
|
||||
case STANDBY:
|
||||
if (recovery_type == RECTYPE_PRIMARY)
|
||||
{
|
||||
status = CHECK_STATUS_CRITICAL;
|
||||
appendPQExpBufferStr(&details,
|
||||
_("node is registered as standby but running as primary"));
|
||||
appendPQExpBuffer(&details,
|
||||
_("node is registered as standby but running as primary"));
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&details,
|
||||
_("node is standby"));
|
||||
appendPQExpBuffer(&details,
|
||||
_("node is standby"));
|
||||
}
|
||||
break;
|
||||
case WITNESS:
|
||||
if (recovery_type == RECTYPE_STANDBY)
|
||||
{
|
||||
status = CHECK_STATUS_CRITICAL;
|
||||
appendPQExpBufferStr(&details,
|
||||
_("node is registered as witness but running as standby"));
|
||||
appendPQExpBuffer(&details,
|
||||
_("node is registered as witness but running as standby"));
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&details,
|
||||
_("node is witness"));
|
||||
appendPQExpBuffer(&details,
|
||||
_("node is witness"));
|
||||
}
|
||||
break;
|
||||
case BDR:
|
||||
@@ -1547,8 +1551,8 @@ do_node_check_role(PGconn *conn, OutputMode mode, t_node_info *node_info, CheckS
|
||||
if (is_bdr_db(conn, &output) == false)
|
||||
{
|
||||
status = CHECK_STATUS_CRITICAL;
|
||||
appendPQExpBufferStr(&details,
|
||||
output.data);
|
||||
appendPQExpBuffer(&details,
|
||||
"%s", output.data);
|
||||
}
|
||||
termPQExpBuffer(&output);
|
||||
|
||||
@@ -1557,13 +1561,13 @@ do_node_check_role(PGconn *conn, OutputMode mode, t_node_info *node_info, CheckS
|
||||
if (is_active_bdr_node(conn, node_info->node_name) == false)
|
||||
{
|
||||
status = CHECK_STATUS_CRITICAL;
|
||||
appendPQExpBufferStr(&details,
|
||||
_("node is not an active BDR node"));
|
||||
appendPQExpBuffer(&details,
|
||||
_("node is not an active BDR node"));
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&details,
|
||||
_("node is an active BDR node"));
|
||||
appendPQExpBuffer(&details,
|
||||
_("node is an active BDR node"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1620,13 +1624,13 @@ do_node_check_slots(PGconn *conn, OutputMode mode, t_node_info *node_info, Check
|
||||
|
||||
if (server_version_num < 90400)
|
||||
{
|
||||
appendPQExpBufferStr(&details,
|
||||
_("replication slots not available for this PostgreSQL version"));
|
||||
appendPQExpBuffer(&details,
|
||||
_("replication slots not available for this PostgreSQL version"));
|
||||
}
|
||||
else if (node_info->total_replication_slots == 0)
|
||||
{
|
||||
appendPQExpBufferStr(&details,
|
||||
_("node has no replication slots"));
|
||||
appendPQExpBuffer(&details,
|
||||
_("node has no replication slots"));
|
||||
}
|
||||
else if (node_info->inactive_replication_slots == 0)
|
||||
{
|
||||
@@ -1696,8 +1700,8 @@ do_node_check_missing_slots(PGconn *conn, OutputMode mode, t_node_info *node_inf
|
||||
|
||||
if (server_version_num < 90400)
|
||||
{
|
||||
appendPQExpBufferStr(&details,
|
||||
_("replication slots not available for this PostgreSQL version"));
|
||||
appendPQExpBuffer(&details,
|
||||
_("replication slots not available for this PostgreSQL version"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1707,8 +1711,9 @@ do_node_check_missing_slots(PGconn *conn, OutputMode mode, t_node_info *node_inf
|
||||
|
||||
if (missing_slots.node_count == 0)
|
||||
{
|
||||
appendPQExpBufferStr(&details,
|
||||
_("node has no missing replication slots"));
|
||||
appendPQExpBuffer(&details,
|
||||
_("node has no missing replication slots"));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1723,7 +1728,7 @@ do_node_check_missing_slots(PGconn *conn, OutputMode mode, t_node_info *node_inf
|
||||
|
||||
if (missing_slots.node_count)
|
||||
{
|
||||
appendPQExpBufferStr(&details, ": ");
|
||||
appendPQExpBuffer(&details, ": ");
|
||||
|
||||
for (missing_slot_cell = missing_slots.head; missing_slot_cell; missing_slot_cell = missing_slot_cell->next)
|
||||
{
|
||||
@@ -1733,10 +1738,10 @@ do_node_check_missing_slots(PGconn *conn, OutputMode mode, t_node_info *node_inf
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&details, ", ");
|
||||
appendPQExpBuffer(&details, ", ");
|
||||
}
|
||||
|
||||
appendPQExpBufferStr(&details, missing_slot_cell->node_info->slot_name);
|
||||
appendPQExpBuffer(&details, "%s", missing_slot_cell->node_info->slot_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1779,7 +1784,7 @@ do_node_check_missing_slots(PGconn *conn, OutputMode mode, t_node_info *node_inf
|
||||
if (list_output != NULL)
|
||||
{
|
||||
check_status_list_set(list_output,
|
||||
"Missing replication slots",
|
||||
"Replication slots",
|
||||
status,
|
||||
details.data);
|
||||
}
|
||||
@@ -2132,8 +2137,8 @@ do_node_rejoin(void)
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
appendPQExpBufferStr(&msg,
|
||||
_("prerequisites for using pg_rewind are met"));
|
||||
appendPQExpBuffer(&msg,
|
||||
_("prerequisites for using pg_rewind are met"));
|
||||
|
||||
if (runtime_options.dry_run == true)
|
||||
{
|
||||
|
||||
@@ -170,8 +170,8 @@ do_primary_register(void)
|
||||
&node_info);
|
||||
if (record_created == true)
|
||||
{
|
||||
appendPQExpBufferStr(&event_description,
|
||||
"existing primary record updated");
|
||||
appendPQExpBuffer(&event_description,
|
||||
"existing primary record updated");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -731,16 +731,16 @@ do_standby_clone(void)
|
||||
runtime_options.host,
|
||||
runtime_options.port);
|
||||
|
||||
appendPQExpBufferStr(&event_details,
|
||||
_("; backup method: "));
|
||||
appendPQExpBuffer(&event_details,
|
||||
_("; backup method: "));
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case pg_basebackup:
|
||||
appendPQExpBufferStr(&event_details, "pg_basebackup");
|
||||
appendPQExpBuffer(&event_details, "pg_basebackup");
|
||||
break;
|
||||
case barman:
|
||||
appendPQExpBufferStr(&event_details, "barman");
|
||||
appendPQExpBuffer(&event_details, "barman");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1672,12 +1672,12 @@ do_standby_register(void)
|
||||
|
||||
if (record_created == false)
|
||||
{
|
||||
appendPQExpBufferStr(&details,
|
||||
"standby registration failed");
|
||||
appendPQExpBuffer(&details,
|
||||
"standby registration failed");
|
||||
|
||||
if (runtime_options.force == true)
|
||||
appendPQExpBufferStr(&details,
|
||||
" (-F/--force option was used)");
|
||||
appendPQExpBuffer(&details,
|
||||
" (-F/--force option was used)");
|
||||
|
||||
create_event_notification_extended(
|
||||
primary_conn,
|
||||
@@ -1697,12 +1697,12 @@ do_standby_register(void)
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
appendPQExpBufferStr(&details,
|
||||
"standby registration succeeded");
|
||||
appendPQExpBuffer(&details,
|
||||
"standby registration succeeded");
|
||||
|
||||
if (runtime_options.force == true)
|
||||
appendPQExpBufferStr(&details,
|
||||
" (-F/--force option was used)");
|
||||
appendPQExpBuffer(&details,
|
||||
" (-F/--force option was used)");
|
||||
|
||||
|
||||
/* Log the event */
|
||||
@@ -2771,8 +2771,8 @@ do_standby_follow_internal(PGconn *primary_conn, t_node_info *primary_node_recor
|
||||
primary_node_record->node_id,
|
||||
true) == false)
|
||||
{
|
||||
appendPQExpBufferStr(output,
|
||||
_("unable to update upstream node"));
|
||||
appendPQExpBuffer(output,
|
||||
_("unable to update upstream node"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2788,13 +2788,15 @@ do_standby_follow_internal(PGconn *primary_conn, t_node_info *primary_node_recor
|
||||
|
||||
/*
|
||||
* Perform a switchover by:
|
||||
*
|
||||
* - stopping current primary node
|
||||
* - promoting this standby node to primary
|
||||
* - forcing the previous primary node to follow this node
|
||||
* - forcing previous primary node to follow this node
|
||||
*
|
||||
* Where running and not already paused, repmgrd will be paused (and
|
||||
* subsequently unpaused), unless --repmgrd-no-pause provided.
|
||||
* Caveat:
|
||||
* - repmgrd must not be running, otherwise it may
|
||||
* attempt a failover
|
||||
* (TODO: find some way of notifying repmgrd of planned
|
||||
* activity like this)
|
||||
*
|
||||
* TODO:
|
||||
* - make connection test timeouts/intervals configurable (see below)
|
||||
@@ -2852,11 +2854,6 @@ do_standby_switchover(void)
|
||||
|
||||
t_event_info event_info = T_EVENT_INFO_INITIALIZER;
|
||||
|
||||
/* used for handling repmgrd pause/unpause */
|
||||
NodeInfoList all_nodes = T_NODE_INFO_LIST_INITIALIZER;
|
||||
RepmgrdInfo **repmgrd_info = NULL;
|
||||
int repmgrd_running_count = 0;
|
||||
|
||||
/*
|
||||
* SANITY CHECKS
|
||||
*
|
||||
@@ -2927,7 +2924,7 @@ do_standby_switchover(void)
|
||||
|
||||
if (record_status != RECORD_FOUND)
|
||||
{
|
||||
log_error(_("unable to retrieve node record for currentr primary (node %i)"),
|
||||
log_error(_("unable to retrieve node record for node %i"),
|
||||
remote_node_id);
|
||||
|
||||
PQfinish(local_conn);
|
||||
@@ -2937,11 +2934,11 @@ do_standby_switchover(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that there are no exclusive backups running on the primary.
|
||||
* Check that there's no exclusive backups running on the primary.
|
||||
* We don't want to end up damaging the backup and also leaving the server in an
|
||||
* state where there's control data saying it's in backup mode but there's no
|
||||
* backup_label in PGDATA.
|
||||
* If the user wants to do the switchover anyway, they should first stop the
|
||||
* If the DBA wants to do the switchover anyway, he should first stop the
|
||||
* backup that's running.
|
||||
*/
|
||||
if (server_in_exclusive_backup_mode(remote_conn) != BACKUP_STATE_NO_BACKUP)
|
||||
@@ -2983,7 +2980,6 @@ do_standby_switchover(void)
|
||||
{
|
||||
min_required_free_slots++;
|
||||
}
|
||||
|
||||
/*
|
||||
* If --force-rewind specified, check pg_rewind can be used, and
|
||||
* pre-emptively fetch the list of configuration files which should be
|
||||
@@ -3010,8 +3006,8 @@ do_standby_switchover(void)
|
||||
termPQExpBuffer(&reason);
|
||||
|
||||
initPQExpBuffer(&msg);
|
||||
appendPQExpBufferStr(&msg,
|
||||
_("prerequisites for using pg_rewind are met"));
|
||||
appendPQExpBuffer(&msg,
|
||||
_("prerequisites for using pg_rewind are met"));
|
||||
|
||||
if (runtime_options.dry_run == true)
|
||||
{
|
||||
@@ -3069,7 +3065,7 @@ do_standby_switchover(void)
|
||||
initPQExpBuffer(&remote_command_str);
|
||||
make_remote_repmgr_path(&remote_command_str, &remote_node_record);
|
||||
|
||||
appendPQExpBufferStr(&remote_command_str, "--version 2>/dev/null && echo \"1\" || echo \"0\"");
|
||||
appendPQExpBuffer(&remote_command_str, "--version 2>/dev/null && echo \"1\" || echo \"0\"");
|
||||
initPQExpBuffer(&command_output);
|
||||
command_success = remote_command(remote_host,
|
||||
runtime_options.remote_user,
|
||||
@@ -3091,8 +3087,8 @@ do_standby_switchover(void)
|
||||
termPQExpBuffer(&command_output);
|
||||
|
||||
initPQExpBuffer(&hint);
|
||||
appendPQExpBufferStr(&hint,
|
||||
_("check \"pg_bindir\" is set to the correct path in \"repmgr.conf\"; current value: "));
|
||||
appendPQExpBuffer(&hint,
|
||||
_("check \"pg_bindir\" is set to the correct path in \"repmgr.conf\"; current value: "));
|
||||
|
||||
if (strlen(config_file_options.pg_bindir))
|
||||
{
|
||||
@@ -3101,8 +3097,8 @@ do_standby_switchover(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&hint,
|
||||
"(not set)");
|
||||
appendPQExpBuffer(&hint,
|
||||
"(not set)");
|
||||
}
|
||||
|
||||
|
||||
@@ -3349,8 +3345,8 @@ do_standby_switchover(void)
|
||||
|
||||
initPQExpBuffer(&remote_command_str);
|
||||
make_remote_repmgr_path(&remote_command_str, &remote_node_record);
|
||||
appendPQExpBufferStr(&remote_command_str,
|
||||
"node check --terse -LERROR --archive-ready --optformat");
|
||||
appendPQExpBuffer(&remote_command_str,
|
||||
"node check --terse -LERROR --archive-ready --optformat");
|
||||
|
||||
initPQExpBuffer(&command_output);
|
||||
|
||||
@@ -3548,8 +3544,8 @@ do_standby_switchover(void)
|
||||
|
||||
log_debug("minimum of %i free slots (%i for siblings) required; %i available",
|
||||
min_required_free_slots,
|
||||
reachable_sibling_nodes_with_slot_count,
|
||||
available_slots);
|
||||
reachable_sibling_nodes_with_slot_count
|
||||
, available_slots);
|
||||
|
||||
if (available_slots < min_required_free_slots)
|
||||
{
|
||||
@@ -3579,156 +3575,6 @@ do_standby_switchover(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempt to pause all repmgrd instances, unless user explicitly
|
||||
* specifies not to.
|
||||
*/
|
||||
if (runtime_options.repmgrd_no_pause == false)
|
||||
{
|
||||
NodeInfoListCell *cell = NULL;
|
||||
ItemList repmgrd_connection_errors = {NULL, NULL};
|
||||
int i = 0;
|
||||
int unreachable_node_count = 0;
|
||||
|
||||
get_all_node_records(local_conn, &all_nodes);
|
||||
|
||||
repmgrd_info = (RepmgrdInfo **) pg_malloc0(sizeof(RepmgrdInfo *) * all_nodes.node_count);
|
||||
|
||||
for (cell = all_nodes.head; cell; cell = cell->next)
|
||||
{
|
||||
cell->node_info->conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
||||
|
||||
repmgrd_info[i] = pg_malloc0(sizeof(RepmgrdInfo));
|
||||
repmgrd_info[i]->node_id = cell->node_info->node_id;
|
||||
repmgrd_info[i]->pid = UNKNOWN_PID;
|
||||
repmgrd_info[i]->paused = false;
|
||||
repmgrd_info[i]->running = false;
|
||||
|
||||
if (PQstatus(cell->node_info->conn) != CONNECTION_OK)
|
||||
{
|
||||
/*
|
||||
* unable to connect; treat this as an error
|
||||
*/
|
||||
|
||||
repmgrd_info[i]->pg_running = false;
|
||||
|
||||
item_list_append_format(&repmgrd_connection_errors,
|
||||
_("unable to connect to node \"%s\" (ID %i)"),
|
||||
cell->node_info->node_name,
|
||||
cell->node_info->node_id);
|
||||
|
||||
unreachable_node_count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
repmgrd_info[i]->running = repmgrd_is_running(cell->node_info->conn);
|
||||
repmgrd_info[i]->pid = repmgrd_get_pid(cell->node_info->conn);
|
||||
repmgrd_info[i]->paused = repmgrd_is_paused(cell->node_info->conn);
|
||||
|
||||
if (repmgrd_info[i]->running == true)
|
||||
repmgrd_running_count++;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (unreachable_node_count > 0)
|
||||
{
|
||||
PQExpBufferData msg;
|
||||
PQExpBufferData detail;
|
||||
ItemListCell *cell;
|
||||
|
||||
initPQExpBuffer(&msg);
|
||||
appendPQExpBuffer(&msg,
|
||||
_("unable to connect to %i node(s), unable to pause all repmgrd instances"),
|
||||
unreachable_node_count);
|
||||
|
||||
initPQExpBuffer(&detail);
|
||||
|
||||
for (cell = repmgrd_connection_errors.head; cell; cell = cell->next)
|
||||
{
|
||||
appendPQExpBuffer(&detail,
|
||||
" %s\n",
|
||||
cell->string);
|
||||
}
|
||||
|
||||
|
||||
if (runtime_options.force == false)
|
||||
{
|
||||
log_error("%s", msg.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_warning("%s", msg.data);
|
||||
}
|
||||
|
||||
log_detail(_("following node(s) unreachable:\n%s"), detail.data);
|
||||
|
||||
termPQExpBuffer(&msg);
|
||||
termPQExpBuffer(&detail);
|
||||
|
||||
/* tell user about footgun */
|
||||
if (runtime_options.force == false)
|
||||
{
|
||||
log_hint(_("use -F/--force to continue anyway"));
|
||||
|
||||
clear_node_info_list(&sibling_nodes);
|
||||
clear_node_info_list(&all_nodes);
|
||||
|
||||
exit(ERR_SWITCHOVER_FAIL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (repmgrd_running_count > 0)
|
||||
{
|
||||
i = 0;
|
||||
for (cell = all_nodes.head; cell; cell = cell->next)
|
||||
{
|
||||
/*
|
||||
* Skip if node is already paused. Note we won't unpause these, to
|
||||
* leave the repmgrd instances in the cluster in the same state they
|
||||
* were before the switchover.
|
||||
*/
|
||||
if (repmgrd_info[i]->paused == true)
|
||||
{
|
||||
PQfinish(cell->node_info->conn);
|
||||
cell->node_info->conn = NULL;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (runtime_options.dry_run == true)
|
||||
{
|
||||
log_info(_("would pause repmgrd on node %s (ID %i)"),
|
||||
cell->node_info->node_name,
|
||||
cell->node_info->node_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* XXX check result */
|
||||
log_debug("pausing repmgrd on node %s (ID %i)",
|
||||
cell->node_info->node_name,
|
||||
cell->node_info->node_id);
|
||||
|
||||
(void) repmgrd_pause(cell->node_info->conn, true);
|
||||
}
|
||||
|
||||
PQfinish(cell->node_info->conn);
|
||||
cell->node_info->conn = NULL;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* close all connections - we'll reestablish later */
|
||||
for (cell = all_nodes.head; cell; cell = cell->next)
|
||||
{
|
||||
PQfinish(cell->node_info->conn);
|
||||
cell->node_info->conn = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Sanity checks completed - prepare for the switchover
|
||||
@@ -3769,8 +3615,8 @@ do_standby_switchover(void)
|
||||
|
||||
if (runtime_options.dry_run == true)
|
||||
{
|
||||
appendPQExpBufferStr(&remote_command_str,
|
||||
"node service --terse -LERROR --list-actions --action=stop");
|
||||
appendPQExpBuffer(&remote_command_str,
|
||||
"node service --terse -LERROR --list-actions --action=stop");
|
||||
|
||||
}
|
||||
else
|
||||
@@ -3778,8 +3624,8 @@ do_standby_switchover(void)
|
||||
log_notice(_("stopping current primary node \"%s\" (ID: %i)"),
|
||||
remote_node_record.node_name,
|
||||
remote_node_record.node_id);
|
||||
appendPQExpBufferStr(&remote_command_str,
|
||||
"node service --action=stop --checkpoint");
|
||||
appendPQExpBuffer(&remote_command_str,
|
||||
"node service --action=stop --checkpoint");
|
||||
}
|
||||
|
||||
/* XXX handle failure */
|
||||
@@ -3810,7 +3656,6 @@ do_standby_switchover(void)
|
||||
shutdown_command);
|
||||
|
||||
clear_node_info_list(&sibling_nodes);
|
||||
|
||||
key_value_list_free(&remote_config_files);
|
||||
|
||||
return;
|
||||
@@ -3821,14 +3666,13 @@ do_standby_switchover(void)
|
||||
|
||||
/* loop for timeout waiting for current primary to stop */
|
||||
|
||||
for (i = 0; i < config_file_options.shutdown_check_timeout; i++)
|
||||
for (i = 0; i < config_file_options.reconnect_attempts; i++)
|
||||
{
|
||||
/* Check whether primary is available */
|
||||
PGPing ping_res;
|
||||
|
||||
log_info(_("checking for primary shutdown; %i of %i attempts (\"shutdown_check_timeout\")"),
|
||||
i + 1, config_file_options.shutdown_check_timeout);
|
||||
|
||||
log_info(_("checking primary status; %i of %i attempts"),
|
||||
i + 1, config_file_options.reconnect_attempts);
|
||||
ping_res = PQping(remote_conninfo);
|
||||
|
||||
log_debug("ping status is: %s", print_pqping_status(ping_res));
|
||||
@@ -3847,8 +3691,8 @@ do_standby_switchover(void)
|
||||
|
||||
initPQExpBuffer(&remote_command_str);
|
||||
make_remote_repmgr_path(&remote_command_str, &remote_node_record);
|
||||
appendPQExpBufferStr(&remote_command_str,
|
||||
"node status --is-shutdown-cleanly");
|
||||
appendPQExpBuffer(&remote_command_str,
|
||||
"node status --is-shutdown-cleanly");
|
||||
|
||||
initPQExpBuffer(&command_output);
|
||||
|
||||
@@ -3897,8 +3741,9 @@ do_standby_switchover(void)
|
||||
termPQExpBuffer(&command_output);
|
||||
}
|
||||
|
||||
log_debug("sleeping 1 second until next check");
|
||||
sleep(1);
|
||||
log_debug("sleeping %i seconds (\"reconnect_interval\") until next check",
|
||||
config_file_options.reconnect_interval);
|
||||
sleep(config_file_options.reconnect_interval);
|
||||
}
|
||||
|
||||
if (shutdown_success == false)
|
||||
@@ -3948,7 +3793,7 @@ do_standby_switchover(void)
|
||||
|
||||
|
||||
/*
|
||||
* If pg_rewind is requested, issue a checkpoint immediately after promoting
|
||||
* if pg_rewind is requested, issue a checkpoint immediately after promoting
|
||||
* the local node, as pg_rewind compares timelines on the basis of the value
|
||||
* in pg_control, which is written at the first checkpoint, which might not
|
||||
* occur immediately.
|
||||
@@ -3960,7 +3805,7 @@ do_standby_switchover(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute "repmgr node rejoin" to create recovery.conf and start the
|
||||
* Execute `repmgr node rejoin` to create recovery.conf and start the
|
||||
* remote server. Additionally execute "pg_rewind", if required and
|
||||
* requested.
|
||||
*/
|
||||
@@ -3974,13 +3819,12 @@ do_standby_switchover(void)
|
||||
{
|
||||
log_error(_("new primary diverges from former primary and --force-rewind not provided"));
|
||||
log_hint(_("the former primary will need to be restored manually, or use \"repmgr node rejoin\""));
|
||||
|
||||
termPQExpBuffer(&node_rejoin_options);
|
||||
PQfinish(local_conn);
|
||||
exit(ERR_SWITCHOVER_FAIL);
|
||||
}
|
||||
|
||||
appendPQExpBufferStr(&node_rejoin_options,
|
||||
appendPQExpBuffer(&node_rejoin_options,
|
||||
" --force-rewind");
|
||||
|
||||
if (runtime_options.force_rewind_path[0] != '\0')
|
||||
@@ -3989,20 +3833,20 @@ do_standby_switchover(void)
|
||||
"=%s",
|
||||
runtime_options.force_rewind_path);
|
||||
}
|
||||
appendPQExpBufferStr(&node_rejoin_options,
|
||||
" --config-files=");
|
||||
appendPQExpBuffer(&node_rejoin_options,
|
||||
" --config-files=");
|
||||
|
||||
for (cell = remote_config_files.head; cell; cell = cell->next)
|
||||
{
|
||||
if (first_entry == false)
|
||||
appendPQExpBufferChar(&node_rejoin_options, ',');
|
||||
appendPQExpBuffer(&node_rejoin_options, ",");
|
||||
else
|
||||
first_entry = false;
|
||||
|
||||
appendPQExpBufferStr(&node_rejoin_options, cell->key);
|
||||
appendPQExpBuffer(&node_rejoin_options, "%s", cell->key);
|
||||
}
|
||||
|
||||
appendPQExpBufferChar(&node_rejoin_options, ' ');
|
||||
appendPQExpBuffer(&node_rejoin_options, " ");
|
||||
}
|
||||
|
||||
key_value_list_free(&remote_config_files);
|
||||
@@ -4031,7 +3875,7 @@ do_standby_switchover(void)
|
||||
|
||||
if (command_success == false)
|
||||
{
|
||||
log_error(_("rejoin failed with error code %i"), r);
|
||||
log_error(_("rejoin failed %i"), r);
|
||||
|
||||
create_event_notification_extended(local_conn,
|
||||
&config_file_options,
|
||||
@@ -4096,30 +3940,14 @@ do_standby_switchover(void)
|
||||
|
||||
if (sibling_node_record.type == WITNESS)
|
||||
{
|
||||
/* TODO: create "repmgr witness resync" or similar */
|
||||
appendPQExpBuffer(&remote_command_str,
|
||||
"witness register -d \\'%s\\' --force 2>/dev/null && echo \"1\" || echo \"0\"",
|
||||
local_node_record.conninfo);
|
||||
|
||||
/*
|
||||
* Notify the witness repmgrd about the new primary, as at this point it will be assuming
|
||||
* a failover situation is in place. It will detect the new primary at some point, this
|
||||
* just speeds up the process.
|
||||
*
|
||||
* In the unlikely event repmgrd is not running or not in use, this will have no effect.
|
||||
*/
|
||||
cell->node_info->conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
||||
|
||||
if (PQstatus(cell->node_info->conn) == CONNECTION_OK)
|
||||
{
|
||||
notify_follow_primary(cell->node_info->conn, local_node_record.node_id);
|
||||
}
|
||||
PQfinish(cell->node_info->conn);
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&remote_command_str,
|
||||
"standby follow 2>/dev/null && echo \"1\" || echo \"0\"");
|
||||
appendPQExpBuffer(&remote_command_str,
|
||||
"standby follow 2>/dev/null && echo \"1\" || echo \"0\"");
|
||||
}
|
||||
get_conninfo_value(cell->node_info->conninfo, "host", host);
|
||||
log_debug("executing:\n %s", remote_command_str.data);
|
||||
@@ -4172,8 +4000,8 @@ do_standby_switchover(void)
|
||||
PQfinish(local_conn);
|
||||
|
||||
/*
|
||||
* Clean up remote node (primary demoted to standby). It's possible that the node is
|
||||
* still starting up, so poll for a while until we get a connection.
|
||||
* Clean up remote node. It's possible that the standby is still starting up,
|
||||
* so poll for a while until we get a connection.
|
||||
*/
|
||||
|
||||
for (i = 0; i < config_file_options.standby_reconnect_timeout; i++)
|
||||
@@ -4225,84 +4053,6 @@ do_standby_switchover(void)
|
||||
|
||||
PQfinish(remote_conn);
|
||||
|
||||
/*
|
||||
* Attempt to unpause all paused repmgrd instances, unless user explicitly
|
||||
* specifies not to.
|
||||
*/
|
||||
if (runtime_options.repmgrd_no_pause == false)
|
||||
{
|
||||
if (repmgrd_running_count > 0)
|
||||
{
|
||||
ItemList repmgrd_unpause_errors = {NULL, NULL};
|
||||
NodeInfoListCell *cell = NULL;
|
||||
int i = 0;
|
||||
int error_node_count = 0;
|
||||
|
||||
for (cell = all_nodes.head; cell; cell = cell->next)
|
||||
{
|
||||
|
||||
if (repmgrd_info[i]->paused == true)
|
||||
{
|
||||
log_debug("repmgrd on node %s (ID %i) paused before switchover, not unpausing",
|
||||
cell->node_info->node_name,
|
||||
cell->node_info->node_id);
|
||||
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
log_debug("unpausing repmgrd on node %s (ID %i)",
|
||||
cell->node_info->node_name,
|
||||
cell->node_info->node_id);
|
||||
|
||||
cell->node_info->conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
||||
|
||||
if (PQstatus(cell->node_info->conn) == CONNECTION_OK)
|
||||
{
|
||||
if (repmgrd_pause(cell->node_info->conn, false) == false)
|
||||
{
|
||||
item_list_append_format(&repmgrd_unpause_errors,
|
||||
_("unable to unpause node \"%s\" (ID %i)"),
|
||||
cell->node_info->node_name,
|
||||
cell->node_info->node_id);
|
||||
error_node_count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item_list_append_format(&repmgrd_unpause_errors,
|
||||
_("unable to connect to node \"%s\" (ID %i)"),
|
||||
cell->node_info->node_name,
|
||||
cell->node_info->node_id);
|
||||
error_node_count++;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (error_node_count > 0)
|
||||
{
|
||||
PQExpBufferData detail;
|
||||
ItemListCell *cell;
|
||||
|
||||
for (cell = repmgrd_unpause_errors.head; cell; cell = cell->next)
|
||||
{
|
||||
appendPQExpBuffer(&detail,
|
||||
" %s\n",
|
||||
cell->string);
|
||||
}
|
||||
|
||||
log_warning(_("unable to unpause repmgrd on %i node(s)"),
|
||||
error_node_count);
|
||||
log_detail(_("errors encountered for following node(s):\n%s"), detail.data);
|
||||
log_hint(_("check node connection and status; unpause manually with \"repmgr daemon unpause\""));
|
||||
|
||||
termPQExpBuffer(&detail);
|
||||
}
|
||||
}
|
||||
|
||||
clear_node_info_list(&all_nodes);
|
||||
}
|
||||
|
||||
if (switchover_success == true)
|
||||
{
|
||||
@@ -5275,7 +5025,7 @@ run_basebackup(t_node_info *node_record)
|
||||
|
||||
if (runtime_options.fast_checkpoint)
|
||||
{
|
||||
appendPQExpBufferStr(¶ms, " -c fast");
|
||||
appendPQExpBuffer(¶ms, " -c fast");
|
||||
}
|
||||
|
||||
if (config_file_options.tablespace_mapping.head != NULL)
|
||||
@@ -5297,7 +5047,7 @@ run_basebackup(t_node_info *node_record)
|
||||
*/
|
||||
if (!strlen(backup_options.xlog_method))
|
||||
{
|
||||
appendPQExpBufferStr(¶ms, " -X stream");
|
||||
appendPQExpBuffer(¶ms, " -X stream");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -6337,8 +6087,8 @@ create_recovery_file(t_node_info *node_record, t_conninfo_param_list *recovery_c
|
||||
initPQExpBuffer(&recovery_file_buf);
|
||||
|
||||
/* standby_mode = 'on' */
|
||||
appendPQExpBufferStr(&recovery_file_buf,
|
||||
"standby_mode = 'on'\n");
|
||||
appendPQExpBuffer(&recovery_file_buf,
|
||||
"standby_mode = 'on'\n");
|
||||
|
||||
/* primary_conninfo = '...' */
|
||||
|
||||
@@ -6366,8 +6116,8 @@ create_recovery_file(t_node_info *node_record, t_conninfo_param_list *recovery_c
|
||||
}
|
||||
|
||||
/* recovery_target_timeline = 'latest' */
|
||||
appendPQExpBufferStr(&recovery_file_buf,
|
||||
"recovery_target_timeline = 'latest'\n");
|
||||
appendPQExpBuffer(&recovery_file_buf,
|
||||
"recovery_target_timeline = 'latest'\n");
|
||||
|
||||
|
||||
/* recovery_min_apply_delay = ... (optional) */
|
||||
@@ -6500,12 +6250,12 @@ write_primary_conninfo(PQExpBufferData *dest, t_conninfo_param_list *param_list)
|
||||
{
|
||||
if (strlen(config_file_options.node_name))
|
||||
{
|
||||
appendPQExpBufferStr(&conninfo_buf, " application_name=");
|
||||
appendPQExpBuffer(&conninfo_buf, " application_name=");
|
||||
appendConnStrVal(&conninfo_buf, config_file_options.node_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&conninfo_buf, " application_name=repmgr");
|
||||
appendPQExpBuffer(&conninfo_buf, " application_name=repmgr");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6518,7 +6268,7 @@ write_primary_conninfo(PQExpBufferData *dest, t_conninfo_param_list *param_list)
|
||||
|
||||
if (password != NULL)
|
||||
{
|
||||
appendPQExpBufferStr(&conninfo_buf, " password=");
|
||||
appendPQExpBuffer(&conninfo_buf, " password=");
|
||||
appendConnStrVal(&conninfo_buf, password);
|
||||
}
|
||||
}
|
||||
@@ -6530,7 +6280,7 @@ write_primary_conninfo(PQExpBufferData *dest, t_conninfo_param_list *param_list)
|
||||
/* check if the libpq we're using supports "passfile=" */
|
||||
if (has_passfile() == true)
|
||||
{
|
||||
appendPQExpBufferStr(&conninfo_buf, " passfile=");
|
||||
appendPQExpBuffer(&conninfo_buf, " passfile=");
|
||||
appendConnStrVal(&conninfo_buf, config_file_options.passfile);
|
||||
}
|
||||
}
|
||||
@@ -6852,7 +6602,6 @@ do_standby_help(void)
|
||||
printf(_(" (9.3 and 9.4 - provide \"pg_rewind\" path)\n"));
|
||||
|
||||
printf(_(" -R, --remote-user=USERNAME database server username for SSH operations (default: \"%s\")\n"), runtime_options.username);
|
||||
printf(_(" --repmgrd-no-pause don't pause repmgrd\n"));
|
||||
printf(_(" --siblings-follow have other standbys follow new primary\n"));
|
||||
|
||||
puts("");
|
||||
|
||||
@@ -218,13 +218,7 @@ do_witness_register(void)
|
||||
* if repmgr.nodes contains entries, delete if -F/--force provided,
|
||||
* otherwise exit with error
|
||||
*/
|
||||
if (get_all_node_records(witness_conn, &nodes) == false)
|
||||
{
|
||||
/* get_all_node_records() will display the error */
|
||||
PQfinish(witness_conn);
|
||||
PQfinish(primary_conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
get_all_node_records(witness_conn, &nodes);
|
||||
|
||||
log_verbose(LOG_DEBUG, "%i node records found", nodes.node_count);
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ typedef struct
|
||||
bool force_rewind_used;
|
||||
char force_rewind_path[MAXPGPATH];
|
||||
bool siblings_follow;
|
||||
bool repmgrd_no_pause;
|
||||
|
||||
/* "node status" options */
|
||||
bool is_shutdown_cleanly;
|
||||
@@ -157,7 +156,7 @@ typedef struct
|
||||
/* "standby register" options */ \
|
||||
false, -1, DEFAULT_WAIT_START, \
|
||||
/* "standby switchover" options */ \
|
||||
false, false, "", false, false, \
|
||||
false, false, "", false, \
|
||||
/* "node status" options */ \
|
||||
false, \
|
||||
/* "node check" options */ \
|
||||
@@ -194,14 +193,6 @@ typedef enum
|
||||
} t_server_action;
|
||||
|
||||
|
||||
typedef struct ColHeader
|
||||
{
|
||||
char title[MAXLEN];
|
||||
int max_length;
|
||||
int cur_length;
|
||||
} ColHeader;
|
||||
|
||||
|
||||
|
||||
/* global configuration structures */
|
||||
extern t_runtime_options runtime_options;
|
||||
@@ -237,10 +228,7 @@ extern void get_superuser_connection(PGconn **conn, PGconn **superuser_conn, PGc
|
||||
extern bool remote_command(const char *host, const char *user, const char *command, PQExpBufferData *outputbuf);
|
||||
|
||||
extern void make_remote_repmgr_path(PQExpBufferData *outputbuf, t_node_info *remote_node_record);
|
||||
|
||||
/* display functions */
|
||||
extern void print_help_header(void);
|
||||
extern void print_status_header(int cols, ColHeader *headers);
|
||||
|
||||
/* server control functions */
|
||||
extern void get_server_action(t_server_action action, char *script, char *data_dir);
|
||||
|
||||
119
repmgr-client.c
119
repmgr-client.c
@@ -30,15 +30,10 @@
|
||||
* NODE STATUS
|
||||
* NODE CHECK
|
||||
*
|
||||
* DAEMON STATUS
|
||||
* DAEMON PAUSE
|
||||
* DAEMON UNPAUSE
|
||||
*
|
||||
* For internal use:
|
||||
* NODE REJOIN
|
||||
* NODE SERVICE
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
@@ -67,7 +62,6 @@
|
||||
#include "repmgr-action-bdr.h"
|
||||
#include "repmgr-action-node.h"
|
||||
#include "repmgr-action-cluster.h"
|
||||
#include "repmgr-action-daemon.h"
|
||||
|
||||
#include <storage/fd.h> /* for PG_TEMP_FILE_PREFIX */
|
||||
|
||||
@@ -444,10 +438,6 @@ main(int argc, char **argv)
|
||||
runtime_options.siblings_follow = true;
|
||||
break;
|
||||
|
||||
case OPT_REPMGRD_NO_PAUSE:
|
||||
runtime_options.repmgrd_no_pause = true;
|
||||
break;
|
||||
|
||||
/*----------------------
|
||||
* "node status" options
|
||||
*----------------------
|
||||
@@ -910,21 +900,6 @@ main(int argc, char **argv)
|
||||
else if (strcasecmp(repmgr_action, "CLEANUP") == 0)
|
||||
action = CLUSTER_CLEANUP;
|
||||
}
|
||||
else if (strcasecmp(repmgr_command, "DAEMON") == 0)
|
||||
{
|
||||
if (help_option == true)
|
||||
{
|
||||
do_daemon_help();
|
||||
exit(SUCCESS);
|
||||
}
|
||||
|
||||
if (strcasecmp(repmgr_action, "STATUS") == 0)
|
||||
action = DAEMON_STATUS;
|
||||
else if (strcasecmp(repmgr_action, "PAUSE") == 0)
|
||||
action = DAEMON_PAUSE;
|
||||
else if (strcasecmp(repmgr_action, "UNPAUSE") == 0)
|
||||
action = DAEMON_UNPAUSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
valid_repmgr_command_found = false;
|
||||
@@ -1323,17 +1298,6 @@ main(int argc, char **argv)
|
||||
do_cluster_cleanup();
|
||||
break;
|
||||
|
||||
/* DAEMON */
|
||||
case DAEMON_STATUS:
|
||||
do_daemon_status();
|
||||
break;
|
||||
case DAEMON_PAUSE:
|
||||
do_daemon_pause();
|
||||
break;
|
||||
case DAEMON_UNPAUSE:
|
||||
do_daemon_unpause();
|
||||
break;
|
||||
|
||||
default:
|
||||
/* An action will have been determined by this point */
|
||||
break;
|
||||
@@ -1556,7 +1520,6 @@ check_cli_parameters(const int action)
|
||||
case PRIMARY_UNREGISTER:
|
||||
case STANDBY_UNREGISTER:
|
||||
case WITNESS_UNREGISTER:
|
||||
case CLUSTER_CLEANUP:
|
||||
case CLUSTER_EVENT:
|
||||
case CLUSTER_MATRIX:
|
||||
case CLUSTER_CROSSCHECK:
|
||||
@@ -1780,18 +1743,6 @@ check_cli_parameters(const int action)
|
||||
}
|
||||
}
|
||||
|
||||
if (runtime_options.repmgrd_no_pause == true)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case STANDBY_SWITCHOVER:
|
||||
break;
|
||||
default:
|
||||
item_list_append_format(&cli_warnings,
|
||||
_("--repmgrd-no-pause will be ignored when executing %s"),
|
||||
action_name(action));
|
||||
}
|
||||
}
|
||||
|
||||
if (runtime_options.config_files[0] != '\0')
|
||||
{
|
||||
@@ -1820,8 +1771,6 @@ check_cli_parameters(const int action)
|
||||
case WITNESS_UNREGISTER:
|
||||
case NODE_REJOIN:
|
||||
case NODE_SERVICE:
|
||||
case DAEMON_PAUSE:
|
||||
case DAEMON_UNPAUSE:
|
||||
break;
|
||||
default:
|
||||
item_list_append_format(&cli_warnings,
|
||||
@@ -1901,14 +1850,6 @@ action_name(const int action)
|
||||
return "CLUSTER MATRIX";
|
||||
case CLUSTER_CROSSCHECK:
|
||||
return "CLUSTER CROSSCHECK";
|
||||
|
||||
case DAEMON_STATUS:
|
||||
return "DAEMON STATUS";
|
||||
case DAEMON_PAUSE:
|
||||
return "DAEMON PAUSE";
|
||||
case DAEMON_UNPAUSE:
|
||||
return "DAEMON UNPAUSE";
|
||||
|
||||
}
|
||||
|
||||
return "UNKNOWN ACTION";
|
||||
@@ -1936,42 +1877,6 @@ print_error_list(ItemList *error_list, int log_level)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
print_status_header(int cols, ColHeader *headers)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < cols; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
printf(" ");
|
||||
else
|
||||
printf(" | ");
|
||||
|
||||
printf("%-*s",
|
||||
headers[i].max_length,
|
||||
headers[i].title);
|
||||
}
|
||||
printf("\n");
|
||||
printf("-");
|
||||
|
||||
for (i = 0; i < cols; i++)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = 0; j < headers[i].max_length; j++)
|
||||
printf("-");
|
||||
|
||||
if (i < (cols - 1))
|
||||
printf("-+-");
|
||||
else
|
||||
printf("-");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
print_help_header(void)
|
||||
{
|
||||
@@ -2000,7 +1905,6 @@ do_help(void)
|
||||
printf(_(" %s [OPTIONS] node {status|check|rejoin|service}\n"), progname());
|
||||
printf(_(" %s [OPTIONS] cluster {show|event|matrix|crosscheck|cleanup}\n"), progname());
|
||||
printf(_(" %s [OPTIONS] witness {register|unregister}\n"), progname());
|
||||
printf(_(" %s [OPTIONS] daemon {status|pause|unpause}\n"), progname());
|
||||
|
||||
puts("");
|
||||
|
||||
@@ -2672,29 +2576,11 @@ remote_command(const char *host, const char *user, const char *command, PQExpBuf
|
||||
void
|
||||
make_remote_repmgr_path(PQExpBufferData *output_buf, t_node_info *remote_node_record)
|
||||
{
|
||||
if (config_file_options.repmgr_bindir[0] != '\0')
|
||||
{
|
||||
int len = strlen(config_file_options.repmgr_bindir);
|
||||
|
||||
appendPQExpBufferStr(output_buf,
|
||||
config_file_options.repmgr_bindir);
|
||||
|
||||
/* Add trailing slash */
|
||||
if (config_file_options.repmgr_bindir[len - 1] != '/')
|
||||
{
|
||||
appendPQExpBufferChar(output_buf, '/');
|
||||
}
|
||||
}
|
||||
else if (pg_bindir[0] != '\0')
|
||||
{
|
||||
appendPQExpBufferStr(output_buf,
|
||||
pg_bindir);
|
||||
}
|
||||
|
||||
appendPQExpBuffer(output_buf,
|
||||
"%s -f %s ",
|
||||
progname(),
|
||||
make_pg_path(progname()),
|
||||
remote_node_record->config_file);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3134,3 +3020,4 @@ drop_replication_slot_if_exists(PGconn *conn, int node_id, char *slot_name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,6 @@
|
||||
#define CLUSTER_MATRIX 19
|
||||
#define CLUSTER_CROSSCHECK 20
|
||||
#define CLUSTER_EVENT 21
|
||||
#define DAEMON_STATUS 22
|
||||
#define DAEMON_PAUSE 23
|
||||
#define DAEMON_UNPAUSE 24
|
||||
|
||||
/* command line options without short versions */
|
||||
#define OPT_HELP 1001
|
||||
@@ -91,7 +88,6 @@
|
||||
#define OPT_RECOVERY_CONF_ONLY 1039
|
||||
#define OPT_NO_WAIT 1040
|
||||
#define OPT_MISSING_SLOTS 1041
|
||||
#define OPT_REPMGRD_NO_PAUSE 1042
|
||||
|
||||
/* deprecated since 3.3 */
|
||||
#define OPT_DATA_DIR 999
|
||||
@@ -160,7 +156,6 @@ static struct option long_options[] =
|
||||
*/
|
||||
{"always-promote", no_argument, NULL, OPT_ALWAYS_PROMOTE},
|
||||
{"siblings-follow", no_argument, NULL, OPT_SIBLINGS_FOLLOW},
|
||||
{"repmgrd-no-pause", no_argument, NULL, OPT_REPMGRD_NO_PAUSE},
|
||||
|
||||
/* "node status" options */
|
||||
{"is-shutdown-cleanly", no_argument, NULL, OPT_IS_SHUTDOWN_CLEANLY},
|
||||
|
||||
264
repmgr.c
264
repmgr.c
@@ -26,7 +26,6 @@
|
||||
#include "access/xlog.h"
|
||||
#include "miscadmin.h"
|
||||
#include "replication/walreceiver.h"
|
||||
#include "storage/fd.h"
|
||||
#include "storage/ipc.h"
|
||||
#include "storage/lwlock.h"
|
||||
#include "storage/procarray.h"
|
||||
@@ -44,21 +43,14 @@
|
||||
#include "lib/stringinfo.h"
|
||||
#include "access/xact.h"
|
||||
#include "utils/snapmgr.h"
|
||||
|
||||
#if (PG_VERSION_NUM >= 90400)
|
||||
#include "pgstat.h"
|
||||
#else
|
||||
#define PGSTAT_STAT_PERMANENT_DIRECTORY "pg_stat"
|
||||
#endif
|
||||
|
||||
|
||||
#include "voting.h"
|
||||
|
||||
#define UNKNOWN_NODE_ID -1
|
||||
#define UNKNOWN_PID -1
|
||||
|
||||
#define TRANCHE_NAME "repmgrd"
|
||||
#define REPMGRD_STATE_FILE PGSTAT_STAT_PERMANENT_DIRECTORY "/repmgrd_state.txt"
|
||||
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
@@ -74,9 +66,6 @@ typedef struct repmgrdSharedState
|
||||
LWLockId lock; /* protects search/modification */
|
||||
TimestampTz last_updated;
|
||||
int local_node_id;
|
||||
int repmgrd_pid;
|
||||
char repmgrd_pidfile[MAXPGPATH];
|
||||
bool repmgrd_paused;
|
||||
/* streaming failover */
|
||||
NodeVotingStatus voting_status;
|
||||
int current_electoral_term;
|
||||
@@ -123,25 +112,6 @@ PG_FUNCTION_INFO_V1(am_bdr_failover_handler);
|
||||
Datum unset_bdr_failover_handler(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(unset_bdr_failover_handler);
|
||||
|
||||
Datum set_repmgrd_pid(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(set_repmgrd_pid);
|
||||
|
||||
Datum get_repmgrd_pid(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(get_repmgrd_pid);
|
||||
|
||||
Datum get_repmgrd_pidfile(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(get_repmgrd_pidfile);
|
||||
|
||||
Datum repmgrd_is_running(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(repmgrd_is_running);
|
||||
|
||||
Datum repmgrd_pause(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(repmgrd_pause);
|
||||
|
||||
Datum repmgrd_is_paused(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(repmgrd_is_paused);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Module load callback
|
||||
@@ -215,9 +185,6 @@ repmgr_shmem_startup(void)
|
||||
#endif
|
||||
|
||||
shared_state->local_node_id = UNKNOWN_NODE_ID;
|
||||
shared_state->repmgrd_pid = UNKNOWN_PID;
|
||||
memset(shared_state->repmgrd_pidfile, 0, MAXPGPATH);
|
||||
shared_state->repmgrd_paused = false;
|
||||
shared_state->current_electoral_term = 0;
|
||||
shared_state->voting_status = VS_NO_VOTE;
|
||||
shared_state->candidate_node_id = UNKNOWN_NODE_ID;
|
||||
@@ -237,8 +204,6 @@ Datum
|
||||
set_local_node_id(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int local_node_id = UNKNOWN_NODE_ID;
|
||||
int stored_node_id = UNKNOWN_NODE_ID;
|
||||
int paused = -1;
|
||||
|
||||
if (!shared_state)
|
||||
PG_RETURN_NULL();
|
||||
@@ -248,34 +213,6 @@ set_local_node_id(PG_FUNCTION_ARGS)
|
||||
|
||||
local_node_id = PG_GETARG_INT32(0);
|
||||
|
||||
/* read state file and if exists/valid, update "repmgrd_paused" */
|
||||
{
|
||||
FILE *file = NULL;
|
||||
|
||||
file = AllocateFile(REPMGRD_STATE_FILE, PG_BINARY_R);
|
||||
|
||||
if (file != NULL)
|
||||
{
|
||||
int buffer_size = 128;
|
||||
char buffer[buffer_size];
|
||||
|
||||
if (fgets(buffer, buffer_size, file) != NULL)
|
||||
{
|
||||
if (sscanf(buffer, "%i:%i", &stored_node_id, &paused) != 2)
|
||||
{
|
||||
elog(WARNING, "unable to parse repmgrd state file");
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(DEBUG1, "node_id: %i; paused: %i", stored_node_id, paused);
|
||||
}
|
||||
}
|
||||
|
||||
FreeFile(file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LWLockAcquire(shared_state->lock, LW_EXCLUSIVE);
|
||||
|
||||
/* only set local_node_id once, as it should never change */
|
||||
@@ -284,19 +221,6 @@ set_local_node_id(PG_FUNCTION_ARGS)
|
||||
shared_state->local_node_id = local_node_id;
|
||||
}
|
||||
|
||||
/* only update if state file valid */
|
||||
if (stored_node_id == shared_state->local_node_id)
|
||||
{
|
||||
if (paused == 0)
|
||||
{
|
||||
shared_state->repmgrd_paused = false;
|
||||
}
|
||||
else if (paused == 1)
|
||||
{
|
||||
shared_state->repmgrd_paused = true;
|
||||
}
|
||||
}
|
||||
|
||||
LWLockRelease(shared_state->lock);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
@@ -492,191 +416,9 @@ unset_bdr_failover_handler(PG_FUNCTION_ARGS)
|
||||
LWLockAcquire(shared_state->lock, LW_EXCLUSIVE);
|
||||
|
||||
shared_state->bdr_failover_handler = UNKNOWN_NODE_ID;
|
||||
}
|
||||
|
||||
LWLockRelease(shared_state->lock);
|
||||
LWLockRelease(shared_state->lock);
|
||||
}
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns the repmgrd pid; or NULL if none set; or -1 if set but repmgrd
|
||||
* process not running (TODO!)
|
||||
*/
|
||||
Datum
|
||||
get_repmgrd_pid(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int repmgrd_pid = UNKNOWN_PID;
|
||||
|
||||
if (!shared_state)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
||||
repmgrd_pid = shared_state->repmgrd_pid;
|
||||
LWLockRelease(shared_state->lock);
|
||||
|
||||
PG_RETURN_INT32(repmgrd_pid);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns the repmgrd pidfile
|
||||
*/
|
||||
Datum
|
||||
get_repmgrd_pidfile(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char repmgrd_pidfile[MAXPGPATH];
|
||||
|
||||
if (!shared_state)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
memset(repmgrd_pidfile, 0, MAXPGPATH);
|
||||
|
||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
||||
strncpy(repmgrd_pidfile, shared_state->repmgrd_pidfile, MAXPGPATH);
|
||||
LWLockRelease(shared_state->lock);
|
||||
|
||||
if (repmgrd_pidfile[0] == '\0')
|
||||
PG_RETURN_NULL();
|
||||
|
||||
PG_RETURN_TEXT_P(cstring_to_text(repmgrd_pidfile));
|
||||
}
|
||||
|
||||
Datum
|
||||
set_repmgrd_pid(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int repmgrd_pid = UNKNOWN_PID;
|
||||
char *repmgrd_pidfile = NULL;
|
||||
|
||||
if (!shared_state)
|
||||
PG_RETURN_VOID();
|
||||
|
||||
if (PG_ARGISNULL(0))
|
||||
{
|
||||
repmgrd_pid = UNKNOWN_PID;
|
||||
}
|
||||
else
|
||||
{
|
||||
repmgrd_pid = PG_GETARG_INT32(0);
|
||||
}
|
||||
|
||||
elog(DEBUG3, "set_repmgrd_pid(): provided pid is %i", repmgrd_pid);
|
||||
|
||||
if (repmgrd_pid != UNKNOWN_PID && !PG_ARGISNULL(1))
|
||||
{
|
||||
repmgrd_pidfile = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||
elog(INFO, "set_repmgrd_pid(): provided pidfile is %s", repmgrd_pidfile);
|
||||
}
|
||||
|
||||
LWLockAcquire(shared_state->lock, LW_EXCLUSIVE);
|
||||
|
||||
shared_state->repmgrd_pid = repmgrd_pid;
|
||||
memset(shared_state->repmgrd_pidfile, 0, MAXPGPATH);
|
||||
|
||||
if(repmgrd_pidfile != NULL)
|
||||
{
|
||||
strncpy(shared_state->repmgrd_pidfile, repmgrd_pidfile, MAXPGPATH);
|
||||
}
|
||||
|
||||
LWLockRelease(shared_state->lock);
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
|
||||
Datum
|
||||
repmgrd_is_running(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int repmgrd_pid = UNKNOWN_PID;
|
||||
int kill_ret;
|
||||
|
||||
if (!shared_state)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
||||
repmgrd_pid = shared_state->repmgrd_pid;
|
||||
LWLockRelease(shared_state->lock);
|
||||
|
||||
/* No PID registered - assume not running */
|
||||
if (repmgrd_pid == UNKNOWN_PID)
|
||||
{
|
||||
PG_RETURN_BOOL(false);
|
||||
}
|
||||
|
||||
kill_ret = kill(repmgrd_pid, 0);
|
||||
|
||||
if (kill_ret == 0)
|
||||
{
|
||||
PG_RETURN_BOOL(true);
|
||||
}
|
||||
|
||||
PG_RETURN_BOOL(false);
|
||||
}
|
||||
|
||||
|
||||
Datum
|
||||
repmgrd_pause(PG_FUNCTION_ARGS)
|
||||
{
|
||||
bool pause;
|
||||
FILE *file = NULL;
|
||||
StringInfoData buf;
|
||||
|
||||
if (!shared_state)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
if (PG_ARGISNULL(0))
|
||||
PG_RETURN_NULL();
|
||||
|
||||
pause = PG_GETARG_BOOL(0);
|
||||
|
||||
LWLockAcquire(shared_state->lock, LW_EXCLUSIVE);
|
||||
shared_state->repmgrd_paused = pause;
|
||||
LWLockRelease(shared_state->lock);
|
||||
|
||||
/* write state to file */
|
||||
file = AllocateFile(REPMGRD_STATE_FILE, PG_BINARY_W);
|
||||
|
||||
if (file == NULL)
|
||||
{
|
||||
elog(DEBUG1, "unable to allocate %s", REPMGRD_STATE_FILE);
|
||||
|
||||
// XXX anything else we can do? log?
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
elog(DEBUG1, "allocated");
|
||||
|
||||
initStringInfo(&buf);
|
||||
|
||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
||||
|
||||
appendStringInfo(&buf, "%i:%i",
|
||||
shared_state->local_node_id,
|
||||
pause ? 1 : 0);
|
||||
LWLockRelease(shared_state->lock);
|
||||
|
||||
// XXX check success
|
||||
fwrite(buf.data, strlen(buf.data) + 1, 1, file);
|
||||
|
||||
|
||||
resetStringInfo(&buf);
|
||||
FreeFile(file);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
|
||||
Datum
|
||||
repmgrd_is_paused(PG_FUNCTION_ARGS)
|
||||
{
|
||||
bool is_paused;
|
||||
|
||||
if (!shared_state)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
||||
is_paused = shared_state->repmgrd_paused;
|
||||
LWLockRelease(shared_state->lock);
|
||||
|
||||
PG_RETURN_BOOL(is_paused);
|
||||
}
|
||||
|
||||
@@ -147,11 +147,7 @@
|
||||
# *NOTE* "pg_bindir" is only used when repmgr directly
|
||||
# executes PostgreSQL binaries; any user-defined scripts
|
||||
# *must* be specified with the full path
|
||||
|
||||
#repmgr_bindir='' # Path to repmgr binary directory (location of the repmgr
|
||||
# binary. Only needed if the repmgr executable is not in
|
||||
# the system $PATH or the path defined in "pg_bindir".
|
||||
|
||||
#
|
||||
#use_primary_conninfo_password=false # explicitly set "password" in recovery.conf's
|
||||
# "primary_conninfo" parameter using the value contained
|
||||
# in the environment variable PGPASSWORD
|
||||
@@ -165,7 +161,7 @@
|
||||
# Examples:
|
||||
#
|
||||
# pg_ctl_options='-s'
|
||||
# pg_basebackup_options='--label=repmgr_backup'
|
||||
# pg_basebackup_options='--label=repmgr_backup
|
||||
# rsync_options=--archive --checksum --compress --progress --rsh="ssh -o \"StrictHostKeyChecking no\""
|
||||
# ssh_options=-o "StrictHostKeyChecking no"
|
||||
|
||||
@@ -235,8 +231,6 @@ ssh_options='-q -o ConnectTimeout=10' # Options to append to "ssh"
|
||||
# These settings apply when switching roles between a primary and a standby
|
||||
# ("repmgr standby switchover").
|
||||
|
||||
#shutdown_check_timeout=60 # The max length of time (in seconds) to wait for the demotion
|
||||
# candidate (current primary) to shut down
|
||||
#standby_reconnect_timeout=60 # The max length of time (in seconds) to wait
|
||||
# for the demoted standby to reconnect to the promoted
|
||||
# primary (note: this value should be equal to or greater
|
||||
@@ -287,9 +281,9 @@ ssh_options='-q -o ConnectTimeout=10' # Options to append to "ssh"
|
||||
# a value of zero prevents the node being promoted to primary
|
||||
# (default: 100)
|
||||
|
||||
#reconnect_attempts=6 # Number of attempts which will be made to reconnect to an unreachable
|
||||
#reconnect_attempts=6 # Number attempts which will be made to reconnect to an unreachable
|
||||
# primary (or other upstream node)
|
||||
#reconnect_interval=10 # Interval between attempts to reconnect to an unreachable
|
||||
#reconnect_interval=10 # Interval between attempts to reconnect to an unreachable
|
||||
# primary (or other upstream node)
|
||||
#promote_command= # command repmgrd executes when promoting a new primary; use something like:
|
||||
#
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# repmgr extension
|
||||
comment = 'Replication manager for PostgreSQL'
|
||||
default_version = '4.2'
|
||||
default_version = '4.1'
|
||||
module_pathname = '$libdir/repmgr'
|
||||
relocatable = false
|
||||
schema = repmgr
|
||||
|
||||
2
repmgr.h
2
repmgr.h
@@ -53,7 +53,6 @@
|
||||
|
||||
#define UNKNOWN_TIMELINE_ID -1
|
||||
#define UNKNOWN_SYSTEM_IDENTIFIER 0
|
||||
#define UNKNOWN_PID -1
|
||||
|
||||
#define NODE_NOT_FOUND -1
|
||||
#define NO_UPSTREAM_NODE -1
|
||||
@@ -85,7 +84,6 @@
|
||||
#define DEFAULT_WAIT_START 30 /* seconds */
|
||||
#define DEFAULT_PROMOTE_CHECK_TIMEOUT 60 /* seconds */
|
||||
#define DEFAULT_PROMOTE_CHECK_INTERVAL 1 /* seconds */
|
||||
#define DEFAULT_SHUTDOWN_CHECK_TIMEOUT 60 /* seconds */
|
||||
#define DEFAULT_STANDBY_RECONNECT_TIMEOUT 60 /* seconds */
|
||||
#define DEFAULT_NODE_REJOIN_TIMEOUT 60 /* seconds */
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#define REPMGR_VERSION_DATE ""
|
||||
#define REPMGR_VERSION "4.2"
|
||||
#define REPMGR_VERSION "4.1.1"
|
||||
|
||||
@@ -150,13 +150,7 @@ monitor_bdr(void)
|
||||
* retrieve list of all nodes - we'll need these if the DB connection goes
|
||||
* away
|
||||
*/
|
||||
if (get_all_node_records(local_conn, &nodes) == false)
|
||||
{
|
||||
/* get_all_node_records() will display the error */
|
||||
PQfinish(local_conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
get_all_node_records(local_conn, &nodes);
|
||||
|
||||
/* we're expecting all (both) nodes to be up */
|
||||
for (cell = nodes.head; cell; cell = cell->next)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
23
repmgrd.c
23
repmgrd.c
@@ -35,7 +35,7 @@
|
||||
|
||||
static char *config_file = NULL;
|
||||
static bool verbose = false;
|
||||
char pid_file[MAXPGPATH];
|
||||
static char pid_file[MAXPGPATH];
|
||||
static bool daemonize = true;
|
||||
static bool show_pid_file = false;
|
||||
static bool no_pid_file = false;
|
||||
@@ -101,8 +101,7 @@ main(int argc, char **argv)
|
||||
{"config-file", required_argument, NULL, 'f'},
|
||||
|
||||
/* daemon options */
|
||||
{"daemonize-short", optional_argument, NULL, 'd'},
|
||||
{"daemonize", optional_argument, NULL, OPT_DAEMONIZE},
|
||||
{"daemonize", optional_argument, NULL, 'd'},
|
||||
{"pid-file", required_argument, NULL, 'p'},
|
||||
{"show-pid-file", no_argument, NULL, 's'},
|
||||
{"no-pid-file", no_argument, NULL, OPT_NO_PID_FILE},
|
||||
@@ -176,11 +175,10 @@ main(int argc, char **argv)
|
||||
/* daemon options */
|
||||
|
||||
case 'd':
|
||||
daemonize = true;
|
||||
break;
|
||||
|
||||
case OPT_DAEMONIZE:
|
||||
daemonize = parse_bool(optarg, "-d/--daemonize", &cli_errors);
|
||||
if (optarg != NULL)
|
||||
{
|
||||
daemonize = parse_bool(optarg, "-d/--daemonize", &cli_errors);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
@@ -490,9 +488,6 @@ main(int argc, char **argv)
|
||||
check_and_create_pid_file(pid_file);
|
||||
}
|
||||
|
||||
repmgrd_set_pid(local_conn, getpid(), pid_file);
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
setup_event_handlers();
|
||||
#endif
|
||||
@@ -765,8 +760,7 @@ show_help(void)
|
||||
puts("");
|
||||
|
||||
printf(_("Daemon configuration options:\n"));
|
||||
printf(_(" -d\n"));
|
||||
printf(_(" --daemonize[=true/false]\n"));
|
||||
printf(_(" -d, --daemonize[=true/false]\n"));
|
||||
printf(_(" detach process from foreground (default: true)\n"));
|
||||
printf(_(" -p, --pid-file=PATH use the specified PID file\n"));
|
||||
printf(_(" -s, --show-pid-file show PID file which would be used by the current configuration\n"));
|
||||
@@ -907,9 +901,6 @@ print_monitoring_state(MonitoringState monitoring_state)
|
||||
void
|
||||
terminate(int retval)
|
||||
{
|
||||
if (PQstatus(local_conn) == CONNECTION_OK)
|
||||
repmgrd_set_pid(local_conn, UNKNOWN_PID, NULL);
|
||||
|
||||
logger_shutdown();
|
||||
|
||||
if (pid_file[0] != '\0')
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "portability/instr_time.h"
|
||||
|
||||
#define OPT_NO_PID_FILE 1000
|
||||
#define OPT_DAEMONIZE 1001
|
||||
|
||||
extern volatile sig_atomic_t got_SIGHUP;
|
||||
extern MonitoringState monitoring_state;
|
||||
@@ -21,7 +20,6 @@ extern t_configuration_options config_file_options;
|
||||
extern t_node_info local_node_info;
|
||||
extern PGconn *local_conn;
|
||||
extern bool startup_event_logged;
|
||||
extern char pid_file[MAXPGPATH];
|
||||
|
||||
void try_reconnect(PGconn **conn, t_node_info *node_info);
|
||||
|
||||
|
||||
12
strutil.c
12
strutil.c
@@ -87,17 +87,17 @@ append_where_clause(PQExpBufferData *where_clause, const char *format,...)
|
||||
|
||||
if (where_clause->data[0] == '\0')
|
||||
{
|
||||
appendPQExpBufferStr(where_clause,
|
||||
" WHERE ");
|
||||
appendPQExpBuffer(where_clause,
|
||||
" WHERE ");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(where_clause,
|
||||
" AND ");
|
||||
appendPQExpBuffer(where_clause,
|
||||
" AND ");
|
||||
}
|
||||
|
||||
appendPQExpBufferStr(where_clause,
|
||||
stringbuf);
|
||||
appendPQExpBuffer(where_clause,
|
||||
"%s", stringbuf);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user