Monitoring through SQL v6.5.1

Query the monitoring and statistics views specific to EDB Postgres Distributed's distributed behavior, and use the standard Postgres monitoring views alongside them.

PGD's monitoring and statistics views need the bdr_read_all_stats role, or the broader bdr_monitor role, which also covers the bdr.monitor_* functions that report health and views that expose more sensitive internal or user data. Query the views prefixed bdr.group to get a group-level picture from a single node, since PGD fans these queries out across the cluster for you, or, if a bdr_superuser granted you access to bdr.run_on_all_nodes(), run your own queries against every node at once.

Monitoring cluster topology and membership

Confirm a cluster's groups and nodes match what you expect, track a node through joining or parting, and check that automatic synchronization catches a reconnected node up.

Listing groups

List the PGD node groups that the current node is a member of with a query against bdr.local_node_summary. It currently returns only one row:

SELECT node_group_name
FROM bdr.local_node_summary;

Display the configuration of each node group with a more complex query:

SELECT g.node_group_name
, ns.pub_repsets
, ns.sub_repsets
, g.node_group_default_repset  AS default_repset
, node_group_check_constraints AS check_constraints
FROM bdr.local_node_summary ns
JOIN bdr.node_group g USING (node_group_name);
Output
 node_group_name |  pub_repsets  |  sub_repsets  | default_repset | check_constraints 
-----------------+---------------+---------------+----------------+-------------------
 group-1         | {pgd,group-1} | {pgd,group-1} |     4168808439 | 
(1 row)

Listing nodes

Extract the list of all nodes in a given node group, such as group-1, from the bdr.node_summary view. For example:

SELECT node_name         AS name
, node_seq_id            AS ord
, peer_state_name        AS current_state
, peer_target_state_name AS target_state
, interface_connstr      AS dsn
FROM bdr.node_summary
WHERE node_group_name = 'group-1';
Output
  name  | ord | current_state | target_state |                       dsn                        
--------+-----+---------------+--------------+--------------------------------------------------
 node-1 |   1 | ACTIVE        | ACTIVE       | port=5432 dbname=pgddb host=host-1 user=postgres
 node-3 |   2 | ACTIVE        | ACTIVE       | host=host-3 port=5432 dbname=pgddb user=postgres
 node-2 |   3 | ACTIVE        | ACTIVE       | host=host-2 port=5432 dbname=pgddb user=postgres
(3 rows)

Node join and removal

Node management functions wait for a join or part operation to complete by default. Turn waiting off with the wait_for_completion function argument, then check node state with bdr.node_summary and bdr.event_summary to see when the operation finishes.

Alternatively, call bdr.wait_for_join_completion() to pause the session until all outstanding node join operations are complete.

SELECT node_name, interface_connstr, peer_state_name,
        node_seq_id, node_local_dbname
FROM bdr.node_summary;
Output
 node_name |                interface_connstr                 | peer_state_name | node_seq_id | node_local_dbname 
-----------+--------------------------------------------------+-----------------+-------------+-------------------
 node-1    | port=5432 dbname=pgddb host=host-1 user=postgres | ACTIVE          |           1 | pgddb
 node-3    | host=host-3 port=5432 dbname=pgddb user=postgres | ACTIVE          |           2 | pgddb
 node-2    | host=host-2 port=5432 dbname=pgddb user=postgres | ACTIVE          |           3 | pgddb
(3 rows)

When a node is parted, some nodes in the cluster might not receive all the data from that parting node. So parting a node creates a temporary slot from a node that already received that data and can forward it. Query bdr.node_catchup_info for the catch-up state of a joining or parting node:

SELECT * FROM bdr.node_catchup_info;
Output
  node_id   | node_source_id |                     slot_name                      | min_node_lsn | catchup_state | origin_node_id 
------------+----------------+----------------------------------------------------+--------------+---------------+----------------
 1187058264 |      349596469 | bdr_node_f1e86b14d7124962beb02c10af51c1ab_fc8153ef | 0/6035D78    |            40 |              0
 4143208450 |      349596469 | bdr_node_574fd94618cf4b03b4d2d20173b5fa34_fc8153ef | 0/6038928    |            40 |              0
(2 rows)

catchup_state can be one of the following:

  • 10: setup
  • 20: start
  • 30: catchup
  • 40: done

Automatic synchronization

Track sync requests with the view bdr.sync_node_requests_summary to watch PGD automatically sync a node back up from another node after it goes down and reconnects. See Recovering a failed node for how PGD handles node failures more generally.

This example shows three completed sync requests, all triggered when node-2 and node-1 in turn went down and reconnected:

SELECT * FROM bdr.sync_node_requests_summary;
Output
 origin | source | target | sync_start_lsn |         sync_start_ts         | sync_end_lsn |          sync_end_ts          | sync_status 
