mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
Store configuration file in repmgr.nodes table
When executing repmgr on remote nodes, we otherwise end up jumping through hoops as we can't make assumptions about where the configuration file is located, but really need to be able to provide it. From a support point of view it will also make life easier as it will be easy to specify exactly which file to provide.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#include "log.h"
|
||||
|
||||
const static char *_progname = NULL;
|
||||
static char config_file_path[MAXPGPATH];
|
||||
char config_file_path[MAXPGPATH] = "";
|
||||
static bool config_file_provided = false;
|
||||
bool config_file_found = false;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define CONFIG_FILE_NAME "repmgr.conf"
|
||||
#define MAXLINELENGTH 4096
|
||||
extern bool config_file_found;
|
||||
extern char config_file_path[MAXPGPATH];
|
||||
|
||||
typedef enum {
|
||||
FAILOVER_MANUAL,
|
||||
|
||||
16
dbutils.c
16
dbutils.c
@@ -1637,7 +1637,7 @@ get_node_record(PGconn *conn, int node_id, t_node_info *node_info)
|
||||
" WHERE node_id = %i",
|
||||
node_id);
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_node_record():\n%s", query.data);
|
||||
log_verbose(LOG_DEBUG, "get_node_record():\n %s", query.data);
|
||||
|
||||
result = _get_node_record(conn, query.data, node_info);
|
||||
termPQExpBuffer(&query);
|
||||
@@ -1956,7 +1956,7 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
||||
|
||||
char *slot_name_ptr = NULL;
|
||||
|
||||
int param_count = 10;
|
||||
int param_count = 11;
|
||||
const char *param_values[param_count];
|
||||
|
||||
PGresult *res;
|
||||
@@ -1995,7 +1995,8 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
||||
param_values[6] = node_info->location;
|
||||
param_values[7] = priority;
|
||||
param_values[8] = node_info->active == true ? "TRUE" : "FALSE";
|
||||
param_values[9] = node_id;
|
||||
param_values[9] = node_info->config_file;
|
||||
param_values[10] = node_id;
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
@@ -2005,8 +2006,8 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
||||
"INSERT INTO repmgr.nodes "
|
||||
" (node_id, type, upstream_node_id, "
|
||||
" node_name, conninfo, repluser, slot_name, "
|
||||
" location, priority, active) "
|
||||
"VALUES ($10, $1, $2, $3, $4, $5, $6, $7, $8, $9) ");
|
||||
" location, priority, active, config_file) "
|
||||
"VALUES ($11, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2020,8 +2021,9 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
||||
" slot_name = $6, "
|
||||
" location = $7, "
|
||||
" priority = $8, "
|
||||
" active = $9 "
|
||||
" WHERE node_id = $10 ");
|
||||
" active = $9, "
|
||||
" config_file = $10 "
|
||||
" WHERE node_id = $11 ");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "strutil.h"
|
||||
#include "voting.h"
|
||||
|
||||
#define REPMGR_NODES_COLUMNS "node_id, type, upstream_node_id, node_name, conninfo, repluser, slot_name, location, priority, active, '' AS upstream_node_name "
|
||||
#define REPMGR_NODES_COLUMNS "node_id, type, upstream_node_id, node_name, conninfo, repluser, slot_name, location, priority, active, config_file, '' AS upstream_node_name "
|
||||
|
||||
typedef enum {
|
||||
UNKNOWN = 0,
|
||||
@@ -84,6 +84,7 @@ typedef struct s_node_info
|
||||
int priority;
|
||||
bool active;
|
||||
char slot_name[MAXLEN];
|
||||
char config_file[MAXPGPATH];
|
||||
/* used during failover to track node status */
|
||||
XLogRecPtr last_wal_receive_lsn;
|
||||
NodeStatus node_status;
|
||||
@@ -115,6 +116,7 @@ typedef struct s_node_info
|
||||
DEFAULT_PRIORITY, \
|
||||
true, \
|
||||
"", \
|
||||
"", \
|
||||
/* used during failover to track node status */ \
|
||||
InvalidXLogRecPtr, \
|
||||
NODE_STATUS_UNKNOWN, \
|
||||
|
||||
@@ -11,7 +11,8 @@ CREATE TABLE nodes (
|
||||
priority INT NOT NULL DEFAULT 100,
|
||||
conninfo TEXT NOT NULL,
|
||||
repluser VARCHAR(63) NOT NULL,
|
||||
slot_name TEXT NULL
|
||||
slot_name TEXT NULL,
|
||||
config_file TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE events (
|
||||
|
||||
@@ -2971,6 +2971,7 @@ init_node_record(t_node_info *node_record)
|
||||
|
||||
strncpy(node_record->node_name, config_file_options.node_name, MAXLEN);
|
||||
strncpy(node_record->conninfo, config_file_options.conninfo, MAXLEN);
|
||||
strncpy(node_record->config_file, config_file_path, MAXLEN);
|
||||
|
||||
if (config_file_options.replication_user[0] != '\0')
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user