Troubleshooting
The messages DBTrail prints about a PostgreSQL source, what causes each one, and how to fix it.
When something is wrong with a PostgreSQL source, run DBTrail's checks first. They find most of the problems below, and print the statement that fixes each one.
Copy and paste
On the DBTrail machine (it has Docker):
docker run --rm --network host ghcr.io/dbtrail/bintrail-pg:latest doctor \
--query-dsn "postgres://dbtrail:$DBTRAIL_PW@$PGHOST:${PGPORT:-5432}/$PGDATABASE" \
--slot "bintrail_$PGDATABASE" --publication bintrail_pubIt reads $PGHOST, $PGDATABASE and $DBTRAIL_PW from
Prepare, step 1. Each line starts with a mark:
✓the check passed;!a warning: capture works, but read the advice under it;✗a failure, with the statement to run under it.
All is well when the last lines say Failed: 0. A failure, for example:
✗ REPLICA IDENTITY FULL (1 table of the publication is not at REPLICA IDENTITY FULL, so its changes are not captured: "public"."customers")
ALTER TABLE "public"."customers" REPLICA IDENTITY FULL;Run the statement on your PostgreSQL, then run the checks again. For any other message, find it in the table below.
In detail
Most problems with a PostgreSQL source show up as a message from DBTrail's checks or from capture. Find the message below for its cause and fix. A step number is a step of every step in full.
Tip: run
bintrail-pg doctorto catch most of the rows below before they cost you a debugging cycle: it checkswal_level, publication coverage, replica identity,max_slot_wal_keep_size, and live slot health in one shot.
| Symptom | Cause / fix |
|---|---|
wal_level is "replica", must be 'logical' | Set wal_level = logical and restart the server (a reload is not enough). |
publication "…" does not exist — create it | Create the publication first (step 4): bintrail-pg never creates it. |
publication "…" does not cover requested table(s) […] | Your --schemas/--tables include tables not in the publication; ALTER PUBLICATION … ADD TABLE … (or widen the publication). |
table is not at REPLICA IDENTITY FULL; its changes are NOT captured | ALTER TABLE <t> REPLICA IDENTITY FULL (each partition too, for a partitioned table); capture of the table resumes by itself, and its next full read brings the copy up to date (step 3). On PostgreSQL 18, read the generated-columns note first. |
cannot undo a change in … was not captured, because the table was not at REPLICA IDENTITY FULL | The window holds an UPDATE or a DELETE that version 0.138.0 recorded while the table was not at FULL. It cannot be undone (Upgraded from 0.138.0). |
table's replica identity does not hold its primary key; its changes are NOT captured | ALTER TABLE <t> REPLICA IDENTITY FULL; capture of the table resumes by itself (step 3). |
table has a primary key declared DEFERRABLE; its changes are NOT captured | Make the key not deferrable (ALTER TABLE <t> DROP CONSTRAINT <key>, ADD PRIMARY KEY (...)), or take the table out of the publication (step 3). |
publication "…" applies a row filter or column list to table(s) […] | A PG15+ WHERE (...) row filter or column list makes pgoutput emit only a subset of changes (silent data loss). Recreate the publication (or ALTER PUBLICATION … SET TABLE … re-listing the tables) without WHERE (...) / column lists. |
publication "…" does not publish […] — those changes would be silently lost | The publication was created with a narrowed publish option (e.g. WITH (publish = 'insert')). Run ALTER PUBLICATION … SET (publish = 'insert, update, delete, truncate') (it keeps the publication's tables and other options), or recreate it leaving publish unset (the default publishes all operations). |
replication slot "…" is invalidated (wal_status=lost; max_slot_wal_keep_size exceeded) | The source dropped WAL the slot still needed (slot was stopped too long). The data since the checkpoint is gone: bintrail-pg reset (drops the slot + clears the checkpoint), re-seed, and raise max_slot_wal_keep_size / keep the consumer running. bintrail status shows this as a loud EVENTS PERMANENTLY LOST banner. |
no table was read: replication slot "…" is still being created after 5m0s | A snapshot was asked for while capture was creating the slot, and the slot did not get its position in 5 minutes: write transactions open on the source since before the creation began are holding it back (pg_stat_activity: the oldest xact_start among the rows with a backend_xid). Nothing was read. Run the snapshot again once the slot has a confirmed_flush_lsn in pg_replication_slots. |
replication slot "…" no longer exists: it was removed while the snapshot was read | The slot the snapshot started from was dropped before the read ended, so the changes made since may not be captured. The snapshot was not kept. Run it again once capture is attached. |
the snapshot is not published: capture of this server started reading the source at …, after … | The slot was replaced while the tables were read, and capture started from the new one. The snapshot was not kept. Run it again. |
the table's snapshot holds its changes from … on, and capture of the server started reading the source at …, after it | The snapshot was taken before capture had its slot (possible before this check existed), so changes between the two were never captured. The update is refused; a scheduled update is replaced by a full read of the source, and a snapshot taken by hand (snapshot run) repairs it too. |
whether the table's snapshot starts before capture of the server did could not be checked | The update could not read where capture started from the index (stream_state), within 5 seconds. The update is refused rather than letting the table through, because once rewritten a gap in it could not be seen again; a scheduled update is replaced by a full read, as for any failed update. Check the index is reachable and the account can read stream_state. |
resuming from a saved checkpoint but replication slot "…" no longer exists | The slot was dropped while a checkpoint still pointed at it. Creating a fresh slot would skip data, so bintrail-pg refuses: bintrail-pg reset --index-only to clear the checkpoint and start fresh if the gap is acceptable. |
must include replication=database (connection error on --repl-dsn) | Add replication=database to the --repl-dsn connection string. |
| Permission denied opening replication / creating slot | The role needs the REPLICATION attribute (ALTER ROLE <r> REPLICATION;), or on managed PG the provider's replication grant. |
Upgraded from 0.138.0
Version 0.138.0 captured tables that were not at REPLICA IDENTITY FULL. From
0.139.0 such a table is not captured:
- Its changes from the upgrade on are skipped, and
statusshows capture asDEGRADEDunderreplica_identity_not_full. The other tables go on. - What 0.138.0 recorded of it stays in the history. Undo refuses its
UPDATEs andDELETEs, andverifystops on them; that does not mean the data is wrong. - To capture it again, run the
ALTER TABLEthatdoctorprints, then a full read of the table, so its copy holds the changes skipped in between. - A stopped server with such a table cannot be started from the web interface until the table is fixed or out of the publication.