--------+--------+--------+----------------+-------------------------------+--------------+-------------------------------+-------------
 node-2 | node-1 | node-3 | 0/75563E8      | 2026-08-11 00:38:51.688205+00 | 0/7568788    | 2026-08-11 00:38:51.807152+00 | done
 node-1 | node-2 | node-3 | 0/839E318      | 2026-08-12 04:18:15.398555+00 | 0/83B1BF8    | 2026-08-12 04:18:15.43509+00  | done
 node-3 | node-2 | node-1 | 0/8B260B0      | 2026-08-12 04:18:15.401563+00 | 0/8B3D4A0    | 2026-08-12 04:18:15.446503+00 | done
(3 rows)

Each row tracks one sync request. origin is the down node, source is the node used to catch the others up, and target is the node that received the sync. Watch sync_status to see whether the request finished, and compare sync_start_ts with sync_end_ts to see how long it took, since sync_end_ts stays empty while a request is still running.

If a sync request gets stuck and blocks normal functioning of the cluster, cancel it manually with bdr.sync_node_cancel():

SELECT bdr.sync_node_cancel('<origin_node>', '<source_node>');
Note

Calling bdr.sync_node_cancel() cancels every sync node request for every target that shares the given origin and source. Invoke it only from a write leader.

The configuration parameter that controls automatic sync is bdr.enable_auto_sync_reconcile, and it's set to true by default.

Warning

bdr.enable_auto_sync_reconcile is an internal configuration parameter. Don't disable it, since doing so risks an unintended stop of replication or data divergence.

Monitoring replication

Check replication peers, senders, and slots regularly, especially after a node goes down, reconnects, or comes under heavy write load, to confirm data is flowing correctly between nodes and catch lag before it becomes a problem.

Each node acts as a sender, also called the origin or provider, for the peers it replicates changes to, maintaining a replication slot per peer. It acts as a receiver, also called a replica or subscriber, for the peers it replicates changes from, holding a subscription per peer. For each pair of connected nodes, one side's outgoing replication is the other side's incoming replication.

Outgoing replication

Query bdr.node_replication_rates for an overall picture of outgoing replication activity, including catchup estimates for peer nodes.

SELECT * FROM bdr.node_replication_rates;
Output
 peer_node_id | target_name |  sent_lsn  | replay_lsn |  replay_lag   | replay_lag_bytes | replay_lag_size | apply_rate | catchup_interval 
--------------+-------------+------------+------------+---------------+------------------+-----------------+------------+------------------
    349596469 | node-1      | 3/20FE3D90 | 3/20FE3D90 | 00:00:00.0002 |                0 | 0 bytes         |       2657 | 00:00:00
   4143208450 | node-2      | 3/20FE3D90 | 3/20FE3D90 | 00:00:00      |                0 | 0 bytes         |       2656 | 00:00:00
(2 rows)

The apply_rate field reports the rate, in bytes per second, at which the peer consumes data from the local node. While a peer node is reconnecting and catching up, and replication isn't yet in the streaming state, replay_lag reports an estimate: the time elapsed since the slot's last confirmed flush. Once the state becomes streaming, replay_lag reports the measured lag. To estimate how long the peer needs to catch up to the local node, use the catchup_interval column, which gives the approximate time required to replay the changes still pending.

Query bdr.node_slots for outgoing replication from the local node. It shows the replication status of every peer node in the group known to the current node, plus any additional replication slots PGD created on the current node. Run the query on every participating node to get the full view of lag in the cluster.

SELECT node_group_name, target_dbname, target_name, slot_name, active_pid,
    catalog_xmin, client_addr, sent_lsn, replay_lsn,
    replay_lag_bytes, replay_lag_size
FROM bdr.node_slots;
Output
 node_group_name | target_dbname | target_name |                      slot_name                      | active_pid | catalog_xmin | client_addr |  sent_lsn  | replay_lsn | replay_lag_bytes | replay_lag_size 
-----------------+---------------+-------------+-----------------------------------------------------+------------+--------------+-------------+------------+------------+------------------+-----------------
 group-1         | pgddb         | node-3      | bdr_node_f1e86b14d7124962beb02c10af51c1ab_fc8153ef  |        404 |      1580978 | 172.22.0.2  | 3/2647F208 | 3/2647F208 |                0 | 0 bytes
 group-1         | pgddb         | node-2      | bdr_node_574fd94618cf4b03b4d2d20173b5fa34_fc8153ef  |        405 |      1580978 | 172.22.0.3  | 3/2647F208 | 3/2647F208 |                0 | 0 bytes
                 |               |             | bdr_group_184facab927211f15765f70b373c58dc_fc8153ef |            |      1580383 |             | 3/25EEB128 | 3/25EEB128 |          5849312 | 5712 kB
(3 rows)

The third record, beginning with bdr_group, is the PGD group slot. Each node has exactly one, and it must never have a connection to it, which is why active_pid and client_addr are blank. See Replication slots for more on the group slot.

replay_lag_bytes is the gap, in bytes, between the local node's current WAL write position and replay_lsn, the last position the peer confirmed it replayed. replay_lag_size is the same gap in a human-readable form.

