CDC Sink for PostgreSQL: Monitoring PostgreSQL
-
This page covers PostgreSQL-side monitoring for CDC Sink tasks:
replication slot health, replication lag, and WAL disk usage. -
For RavenDB-side monitoring, see Monitoring.
-
In this article:
Replication slot health
List CDC Sink replication slots that use the auto-generated slot-name prefix and check whether they are active:
- SQL
SELECT slot_name, active, confirmed_flush_lsn
FROM pg_replication_slots
WHERE slot_name LIKE 'rvn_cdc_s_%';
The rvn_cdc_s_ prefix matches only auto-generated slot names.
If the task uses a custom SlotName, replace the filter with that name or remove the filter and cross-check the results against your CDC Sink task configurations.
| Column | Meaning |
|---|---|
active | true if CDC Sink is connected and consuming;false if no process is currently connected to the slot. |
confirmed_flush_lsn | The LSN up to which changes have been confirmed as consumed. |
A slot with active = false means CDC Sink is not currently connected.
This is expected during failover or when the task is disabled or stopped.
If the slot remains inactive for an extended period, investigate the task state in RavenDB Studio.
Replication lag
Replication lag measures how far the slot is behind the current WAL position:
- SQL
SELECT slot_name,
pg_wal_lsn_diff(pg_current_wal_lsn(), confirmed_flush_lsn) AS lag_bytes
FROM pg_replication_slots
WHERE slot_name LIKE 'rvn_cdc_s_%';
The rvn_cdc_s_ prefix matches only auto-generated slot names.
If the task uses a custom SlotName, adjust or remove the filter.
A consistently growing lag_bytes means CDC Sink is not keeping up with the rate
of changes in the source database. Consider:
- Checking CDC Sink performance statistics in RavenDB Studio for slow processing stages or scripts
- Increasing
CdcSink.MaxBatchSizeif the task is limited by batch size - Reducing load on the source database
WAL disk usage
PostgreSQL retains WAL that is still required by replication slots.
An inactive or slow CDC Sink slot can cause WAL files to accumulate on disk.
Check approximate WAL retained by CDC Sink slots that use the auto-generated slot-name prefix:
- SQL
SELECT slot_name, active,
pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) AS retained_wal_bytes
FROM pg_replication_slots
WHERE slot_name LIKE 'rvn_cdc_s_%'
ORDER BY retained_wal_bytes DESC NULLS LAST;
The rvn_cdc_s_ prefix matches only auto-generated slot names.
If the task uses a custom SlotName, adjust or remove the filter.
A high retained_wal_bytes value means PostgreSQL is retaining WAL for that slot.
- If the slot is active, CDC Sink is connected but may be processing changes slowly.
- If it is inactive, no process is currently consuming from it.
Before dropping a slot, verify that no CDC Sink task still needs it. For cleanup guidance, see Cleanup and Maintenance.