Initial switchover implementation

The repmgr3 implementation required the promotion candidate (standby)
to directly work with the demotion candidate's data directory,
directly execute server control commands etc.

Here we delegated a lot more of that work to the repmgr on the
demotion candidate, which reduces the amount of back-and-forth
over SSH and generally makes things cleaner and smoother.

In particular the repmgr on the demotion candidate will carry
out a thorough check that the node is shut down and report
the last checkpoint LSN to the promotion candidate; this
can then be used to determine whether pg_rewind needs to be
executed on the demoted primary before reintegrating it back
into the cluster (todo).

Also implement "--dry-run" for this action, which will sanity-check the
nodes as far as possible without executing the switchover.

Additionally some of the new repmgr node commands (or command options)
introduced for this can be also executed by the user to obtain
additional information about the status of each node.
This commit is contained in:
Ian Barwick
2017-08-03 16:38:37 +09:00
parent c67aa15581
commit 112ca6321a
15 changed files with 1024 additions and 102 deletions

View File

@@ -73,10 +73,19 @@ typedef struct
bool wait_register_sync;
int wait_register_sync_seconds;
/* "standby switchover" options */
char remote_config_file[MAXPGPATH];
bool always_promote;
bool force_rewind;
/* "node status" options */
bool is_shutdown;
/* "node service" options */
char action[MAXLEN];
bool check;
bool list;
bool list_actions;
bool checkpoint;
/* "cluster event" options */
bool all;
@@ -99,15 +108,20 @@ typedef struct
/* database connection options */ \
"", "", "", "", \
/* other connection options */ \
"", "", \
"", "", \
/* node options */ \
UNKNOWN_NODE_ID, "", "", \
/* "standby clone" options */ \
false, CONFIG_FILE_SAMEPATH, false, false, false, "", "", "", NO_UPSTREAM_NODE, false, "", false, \
false, CONFIG_FILE_SAMEPATH, false, false, false, "", "", "", \
NO_UPSTREAM_NODE, false, "", false, \
/* "standby register" options */ \
false, 0, \
/* "standby switchover" options */ \
"", false, false, \
/* "node status" options */ \
false, \
/* "node service" options */ \
"", false, false, \
"", false, false, false, \
/* "cluster event" options */ \
false, "", CLUSTER_EVENT_LIMIT, \
"/tmp" \
@@ -167,6 +181,8 @@ 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);
/* server control functions */
extern void get_server_action(t_server_action action, char *script, char *data_dir);
extern bool data_dir_required_for_action(t_server_action action);