WAL also grows from VACUUM activity, index changes, writes to other databases on the node, and writes to tables outside any replication set. None of that WAL is sent to the peer, but it still counts toward replay_lag_bytes. A high value doesn't mean the peer still has that much data to receive, it means the sender still has that much WAL to process before reaching the peer's confirmed position.

Expect replay_lag_bytes to rise and fall in bursts rather than shrink steadily. It only moves on commit, not while a transaction streams, so it rises as PGD streams a transaction and falls once the peer commits, flushes, and confirms it. LSN positions step in the same way instead of advancing smoothly.

When replication disconnects, active_pid and client_addr go NULL. sent_lsn and replay_lsn stay fixed at confirmed_flush_lsn, the last position the peer is known to have replayed and saved, and replay_lag_bytes and replay_lag_size show the distance between that fixed position and the node's current WAL insert position.

Note

It's expected for restart_lsn to lag behind the other lsn columns, reflecting the oldest transaction that's not yet replicated and flushed. A very old value can slow replication restarts and retain extra WAL, so if you're concerned, check for long-running or forgotten prepared transactions.

Alternatively, query the standard PostgreSQL replication views pg_catalog.pg_stat_replication and pg_catalog.pg_replication_slots for most of the same information as bdr.node_slots.

Incoming replication

Query the bdr.subscription_summary view to monitor incoming replication, also known as subscriptions, at a high level. The following query shows the list of known subscriptions to other nodes in the PGD and the state of the replication worker:

SELECT node_group_name, origin_name, sub_enabled, sub_slot_name,
    subscription_status
FROM bdr.subscription_summary;
Output
 node_group_name | origin_name | sub_enabled |                   sub_slot_name                    | subscription_status 
-----------------+-------------+-------------+-----------------------------------------------------+---------------------
 group-1         | node-2      | t           | bdr_node_e3fab68789394a7a8efc9387341fafbf_fc8153ef | replicating
 group-1         | node-3      | t           | bdr_node_e3fab68789394a7a8efc9387341fafbf_fc8153ef | replicating
(2 rows)

See Apply statistics for the subscription's replication and apply statistics.

WAL senders using LCR

Monitor the current logical change record (LCR) file for each WAL sender with the function bdr.wal_sender_stats(), if the decoding worker is enabled. For example:

SELECT * FROM bdr.wal_sender_stats();
Output
   pid   | is_using_lcr |       decoder_slot_name       |              lcr_file_name
---------+--------------+-------------------------------+------------------------------------------
 2059904 | f            |                               |
 2059909 | t            | bdr_postgres_bdrgroup_decoder | 0000000000000000000000140000000000000000
 2059916 | t            | bdr_postgres_bdrgroup_decoder | 0000000000000000000000140000000000000000
(3 rows)

When is_using_lcr is f, decoder_slot_name and lcr_file_name are NULL, either because the decoding worker isn't enabled or because the WAL sender is serving a logical standby.

Monitor the decoding worker itself with the function bdr.get_decoding_worker_stat(). For example:

SELECT * FROM bdr.get_decoding_worker_stat();
Output
   pid   | decoded_upto_lsn | waiting | waiting_for_lsn
---------+------------------+---------+-----------------
 1153091 | 0/1E5EEE8        | t       | 0/1E5EF00
(1 row)

Replication slots

Query bdr.monitor_local_replslots() for the quickest summary of whether all PGD node replication slots are working as expected. This summary is also available on subscriber-only nodes that are operating as subscriber-only group leaders in a PGD cluster when optimized topology is enabled.

SELECT * FROM bdr.monitor_local_replslots();
Output
 status |                    message
--------+-------------------------------------------------
 OK     | All BDR replication slots are working correctly
(1 row)

The function returns one of the following status summaries:

StatusMessage
UNKNOWNThis node is not part of any BDR group
OKAll BDR replication slots are working correctly
OKThis node is part of a subscriber-only group
CRITICALThere is at least 1 BDR replication slot which is inactive
CRITICALThere is at least 1 BDR replication slot which is missing

For more detail, query the individual replication slots directly. Each PGD node keeps two kinds: one per active PGD peer, and one group replication slot. Query pg_replication_slots to see them:

SELECT slot_name, database, active, confirmed_flush_lsn
FROM pg_replication_slots ORDER BY slot_name;
Output
                      slot_name                      | database | active | confirmed_flush_lsn 
-----------------------------------------------------+----------+--------+---------------------
 bdr_group_184facab927211f15765f70b373c58dc_fc8153ef | pgddb    | f      | 3/25EEB128
 bdr_node_574fd94618cf4b03b4d2d20173b5fa34_fc8153ef  | pgddb    | t      | 3/26E2AA18
 bdr_node_f1e86b14d7124962beb02c10af51c1ab_fc8153ef  | pgddb    | t      | 3/26E2AA18
(3 rows)

