From 7d33c1e4119818e5cf734aa48052d7c3dc3d5245 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 31 Mar 2015 10:28:34 +0900 Subject: [PATCH] Only attempt to log an event if the rempgr schema has been set In some circumstances (primarily when executing `repmgr standby clone`) the `repmgr.conf` file is not mandated. However this means the repmgr schema is not known, and any attempt to create an event record will result in a log warning, which may cause confusion as to the success of the operation. It might be better to mandate providing `repmgr.conf` in all circumstances. Per report in https://github.com/2ndQuadrant/repmgr/issues/53 . --- QUICKSTART.md | 5 ++++- dbutils.c | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/QUICKSTART.md b/QUICKSTART.md index bf0c8700..b2dbd3c0 100644 --- a/QUICKSTART.md +++ b/QUICKSTART.md @@ -71,7 +71,10 @@ Standby setup [2015-03-03 18:18:23] [NOTICE] HINT: You can now start your postgresql server [2015-03-03 18:18:23] [NOTICE] for example : pg_ctl -D /path/to/standby/data start - Note that at this point it does not matter if the `repmgr.conf` file is not found. + Note that the `repmgr.conf` file is not required when cloning a standby. + However we recommend providing a valid `repmgr.conf` if you wish to use + replication slots, or want `repmgr` to log the clone event to the + `repl_events` table. This will clone the PostgreSQL database files from the master, including its `postgresql.conf` and `pg_hba.conf` files, and additionally automatically create diff --git a/dbutils.c b/dbutils.c index 755571e1..7ac39a3c 100644 --- a/dbutils.c +++ b/dbutils.c @@ -1051,7 +1051,12 @@ create_event_record(PGconn *conn, t_configuration_options *options, int node_id, bool success = true; struct tm ts; - if(conn != NULL) + /* Only attempt to write a record if a connection handle was provided/ + Also check that the repmgr schema has been properly intialised - if + not it means no configuration file was provided, which can happen with + e.g. `repmgr standby clone`, and we won't know which schema to write to. + */ + if(conn != NULL && strcmp(repmgr_schema, DEFAULT_REPMGR_SCHEMA_PREFIX) != 0) { int n_node_id = htonl(node_id); char *t_successful = successful ? "TRUE" : "FALSE";