From 5fbcf3e4762f90622717b07454d483dd5fdc2904 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 10 Jul 2017 09:31:31 +0900 Subject: [PATCH] Remove witness server references --- config.c | 10 ---------- config.h | 5 ----- dbutils.c | 6 ------ dbutils.h | 1 - dirutil.c | 31 +++---------------------------- dirutil.h | 1 - repmgr--4.0.sql | 2 +- repmgr-client.c | 5 ----- repmgr-client.h | 17 +++++++---------- repmgr.conf.sample | 2 +- repmgr.h | 3 --- repmgrd.c | 3 --- 12 files changed, 12 insertions(+), 74 deletions(-) diff --git a/config.c b/config.c index 3c3f25b5..403d177f 100644 --- a/config.c +++ b/config.c @@ -248,12 +248,6 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList * options->monitoring_history = false; /* new in 4.0, replaces --monitoring-history */ options->degraded_monitoring_timeout = -1; - /* witness settings - * ---------------- */ - - /* default to resyncing repl_nodes table every 30 seconds on the witness server */ - options->witness_repl_nodes_sync_interval_secs = 30; - /* service settings * ---------------- */ memset(options->pg_ctl_options, 0, sizeof(options->pg_ctl_options)); @@ -421,10 +415,6 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList * else if (strcmp(name, "degraded_monitoring_timeout") == 0) options->degraded_monitoring_timeout = repmgr_atoi(value, name, error_list, 1); - /* witness settings */ - else if (strcmp(name, "witness_repl_nodes_sync_interval_secs") == 0) - options->witness_repl_nodes_sync_interval_secs = repmgr_atoi(value, name, error_list, 1); - /* service settings */ else if (strcmp(name, "pg_ctl_options") == 0) strncpy(options->pg_ctl_options, value, MAXLEN); diff --git a/config.h b/config.h index 0168bd01..80c6685d 100644 --- a/config.h +++ b/config.h @@ -85,9 +85,6 @@ typedef struct bool monitoring_history; int degraded_monitoring_timeout; - /* witness settings */ - int witness_repl_nodes_sync_interval_secs; - /* service settings */ char pg_ctl_options[MAXLEN]; char service_stop_command[MAXLEN]; @@ -131,8 +128,6 @@ typedef struct DEFAULT_RECONNECTION_ATTEMPTS, \ DEFAULT_RECONNECTION_INTERVAL, \ 300, false, -1, \ - /* witness settings */ \ - 30, \ /* service settings */ \ "", "", "", "", "", "", \ /* event notification settings */ \ diff --git a/dbutils.c b/dbutils.c index d2a30418..e3c19aee 100644 --- a/dbutils.c +++ b/dbutils.c @@ -1226,10 +1226,6 @@ parse_node_type(const char *type) { return STANDBY; } - else if (strcmp(type, "witness") == 0) - { - return WITNESS; - } else if (strcmp(type, "bdr") == 0) { return BDR; @@ -1247,8 +1243,6 @@ get_node_type_string(t_server_type type) return "primary"; case STANDBY: return "standby"; - case WITNESS: - return "witness"; case BDR: return "bdr"; /* this should never happen */ diff --git a/dbutils.h b/dbutils.h index 3b1125e3..334b219e 100644 --- a/dbutils.h +++ b/dbutils.h @@ -18,7 +18,6 @@ typedef enum { UNKNOWN = 0, PRIMARY, STANDBY, - WITNESS, BDR } t_server_type; diff --git a/dirutil.c b/dirutil.c index b548e41b..9f80ad38 100644 --- a/dirutil.c +++ b/dirutil.c @@ -22,8 +22,6 @@ #include "strutil.h" #include "log.h" - -static bool _create_pg_dir(char *dir, bool force, bool for_witness); static int unlink_dir_callback(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf); @@ -240,19 +238,6 @@ is_pg_dir(char *path) bool create_pg_dir(char *path, bool force) -{ - return _create_pg_dir(path, force, false); -} - -bool -create_witness_pg_dir(char *path, bool force) -{ - return _create_pg_dir(path, force, true); -} - - -static bool -_create_pg_dir(char *path, bool force, bool for_witness) { bool pg_dir = false; @@ -277,7 +262,7 @@ _create_pg_dir(char *path, bool force, bool for_witness) if (!set_dir_permissions(path)) { - log_error(_("unable to change permissions of directory \"%s\": %s"), + log_error(_("unable to change permissions of directory \"%s\":\n %s"), path, strerror(errno)); return false; } @@ -289,21 +274,11 @@ _create_pg_dir(char *path, bool force, bool for_witness) pg_dir = is_pg_dir(path); - if (pg_dir && force) { + /* TODO: check DB state, if not running overwrite */ - /* - * The witness server does not store any data other than a copy of the - * repmgr metadata, so in --force mode we can simply overwrite the - * directory. - * - * For non-witness servers, we'll leave the data in place, to reduce - * the risk of unintentional data loss - * - * TODO: check DB state, if not running overwrite - */ - if (for_witness) + if (false) { log_notice(_("deleting existing data directory \"%s\""), path); nftw(path, unlink_dir_callback, 64, FTW_DEPTH | FTW_PHYS); diff --git a/dirutil.h b/dirutil.h index 15ab75f3..800a845c 100644 --- a/dirutil.h +++ b/dirutil.h @@ -14,6 +14,5 @@ extern int check_dir(char *path); extern bool create_dir(char *path); extern bool is_pg_dir(char *path); extern bool create_pg_dir(char *path, bool force); -extern bool create_witness_pg_dir(char *path, bool force); #endif diff --git a/repmgr--4.0.sql b/repmgr--4.0.sql index eab65578..eabf04d1 100644 --- a/repmgr--4.0.sql +++ b/repmgr--4.0.sql @@ -6,7 +6,7 @@ CREATE TABLE nodes ( 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')), + type TEXT NOT NULL CHECK (type IN('primary','standby','bdr')), location TEXT NOT NULL DEFAULT 'default', priority INT NOT NULL DEFAULT 100, conninfo TEXT NOT NULL, diff --git a/repmgr-client.c b/repmgr-client.c index 7f170746..b3c788d2 100644 --- a/repmgr-client.c +++ b/repmgr-client.c @@ -551,7 +551,6 @@ main(int argc, char **argv) * * { PRIMARY | MASTER } REGISTER | * STANDBY {REGISTER | UNREGISTER | CLONE [node] | PROMOTE | FOLLOW [node] | SWITCHOVER | REWIND} | - * WITNESS { CREATE | REGISTER | UNREGISTER } | * BDR { REGISTER | UNREGISTER } | * CLUSTER { CROSSCHECK | MATRIX | SHOW | CLEANUP | EVENT } * @@ -1046,7 +1045,6 @@ check_cli_parameters(const int action) { case PRIMARY_UNREGISTER: case STANDBY_UNREGISTER: - case WITNESS_UNREGISTER: case CLUSTER_EVENT: break; default: @@ -1062,7 +1060,6 @@ check_cli_parameters(const int action) switch (action) { case STANDBY_UNREGISTER: - case WITNESS_UNREGISTER: case CLUSTER_EVENT: if (runtime_options.node_id != UNKNOWN_NODE_ID) { @@ -1178,8 +1175,6 @@ action_name(const int action) return "STANDBY REGISTER"; case STANDBY_UNREGISTER: return "STANDBY UNREGISTER"; - case WITNESS_UNREGISTER: - return "WITNESS UNREGISTER"; case CLUSTER_EVENT: return "CLUSTER EVENT"; } diff --git a/repmgr-client.h b/repmgr-client.h index 8fa6e379..5ce79fef 100644 --- a/repmgr-client.h +++ b/repmgr-client.h @@ -22,16 +22,13 @@ #define STANDBY_SWITCHOVER 8 #define STANDBY_ARCHIVE_CONFIG 9 #define STANDBY_RESTORE_CONFIG 10 -#define WITNESS_CREATE 11 -#define WITNESS_REGISTER 12 -#define WITNESS_UNREGISTER 13 -#define CLUSTER_SHOW 14 -#define CLUSTER_CLEANUP 15 -#define CLUSTER_MATRIX 16 -#define CLUSTER_CROSSCHECK 17 -#define CLUSTER_EVENT 18 -#define BDR_REGISTER 19 -#define BDR_UNREGISTER 20 +#define CLUSTER_SHOW 11 +#define CLUSTER_CLEANUP 12 +#define CLUSTER_MATRIX 13 +#define CLUSTER_CROSSCHECK 14 +#define CLUSTER_EVENT 15 +#define BDR_REGISTER 16 +#define BDR_UNREGISTER 17 /* command line options without short versions */ #define OPT_HELP 1 diff --git a/repmgr.conf.sample b/repmgr.conf.sample index a87bcd9d..a8c890dc 100644 --- a/repmgr.conf.sample +++ b/repmgr.conf.sample @@ -100,7 +100,7 @@ # By default, all notifications will be passed; the notification types # can be filtered to explicitly named ones, e.g.: # -# event_notifications=master_register,standby_register,witness_create +# event_notifications=master_register,standby_register #event_notification_command='' # An external program or script which # can be executed by the user under which diff --git a/repmgr.h b/repmgr.h index f8013d6f..23a090fd 100644 --- a/repmgr.h +++ b/repmgr.h @@ -52,7 +52,4 @@ #define ERRBUFF_SIZE 512 -#define WITNESS_DEFAULT_PORT "5499" /* If this value is ever changed, remember - * to update comments and documentation */ - #endif /* _REPMGR_H_ */ diff --git a/repmgrd.c b/repmgrd.c index 524bc8b2..28074ccf 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -471,9 +471,6 @@ start_monitoring(void) case STANDBY: monitor_streaming_standby(); break; - case WITNESS: - /* not handled */ - return; case BDR: monitor_bdr(); return;