Improve BDR3 node query

We can get everything we need from bdr.node_summary
This commit is contained in:
Ian Barwick
2018-04-26 13:06:02 +09:00
parent bf0d67c60a
commit 836d2125fe
4 changed files with 10 additions and 11 deletions

View File

@@ -4851,9 +4851,7 @@ get_all_bdr_node_records(PGconn *conn, BdrNodeInfoList *node_list)
{ {
appendPQExpBuffer(&query, appendPQExpBuffer(&query,
" SELECT " BDR3_NODES_COLUMNS " SELECT " BDR3_NODES_COLUMNS
" FROM bdr.node bn " " FROM bdr.node_summary ns "
" INNER JOIN pglogical.node_interface pni "
" ON bn.pglogical_node_id = pni.if_nodeid "
" ORDER BY node_name"); " ORDER BY node_name");
} }
@@ -4888,10 +4886,8 @@ get_bdr_node_record_by_name(PGconn *conn, const char *node_name, t_bdr_node_info
{ {
appendPQExpBuffer(&query, appendPQExpBuffer(&query,
" SELECT " BDR3_NODES_COLUMNS " SELECT " BDR3_NODES_COLUMNS
" FROM bdr.node bn " " FROM bdr.node_summary ns "
" INNER JOIN pglogical.node_interface pni " " WHERE ns.node_name = '%s'",
" ON bn.pglogical_node_id = pni.if_nodeid "
" WHERE bn.node_name = '%s'",
node_name); node_name);
} }
@@ -4968,6 +4964,7 @@ _populate_bdr_node_record(PGresult *res, t_bdr_node_info *node_info, int row)
node_info->node_dboid = atoi(PQgetvalue(res, row, 2)); node_info->node_dboid = atoi(PQgetvalue(res, row, 2));
strncpy(node_info->node_name, PQgetvalue(res, row, 3), MAXLEN); strncpy(node_info->node_name, PQgetvalue(res, row, 3), MAXLEN);
strncpy(node_info->node_local_dsn, PQgetvalue(res, row, 4), MAXLEN); strncpy(node_info->node_local_dsn, PQgetvalue(res, row, 4), MAXLEN);
strncpy(node_info->peer_state_name, PQgetvalue(res, row, 5), MAXLEN);
} }

View File

@@ -29,8 +29,8 @@
#include "voting.h" #include "voting.h"
#define REPMGR_NODES_COLUMNS "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, '' AS upstream_node_name " #define REPMGR_NODES_COLUMNS "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, '' AS upstream_node_name "
#define BDR2_NODES_COLUMNS "node_sysid, node_timeline, node_dboid, node_name, node_local_dsn" #define BDR2_NODES_COLUMNS "node_sysid, node_timeline, node_dboid, node_name, node_local_dsn, ''"
#define BDR3_NODES_COLUMNS "bn.pglogical_node_id, 0, 0, pni.if_name AS node_name, pni.if_dsn AS node_init_from_dsn" #define BDR3_NODES_COLUMNS "ns.node_id, 0, 0, ns.node_name, ns.interface_connstr, ns.peer_state_name"
#define ERRBUFF_SIZE 512 #define ERRBUFF_SIZE 512
@@ -241,11 +241,12 @@ typedef struct s_bdr_node_info
uint32 node_dboid; uint32 node_dboid;
char node_name[MAXLEN]; char node_name[MAXLEN];
char node_local_dsn[MAXLEN]; char node_local_dsn[MAXLEN];
char peer_state_name[MAXLEN];
} t_bdr_node_info; } t_bdr_node_info;
#define T_BDR_NODE_INFO_INITIALIZER { \ #define T_BDR_NODE_INFO_INITIALIZER { \
"", InvalidOid, InvalidOid, \ "", InvalidOid, InvalidOid, \
"", "", \ "", "", "" \
} }

View File

@@ -86,7 +86,7 @@ do_bdr_register(void)
/* BDR 2 implementation is for 2 nodes only */ /* BDR 2 implementation is for 2 nodes only */
if (get_bdr_version_num() < 3 && bdr_nodes.node_count > 2) if (get_bdr_version_num() < 3 && bdr_nodes.node_count > 2)
{ {
log_error(_("repmgr can only support BDR clusters with 2 nodes")); log_error(_("repmgr can only support BDR 2.x clusters with 2 nodes"));
log_detail(_("this BDR cluster has %i nodes"), bdr_nodes.node_count); log_detail(_("this BDR cluster has %i nodes"), bdr_nodes.node_count);
PQfinish(conn); PQfinish(conn);
pfree(dbname); pfree(dbname);

View File

@@ -1503,6 +1503,7 @@ check_cli_parameters(const int action)
case STANDBY_CLONE: case STANDBY_CLONE:
case STANDBY_REGISTER: case STANDBY_REGISTER:
case STANDBY_FOLLOW: case STANDBY_FOLLOW:
case BDR_REGISTER:
break; break;
default: default:
item_list_append_format(&cli_warnings, item_list_append_format(&cli_warnings,