Make repmgr metadata tables dumpable

This makes it easier to extract data for troubleshooting.
This commit is contained in:
Ian Barwick
2020-10-12 10:02:52 +09:00
parent b195547525
commit d62743ddf4
5 changed files with 33 additions and 1 deletions

View File

@@ -15,6 +15,7 @@
repmgr: improve output formatting for cluster matrix/crosscheck (Ian)
repmgr: improve database connection failure error checking on the
demotion candidate during "standby switchover" (Ian)
repmgr: make repmgr metadata tables dumpable (Ian)
repmgr: fix issue with tablespace mapping when cloning from Barman;
GitHub #650 (Ian)
repmgr: improve handling of pg_control read errors (Ian)

View File

@@ -379,6 +379,22 @@
</para>
</sect2>
<sect2 id="faq-repmgr-exclude-metadata-from-dump" xreflabel="Excluding repmgr metadata from pg_dump output">
<title>How can I exclude &repmgr; metadata from <application>pg_dump</application> output?</title>
<para>
Beginning with &repmgr; 5.2, the metadata tables associated with the &repmgr; extension
(<literal>repmgr.nodes</literal>, <literal>repmgr.events</literal> and <literal>repmgr.monitoring_history</literal>)
have been marked as dumpable as they contain configuration and user-generated data.
</para>
<para>
To exclude these from <application>pg_dump</application> output, add the flag <option>--exclude-schema=repmgr</option>.
</para>
<para>
To exclude individual &repmgr; metadata tables from <application>pg_dump</application> output, add the flag
e.g. <option>--exclude-table=repmgr.monitoring_history</option>. This flag can be provided multiple times
to exclude individual tables,
</para>
</sect2>
</sect1>

View File

@@ -133,6 +133,12 @@
Improve handling of pg_control read errors.
</para>
</listitem>
<listitem>
<para>
It is now possible to dump the contents of &repmgr; metadata tables with
<application>pg_dump</application>.
</para>
</listitem>
</itemizedlist>
</para>
</sect2>

View File

@@ -1,2 +1,7 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION repmgr" to load this file. \quit
SELECT pg_catalog.pg_extension_config_dump('repmgr.nodes', '');
SELECT pg_catalog.pg_extension_config_dump('repmgr.events', '');
SELECT pg_catalog.pg_extension_config_dump('repmgr.monitoring_history', '');

View File

@@ -15,6 +15,8 @@ CREATE TABLE repmgr.nodes (
config_file TEXT NOT NULL
);
SELECT pg_catalog.pg_extension_config_dump('repmgr.nodes', '');
CREATE TABLE repmgr.events (
node_id INTEGER NOT NULL,
event TEXT NOT NULL,
@@ -23,6 +25,7 @@ CREATE TABLE repmgr.events (
details TEXT NULL
);
SELECT pg_catalog.pg_extension_config_dump('repmgr.events', '');
CREATE TABLE repmgr.monitoring_history (
primary_node_id INTEGER NOT NULL,
@@ -35,10 +38,11 @@ CREATE TABLE repmgr.monitoring_history (
apply_lag BIGINT NOT NULL
);
CREATE INDEX idx_monitoring_history_time
ON repmgr.monitoring_history (last_monitor_time, standby_node_id);
SELECT pg_catalog.pg_extension_config_dump('repmgr.monitoring_history', '');
CREATE VIEW repmgr.show_nodes AS
SELECT n.node_id,
n.node_name,