Peer slot names follow the convention bdr_<DATABASE>_<GROUP>_<PEER>, while the PGD group slot name follows the convention bdr_<DATABASE>_<GROUP>. Inspect the group slot with the function bdr.local_group_slot_name().

A peer replication slot normally stays active on all nodes. If one goes inactive, it can mean one of the following:

  • The peer node is down.
  • A network issue makes the peer unreachable.
  • The replication stream was interrupted.

In that case, check each node's PostgreSQL server log for ERROR or FATAL entries, and query bdr.event_summary on all nodes to find the root cause, such as an incompatible DDL statement executed with DDL replication disabled on one node.

You don't need to monitor the group replication slot, since it's inactive most of the time and PGD advances its LSN automatically once every peer has consumed the corresponding transactions.

Monitoring replication workers and statistics

Replication workers can fall behind, block on locks, or get stuck entirely. When replication seems slow, unresponsive, or stalled, query their statistics to see what each worker is doing and how much it has processed, and find the stuck worker or the bottleneck.

PGD replication workers

Query the system view bdr.stat_activity to see all PGD workers, with the same columns and information as pg_stat_activity, and additional PGD columns:

  • wait_event provides enhanced information if the reason for waiting relates to PGD.
  • Several Connection Manager fields, such as connection_manager_client_addr and session_read_only, report the client's address and read-only routing when it connects through Connection Manager. See the reference for the full list.

For example, this query shows two pgd raft receiver workers waiting on ClientRead, and a client connected through Connection Manager:

SELECT pid, application_name, connection_manager_client_addr,
    connection_manager_client_port, session_read_only, wait_event_type,
    wait_event, state, backend_type
FROM bdr.stat_activity;
Output
 pid |       application_name       | connection_manager_client_addr | connection_manager_client_port | session_read_only | wait_event_type | wait_event | state  |   backend_type    
-----+------------------------------+--------------------------------+--------------------------------+-------------------+-----------------+------------+--------+-------------------
  45 | pgd raft receiver 1187058264 |                                |                                | f                 | Client          | ClientRead | idle   | pgd raft receiver 
 318 | pgd raft receiver 4143208450 |                                |                                | f                 | Client          | ClientRead | idle   | pgd raft receiver 
 585 | psql                         | 172.22.0.4                     |                          46676 | f                 |                 |            | active | client backend    
(3 rows)

Query bdr.workers for PGD worker-specific details that bdr.stat_activity doesn't show. This example shows the workers that run as a single instance per node (consensus, manager, taskmgr, routing_manager, and connection_manager) alongside its receiver and writer workers, each tied to a subscription through worker_subid:

SELECT * FROM bdr.workers;
Output
 worker_pid | worker_role |  worker_role_name  | worker_subid 
------------+-------------+--------------------+--------------
         32 |           6 | consensus          |             
         30 |           1 | manager            |             
         33 |           8 | taskmgr            |             
         34 |           9 | routing_manager    |             
         35 |          14 | connection_manager |             
        398 |           2 | receiver           |    994291187
        399 |           2 | receiver           |   1275319208
        400 |           3 | writer             |   1275319208
        401 |           3 | writer             |    994291187
        402 |           3 | writer             |    994291187
        403 |           3 | writer             |   1275319208
(11 rows)

Check bdr.event_summary for the last error, if any, reported by a worker with a problem continuing its work. This information persists, so note the time of the error rather than just its existence. Most errors are transient, and PGD workers retry the failed operation automatically. For example, this query finds the two most recent worker errors:

SELECT event_node_name, event_type, event_sub_type, event_time, event_text
FROM bdr.event_summary
WHERE event_type = 'WORKER'
ORDER BY event_time DESC LIMIT 2;
Output
 event_node_name | event_type | event_sub_type |          event_time           |                event_text                
------------------+------------+----------------+--------------------------------+-------------------------------------------
 node-2           | WORKER     | ERROR          | 2026-08-25 16:53:38.111489+00 | terminating pgd receiver due to timeout
 node-3           | WORKER     | ERROR          | 2026-08-25 16:53:38.11192+00  | terminating pgd receiver due to timeout
(2 rows)

PGD writers

Query bdr.writers for the current status of writer workers, including:

  • sub_name to identify the subscription that the writer belongs to
  • pid of the writer process
  • streaming_allowed to know if the writer supports applying in-progress streaming transactions
  • is_streaming to know if the writer is currently applying a streaming transaction
  • commit_queue_position to check the position of the writer in the commit queue

PGD honors commit ordering by following the same commit order as happened on the origin. With parallel writers, multiple writers might apply different transactions at the same time. The commit_queue_position shows the order in which they commit. Value 0 means that the writer is the first one to commit. Value -1 means that the commit position isn't yet known, which can happen for a streaming transaction or when the writer isn't currently applying any transaction. For example, in the following output the first writer is in commit position 0, applying a regular, non-streamed transaction. The second is mid-transaction and streaming, so its commit position isn't known yet. The third is idle, so its commit position isn't known either:

SELECT sub_name, pid, streaming_allowed, is_streaming, commit_queue_position
FROM bdr.writers;
Output
             sub_name             | pid | streaming_allowed | is_streaming | commit_queue_position 
----------------------------------+-----+--------------------+--------------+------------------------
 bdr_pgddb_group_1_node_2_node_1  | 401 | t                  | f            |                      0
 bdr_pgddb_group_1_node_3_node_1  | 402 | t                  | t            |                     -1
 bdr_pgddb_group_1_node_2_node_1  | 403 | f                  | f            |                     -1
(3 rows)

Finding writers that wait on locks

Writers follow the same locking rules as user sessions, so a writer can wait on a lock that a user transaction holds, and replication from that node falls behind until the lock is released. bdr.stat_writer shows a writer that's waiting on a lock. Most waits are short, since Postgres resolves deadlocks by ending one of the transactions, and a writer that Postgres ends retries the transaction and generally succeeds.

List the writers that are blocked, with the sessions that block them:

SELECT w.sub_name, w.worker_pid, w.wait_event_type, w.wait_event,
       b.pid AS blocking_pid, b.state, b.xact_start, b.query
  FROM bdr.stat_writer w
  JOIN pg_stat_activity b ON b.pid = ANY(w.blocked_by_pids)
 WHERE cardinality(w.blocked_by_pids) > 0
   AND b.backend_type = 'client backend';
Output
            sub_name             | worker_pid | wait_event_type |   wait_event  | blocking_pid |        state        |          xact_start           |                      query
---------------------------------+------------+-----------------+---------------+--------------+---------------------+-------------------------------+--------------------------------------------------
 bdr_pgddb_group_1_node_1_node_2 |       2399 | Lock            | transactionid |         2687 | idle in transaction | 2026-10-05 15:18:18.573006+00 | SELECT * FROM orders WHERE id = 1001 FOR UPDATE;
(1 row)

The query lists only user sessions. A writer can also wait for another writer of the same subscription, which resolves without action.

To log lock waits for later review, enable Postgres's log_lock_waits configuration parameter.

Apply statistics

Query bdr.stat_subscription for subscription statistics and bdr.stat_relation for relation statistics, PGD's two views for replication apply statistics per subscription and per table. Both provide:

  • ninsert, nupdate, ndelete, and ntruncate for the number of INSERT, UPDATE, DELETE, and TRUNCATE operations replicated
  • shared_blks_hit, shared_blks_read, shared_blks_dirtied, and shared_blks_written for block accesses and cache hit ratio
  • blk_read_time and blk_write_time for total I/O time spent reading and writing blocks

For relations only, bdr.stat_relation also includes:

  • total_time, the total time spent processing replication for the relation
  • lock_acquire_time, the total lock wait time to acquire a lock on the relation, if any

For subscriptions only, bdr.stat_subscription also includes:

  • nconnect, the number of times the subscription has connected to its origin node
  • ncommit and nddl, the number of COMMIT and DDL operations replicated for the subscription
  • nstream_writer, nstream_file, nstream_commit, and nstream_abort, for transactions streamed to writer or file, and streamed transactions committed or aborted

For example:

SELECT sub_name, nconnect, ninsert, ncommit, nupdate, ndelete, ntruncate, nddl
FROM bdr.stat_subscription;
Output
             sub_name             | nconnect | ninsert | ncommit | nupdate | ndelete | ntruncate | nddl 
-----------------------------------+----------+---------+---------+---------+---------+-----------+------
 bdr_pgddb_group_1_node_2_node_1   |        3 |      10 |       5 |       0 |       0 |         0 |    2
(1 row)

In this case, the subscription connected three times to its origin node, inserted 10 rows, and performed two DDL commands inside five transactions.

The configuration parameters bdr.track_subscription_apply and bdr.track_relation_apply control tracking of these statistics, respectively. bdr.track_subscription_apply defaults to on, but bdr.track_relation_apply defaults to off, so bdr.stat_relation returns no rows until you turn it on.

Reset the stats counters for these views to zero with the functions bdr.reset_subscription_stats and bdr.reset_relation_stats.

Query bdr.stat_receiver and bdr.stat_writer for the receiver and writer process statistics behind each subscription, respectively.

Standard Postgres statistics views

Query pg_stat_user_tables and pg_statio_user_tables on the node applying replicated changes to check table usage. PGD applies changes there as real write operations, so these statistics update normally, and autovacuum uses them to keep query performance up.

Expect n_tup_ins, n_tup_upd, and n_tup_del in pg_stat_user_tables to roughly match between nodes once statistics were reset during a quiescent period, some changes have replicated between the nodes in either direction, and all replication lag has since drained, so the cluster is quiescent again when you query both nodes. The rest of pg_stat_user_tables, and all of pg_statio_user_tables, reflects each node's own query and I/O activity, so don't expect those columns to match. For example:

