Skip to content

Export safe_wal_size and wal_status to monitor for lost replication slots when using max_slot_wal_keep_size #1017

Open
@MarcWort

Description

@MarcWort

Proposal

We set the option max_slot_wal_keep_size supported by postgres >= 13 and want to alert if the slot is lost. I cannot find a reliable solution to do this except using wal_status and safe_wal_size which is currently not exported.

documentation: https://www.postgresql.org/docs/13/view-pg-replication-slots.html

example:

postgres=# SELECT * FROM pg_catalog.pg_replication_slots;
 slot_name | plugin | slot_type | datoid | database | temporary | active | active_pid | xmin | catalog_xmin | restart_lsn | confirmed_flush_lsn | wal_status | safe_wal_size
-----------+--------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+---------------------+------------+---------------
 barman    |        | physical  |        |          | f         | f      |            |      |              | 0/B0000000  |                     | unreserved |    -323906992
(1 rows)

postgres=# SELECT * FROM pg_catalog.pg_replication_slots;
 slot_name | plugin | slot_type | datoid | database | temporary | active | active_pid | xmin | catalog_xmin | restart_lsn | confirmed_flush_lsn | wal_status | safe_wal_size
-----------+--------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+---------------------+------------+---------------
 barman    |        | physical  |        |          | f         | f      |            |      |              |             |                     | lost       |
(1 rows)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions