Limit repmgr installation on a BDR cluster to two nodes

This commit is contained in:
Ian Barwick
2017-07-13 14:10:08 +09:00
parent 7eadbf6b17
commit 2594a46a4f
2 changed files with 25 additions and 6 deletions

View File

@@ -22,6 +22,7 @@ void
do_bdr_register(void)
{
PGconn *conn = NULL;
BdrNodeInfoList bdr_nodes = T_BDR_NODE_INFO_LIST_INITIALIZER;
ExtensionStatus extension_status;
t_node_info node_info = T_NODE_INFO_INITIALIZER;
RecordStatus record_status;
@@ -45,6 +46,25 @@ do_bdr_register(void)
{
log_error(_("database \"%s\" is not BDR-enabled"), dbname);
log_hint(_("when using repmgr with BDR, the repmgr schema must be stored in the BDR database"));
PQfinish(conn);
exit(ERR_BAD_CONFIG);
}
/* Check that there are at most 2 BDR nodes */
get_all_bdr_node_records(conn, &bdr_nodes);
if (bdr_nodes.node_count == 0)
{
log_error(_("database \"%s\" is BDR-enabled but no BDR nodes were found"), dbname);
PQfinish(conn);
exit(ERR_BAD_CONFIG);
}
if (bdr_nodes.node_count > 2)
{
log_error(_("repmgr can only support BDR clusters with 2 nodes"));
log_detail(_("this BDR cluster has %i nodes"), bdr_nodes.node_count);
PQfinish(conn);
exit(ERR_BAD_CONFIG);
}
@@ -54,12 +74,10 @@ do_bdr_register(void)
if (extension_status == REPMGR_UNKNOWN)
{
log_error(_("unable to determine status of \"repmgr\" extension in database \"%s\""),
dbname
);
dbname);
PQfinish(conn);
}
if (extension_status == REPMGR_UNAVAILABLE)
{
log_error(_("\"repmgr\" extension is not available"));
@@ -73,7 +91,6 @@ do_bdr_register(void)
log_error(_("repmgr metadatabase contains records for non-BDR nodes"));
exit(ERR_BAD_CONFIG);
}
}
else
{

View File

@@ -1242,12 +1242,14 @@ do_help(void)
}
printf(_("Usage:\n"));
printf(_(" %s [OPTIONS] primary register\n"), progname());
printf(_(" %s [OPTIONS] primary unregister\n"), progname());
printf(_(" %s [OPTIONS] primary register\n"), progname());
printf(_(" %s [OPTIONS] primary unregister\n"), progname());
printf(_(" %s [OPTIONS] standby clone\n"), progname());
printf(_(" %s [OPTIONS] standby register\n"), progname());
printf(_(" %s [OPTIONS] standby unregister\n"), progname());
printf(_(" %s [OPTIONS] standby promote\n"), progname());
printf(_(" %s [OPTIONS] bdr register\n"), progname());
printf(_(" %s [OPTIONS] bdr unregister\n"), progname());
printf(_(" %s [OPTIONS] cluster event\n"), progname());
puts("");