SELECT relname, n_tup_ins, n_tup_upd, n_tup_del
FROM pg_stat_user_tables
WHERE relname = 'orders';
Output
 relname | n_tup_ins | n_tup_upd | n_tup_del 
---------+-----------+-----------+-----------
 orders  |   1000000 |   1000000 |         0
(1 row)

This query returns the same result on both node-1 and node-2 once the 1M inserts and 1M updates to orders have fully replicated between them and the cluster is quiescent again, regardless of which node the writes originated on.

Query pg_stat_user_indexes for idx_scan on the applying node to check index usage. Expect identifying indexes to see heavier use than non-identifying indexes under UPDATE and DELETE workloads, since indexes are used to apply changes. pg_statio_user_indexes reports the same indexes' block I/O and cache activity.

See the PostgreSQL documentation on the statistics views for details on all these views.

Monitoring consensus and routing

Check Raft consensus, connection routing, and global locks, especially after a network split, node outage, or election, since all three depend on cluster-wide agreement and that's where a stuck DDL statement, a failed election, or misrouted connections show up.

Raft consensus

Confirm Raft consensus is working across all nodes, since PGD relies on it to coordinate global DDL/DML locks, Eager Replication, and galloc sequence chunk allocation across the cluster. Regular data replication keeps working even when Raft consensus is temporarily unavailable. While it's down, operations that need cluster-wide agreement, such as acquiring a global lock, allocating a new galloc sequence chunk, joining or parting a node, or promoting a standby, wait until consensus resumes instead of completing, and the PGD group replication slot pauses advancing its LSN until then.

Query bdr.group_raft_details to check Raft consensus status across all nodes at once. For example:

SELECT node_id, node_name, node_group_name, state, leader_id
FROM bdr.group_raft_details;
Output
  node_id   | node_name | node_group_name |     state     | leader_id  
------------+-----------+-----------------+---------------+------------
  349596469 | node-1    | pgd             | RAFT_LEADER   |  349596469
 4143208450 | node-2    | pgd             | RAFT_FOLLOWER |  349596469
 1187058264 | node-3    | pgd             | RAFT_FOLLOWER |  349596469
  349596469 | node-1    | group-1         | RAFT_FOLLOWER | 4143208450
 4143208450 | node-2    | group-1         | RAFT_LEADER   | 4143208450
 1187058264 | node-3    | group-1         | RAFT_FOLLOWER | 4143208450
(6 rows)

Each PGD group elects its own Raft leader, so a node can be the RAFT_LEADER for one group and a RAFT_FOLLOWER for another. Here, node-1 leads the top-level pgd group, while node-2 leads the group-1 subgroup.

Raft consensus works as long as a majority of nodes in the group can reach each other over the network. When a majority is reachable, querying bdr.group_raft_details shows, for each node_group_name:

  • A valid state (RAFT_LEADER or RAFT_FOLLOWER) on all nodes in the group.
  • Only one node in the group as RAFT_LEADER.
  • The same leader_id on every row for the group, matching the node_id of the row where state = RAFT_LEADER.

Raft consensus periodically starts a new election, independently for each group, to define a new RAFT_LEADER. During an election, there might be an intermediary situation where there's no RAFT_LEADER, and some of the nodes consider themselves as RAFT_CANDIDATE. If no RAFT_LEADER is elected within bdr.raft_global_election_timeout (6 seconds by default), PGD starts a new election attempt. If the query above returns an in-election situation, wait for the timeout to pass and run the query again. If the timeout has passed and some of the listed conditions still aren't met, Raft consensus isn't working as expected.

Raft consensus might not be working correctly on only a single node, for example if that node doesn't recognize the current leader and considers itself a RAFT_CANDIDATE. In this case, ensure that:

  • All PGD nodes can reach each other over both regular and replication connections, which you can verify in pg_hba.conf.
  • bdr.raft_global_election_timeout is the same on all nodes.

In some cases, especially if nodes are geographically distant from each other or network latency is high, the default value of bdr.raft_global_election_timeout (6 seconds) might not be enough. If Raft consensus is still not working after checking all of the above, increase bdr.raft_global_election_timeout to 30 seconds on all nodes.

Query bdr.monitor_group_raft() for a cluster-wide Raft check, built on the Raft consensus status information returned from the view bdr.group_raft_details. Since Raft consensus affects cluster operational tasks and is directly responsible for advancing the group slot, expect one of the following status summaries:

StatusMessage
UNKNOWNThis node is not part of any BDR group
OKRaft Consensus is working correctly
WARNINGThere is at least 1 node that is not accessible
WARNINGThere are node(s) as RAFT_CANDIDATE, an election might be in progress
WARNINGThere is no RAFT_LEADER, an election might be in progress
CRITICALThere is a single node in Raft Consensus
WARNINGThere are node(s) as RAFT_CANDIDATE while a RAFT_LEADER is defined
CRITICALThere are node(s) following a leader different than the node set as RAFT_LEADER
CRITICALThe BDR group raft does not reach the quorum

