diff options
author | Michael Paquier | 2021-11-23 10:29:42 +0000 |
---|---|---|
committer | Michael Paquier | 2021-11-23 10:29:42 +0000 |
commit | 1922d7c6e1a74178bd2f1d5aa5a6ab921b3fcd34 (patch) | |
tree | f50330db40f2049bf53b7f7f3801d46b20058d05 /contrib | |
parent | b55f2b6926556115155930c4b2d006c173f45e65 (diff) |
Add SQL functions to monitor the directory contents of replication slots
This commit adds a set of functions able to look at the contents of
various paths related to replication slots:
- pg_ls_logicalsnapdir, for pg_logical/snapshots/
- pg_ls_logicalmapdir, for pg_logical/mappings/
- pg_ls_replslotdir, for pg_replslot/<slot_name>/
These are intended to be used by monitoring tools. Unlike pg_ls_dir(),
execution permission can be granted to non-superusers. Roles members of
pg_monitor gain have access to those functions.
Bump catalog version.
Author: Bharath Rupireddy
Reviewed-by: Nathan Bossart, Justin Pryzby
Discussion: https://postgr.es/m/CALj2ACWsfizZjMN6bzzdxOk1ADQQeSw8HhEjhmVXn_Pu+7VzLw@mail.gmail.com
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/test_decoding/expected/slot.out | 21 | ||||
-rw-r--r-- | contrib/test_decoding/sql/slot.sql | 6 |
2 files changed, 27 insertions, 0 deletions
diff --git a/contrib/test_decoding/expected/slot.out b/contrib/test_decoding/expected/slot.out index 75b4b5cc62..63a9940f73 100644 --- a/contrib/test_decoding/expected/slot.out +++ b/contrib/test_decoding/expected/slot.out @@ -48,6 +48,27 @@ SELECT pg_drop_replication_slot('regression_slot_t'); ERROR: replication slot "regression_slot_t" does not exist SELECT pg_drop_replication_slot('regression_slot_t2'); ERROR: replication slot "regression_slot_t2" does not exist +-- monitoring functions for slot directories +SELECT count(*) >= 0 AS ok FROM pg_ls_logicalmapdir(); + ok +---- + t +(1 row) + +SELECT count(*) >= 0 AS ok FROM pg_ls_logicalsnapdir(); + ok +---- + t +(1 row) + +SELECT count(*) >= 0 AS ok FROM pg_ls_replslotdir('regression_slot_p'); + ok +---- + t +(1 row) + +SELECT count(*) >= 0 AS ok FROM pg_ls_replslotdir('not_existing_slot'); -- fails +ERROR: replication slot "not_existing_slot" does not exist -- permanent slot has survived SELECT pg_drop_replication_slot('regression_slot_p'); pg_drop_replication_slot diff --git a/contrib/test_decoding/sql/slot.sql b/contrib/test_decoding/sql/slot.sql index 6d83fb2678..1aa27c5667 100644 --- a/contrib/test_decoding/sql/slot.sql +++ b/contrib/test_decoding/sql/slot.sql @@ -28,6 +28,12 @@ end'; SELECT pg_drop_replication_slot('regression_slot_t'); SELECT pg_drop_replication_slot('regression_slot_t2'); +-- monitoring functions for slot directories +SELECT count(*) >= 0 AS ok FROM pg_ls_logicalmapdir(); +SELECT count(*) >= 0 AS ok FROM pg_ls_logicalsnapdir(); +SELECT count(*) >= 0 AS ok FROM pg_ls_replslotdir('regression_slot_p'); +SELECT count(*) >= 0 AS ok FROM pg_ls_replslotdir('not_existing_slot'); -- fails + -- permanent slot has survived SELECT pg_drop_replication_slot('regression_slot_p'); |