Postgresql: how to enable pg_stat_replication_slots?



  • I have a streaming replication on pg 14.2 that seems to be working, on a slot named slot1.

    select * from pg_stat_replication_slots has no output. Do I need to enable anything else?

    I have those on:

    • track_activities
    • track_counts

    Streaming INFO:

    select * from pg_stat_replication;

    -[ RECORD 1 ]----+------------------------------
    pid              | 21483
    usesysid         | 376382
    usename          | repl
    application_name | replication
    client_addr      | 172.28.201.16
    client_hostname  | 
    client_port      | 42822
    backend_start    | 2022-03-17 11:25:05.599057-03
    backend_xmin     | 
    state            | streaming
    sent_lsn         | 56/4729C750
    write_lsn        | 56/4729C750
    flush_lsn        | 56/4729C750
    replay_lsn       | 56/46007120
    write_lag        | 00:00:00.005546
    flush_lag        | 00:00:00.011271
    replay_lag       | 00:59:34.522039
    sync_priority    | 0
    sync_state       | async
    reply_time       | 2022-03-17 12:24:49.02266-03
    

    select * from pg_replication_slots;

    -[ RECORD 1 ]-------+------------
    slot_name           | slot1
    plugin              | 
    slot_type           | physical
    datoid              | 
    database            | 
    temporary           | f
    active              | t
    active_pid          | 21483
    xmin                | 
    catalog_xmin        | 
    restart_lsn         | 56/47313758
    confirmed_flush_lsn | 
    wal_status          | reserved
    safe_wal_size       | 10750970024
    two_phase           | f
    


  • An important word in the https://www.postgresql.org/docs/14/monitoring-stats.html#MONITORING-PG-STAT-REPLICATION-SLOTS-VIEW :

    The pg_stat_replication_slots view will contain one row per logical replication slot, showing statistics about its usage.

    As intended, there is nothing for physical replication slots here. Perhaps this view could be called differently, but now it's too late to rename.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2