For example:

SELECT * FROM bdr.monitor_group_raft();
Output
 node_group_name | status |               message                
------------------+--------+---------------------------------------
                  | OK     | Raft Consensus is working correctly
(1 row)

Pass a group name, such as bdr.monitor_group_raft('group-1'), to check just a PGD group in particular.

Query bdr.stat_raft_state for a closer look at the state of Raft consensus on the local node, per group. This example runs on node-1, which leads the pgd group but follows node-2 in group-1:

SELECT group_name, raft_state, leader_name, is_voting, nnodes, nvoting_nodes
FROM bdr.stat_raft_state;
Output
 group_name | raft_state    | leader_name | is_voting | nnodes | nvoting_nodes 
------------+---------------+-------------+-----------+--------+---------------
 pgd        | RAFT_LEADER   | node-1      | t         |      3 |             3
 group-1    | RAFT_FOLLOWER | node-2      | t         |      3 |             3
(2 rows)

Query bdr.stat_raft_followers_state on the Raft leader only, for the state of its followers. Run on the same node-1, the output shows only the followers of the group it leads (pgd), not group-1, since node-1 isn't that group's leader:

SELECT group_name, node_name, sent_commit_index, match_index, last_heartbeat_response_time
FROM bdr.stat_raft_followers_state;
Output
 group_name | node_name | sent_commit_index | match_index |  last_heartbeat_response_time  
------------+-----------+-------------------+-------------+--------------------------------
 pgd        | node-2    |             27170 |       27170 | 2026-09-23 12:27:38.671737+00
 pgd        | node-3    |             27170 |       27170 | 2026-09-23 12:27:38.671441+00
(2 rows)

Routing

Confirm routing is working correctly, since it's critical for a seamless application experience, fast failure detection, minimal disruption, and load balancing where it's supported. Query these two views to check it:

For example:

SELECT * FROM bdr.stat_routing_state;
Output
 node_group_name | write_lead_name | previous_write_lead_name |   read_names    | write_candidate_names  |  read_candidate_names  
------------------+-----------------+--------------------------+------------------+------------------------+------------------------
 group-1          | node-1          | node-1                   | {node-3,node-2} | {node-1,node-3,node-2} | {node-1,node-3,node-2}
(1 row)

Global locks

Watch for DDL, and the DML it affects, stuck waiting on a global lock across the PGD group. There are two types of global locks used for DDL replication:

  • A DDL lock, used for serializing all DDL operations on permanent (not temporary) objects, such as tables and sequences, in the database
  • A DML relation lock, used for locking out writes to relations during DDL operations that change the relation definition

PGD creates either or both lock types for the same transaction, depending on the type of DDL operation and the value of the bdr.ddl_locking configuration parameter.

Check bdr.global_locks to observe the global locks held on the local node.

bdr.global_locks shows the relation being locked, the PID holding the lock if local, and whether the lock was globally granted. It also tracks global advisory locks, which you take with bdr.global_advisory_lock() and release with bdr.global_advisory_unlock(). Unlike regular Postgres advisory locks, these are cluster-wide, taken by majority consensus, so they still work even if some nodes are down or lagging. For these, lock_type shows GLOBAL_LOCK_ADVISORY, and relation shows the advisory keys the lock is acquired on.

This example shows the output of bdr.global_locks while running an ALTER TABLE statement with bdr.ddl_locking = 'all':

SELECT lock_type, relation, pid FROM bdr.global_locks;
Output
    lock_type     |       relation        |  pid  
-------------------+-----------------------+-------
 GLOBAL_LOCK_DDL   | [NULL]                | 15534
 GLOBAL_LOCK_DML   | someschema.sometable  | 15534
(2 rows)

See Catalogs for details on all fields, including lock timing information.

Monitoring transactions and conflicts

Check commit scopes to catch slow or stuck commits, and replication conflicts to find concurrent writes worth resolving in your application.

Commit scopes

Commit scopes let you choose the consistency and availability tradeoffs for your transactions, but they also affect transaction performance and, in failure scenarios, can make transactions appear stuck. Query these two views for commit scope statistics:

  • bdr.stat_commit_scope for cumulative statistics for each commit scope. Check ncalls, ncommits, and naborts to see how often a commit scope is used and how often it aborts, and total_commit_time, min_commit_time, max_commit_time, and mean_commit_time to track its commit performance over time. Use it to see how well a commit scope is performing, and to catch it if it starts aborting more often, running slower, or degrading frequently.

  • bdr.stat_commit_scope_state for the commit scopes backend processes are using right now, including which operation each backend is waiting on (waiting_op_num) and how many PREPARE, COMMIT, or LSN confirmations it still needs (waiting_prepare_confirmations, waiting_commit_confirmations, waiting_lsn_confirmations). Use it to see exactly what a specific transaction is stuck waiting for, not just that it's stuck.

bdr.stat_activity (see PGD replication workers) also reports transaction commits in progress. Its wait_event column shows the commit scope's wait state while a transaction commits. By default, PGD commits a transaction immediately on the local node and replicates it to the other nodes asynchronously, so a COMMIT is processed quickly and rarely shows waiting. This monitoring only covers transactions in progress, and doesn't provide historical timing information.

A commit scope with a DEGRADE ON clause relaxes its requirements after a timeout or a connectivity problem. Query bdr.stat_commit_scope to track these degrade events:

  • ndegrades counts the transactions that hit the degrade timeout during commit and degraded individually.
  • nconfig_degrades counts the times the manager background worker switched the commit scope's shared state to degraded, based on node availability checks. Each switch affects every subsequent transaction using that commit scope until PGD recovers it.
  • last_state_change_time records when the commit scope last entered or recovered from the degraded state.

This query finds commit scopes that have degraded, and how long ago:

SELECT
  commit_scope_name,
  ndegrades,
  nconfig_degrades,
  last_state_change_time,
  CASE
    WHEN last_state_change_time IS NULL THEN 'never degraded'
    WHEN age(now(), last_state_change_time) < interval '5 seconds' THEN 'recently changed'
    ELSE 'stable for ' || age(now(), last_state_change_time)::text
  END AS state_change_info
FROM bdr.stat_commit_scope
WHERE ndegrades > 0 OR nconfig_degrades > 0
ORDER BY last_state_change_time DESC NULLS LAST;

Conflicts

Identify replication conflicts, which can arise when multiple nodes make changes that affect the same rows in ways that can interact with each other, and make application changes where possible to eliminate the conflicts or make them less frequent.

PGD logs every conflict to bdr.conflict_history by default. Because this table exposes the full conflicting data, row-level security limits it to the owners of the affected replicated tables. As an owner, expect conflicts to show up on this table, and review them to see which ones are worth resolving.

Query bdr.conflict_history_summary for monitoring instead, since it doesn't contain user data. This example shows a query to count the number of conflicts seen in the current day using an efficient query plan:

SELECT count(*)
FROM bdr.conflict_history_summary
WHERE local_time > date_trunc('day', current_timestamp)
  AND local_time < date_trunc('day', current_timestamp + '1 day');

Monitoring background workers and versions

Watch for the manager worker getting stuck partway through a background task, and confirm every node converges back to the same PGD version after a rolling upgrade, when versions can temporarily differ.

The manager worker

Check what the manager worker is doing, since it's responsible for many background tasks, including managing all the other workers. Query the bdr.stat_worker view for per-worker statistics on PGD workers, including manager workers. Its query field reports the manager's current task, prefixed with pgd manager:, and its worker_backend_state field reports whether the manager is idle or busy. For example, this manager is busy moving the group slot:

SELECT worker_role, worker_pid, worker_backend_state, query,
    worker_query_start
FROM bdr.stat_worker
WHERE worker_role = 'manager';
Output
 worker_role | worker_pid | worker_backend_state |              query              |      worker_query_start       
-------------+------------+-----------------------+----------------------------------+-------------------------------
 manager     |         30 | active                | pgd manager: moving group slot  | 2026-09-23 14:07:29.116613+00
(1 row)

A manager that stays active on the same task for far longer than that task normally takes, with worker_query_start not advancing, is stuck and needs investigation.

PGD versions

Query bdr.group_versions_details to check the Postgres and BDR extension versions running across nodes. PGD allows these to differ across nodes in the same cluster, such as during an upgrade. For example:

SELECT node_name, postgres_version, bdr_version
FROM bdr.group_versions_details;
Output
 node_name |                             postgres_version                             |    bdr_version     
-----------+--------------------------------------------------------------------------+--------------------
 node-1    | 17.10 (EDB Postgres Extended Server 17.10.0) (Debian 0:17.10-1.bookworm) | PGD 6.4.0 Expanded
 node-3    | 17.10 (EDB Postgres Extended Server 17.10.0) (Debian 0:17.10-1.bookworm) | PGD 6.4.0 Expanded
 node-2    | 17.10 (EDB Postgres Extended Server 17.10.0) (Debian 0:17.10-1.bookworm) | PGD 6.4.0 Expanded
(3 rows)

Keep all nodes on the same, latest versions as soon as possible, and avoid running different versions of the BDR extension for too long. Query bdr.monitor_group_versions() for a cluster-wide version check, built on PGD version information returned from the view bdr.group_versions_details. Expect one of the following status summaries:

StatusMessage
UNKNOWNThis node is not part of any BDR group
OKAll nodes are running same BDR versions
WARNINGThere is at least 1 node that is not accessible
WARNINGThere are node(s) running different PGD versions when compared to other nodes

For example:

SELECT * FROM bdr.monitor_group_versions();
Output
 status |                message
--------+-----------------------------------------
 OK     | All nodes are running same BDR versions
(1 row)