Limitations
What DBTrail does not capture or rebuild on a PostgreSQL server, and where the copy answers differently from PostgreSQL.
Read this before you point DBTrail at production. In short:
UNLOGGEDtables are not captured. PostgreSQL writes no change log for them.- A
TRUNCATEis recorded, and cannot be undone. No row is kept for it. - Sequence positions are not captured. After a restore, run the sequence fix.
- Which session made a change is not known. PostgreSQL does not send it.
- One database per replication slot. Capture each database of a cluster as a server of its own.
- One family of databases per installation. An installation that serves PostgreSQL serves only PostgreSQL.
- A division on the copy has 16 decimals. Write
round(a / b, k)to get PostgreSQL's exact text (why).
Check your own server
DBTrail's checks find the tables it would miss (UNLOGGED tables, a cascade
child left out of the publication, a table not ready), on a machine with
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_pubWhat each line means: Troubleshooting.
In detail
What DBTrail does not do on a PostgreSQL server, or does only in part. Read it before you point DBTrail at production.
Versions and installations
PostgreSQL 15 to 18 is supported (13 and 14 may work, best effort).
One database family per installation
An installation that serves PostgreSQL servers serves PostgreSQL servers only. The first server you add decides which family of databases an installation serves, and + Add server then offers that family's server types. A server of another family is refused with a message that says so, and nothing is changed.
PostgreSQL support and the support for other databases are tested and released apart and are never run together in one process, so the combination is not offered. This is about the databases DBTrail captures from: DBTrail's history store is the same for every family.
To capture another family of databases as well, run a second installation beside the first, in a folder with another name and on a port of its own:
curl -fsSL https://raw.githubusercontent.com/dbtrail/dbtrail/main/install.sh | DBTRAIL_DIR=./dbtrail-2 DBTRAIL_PORT=8091 shIt has its own containers, its own index, and its own web interface and login
on that port. The folder's name is what keeps the two apart, not its place:
two folders that end in the same name (/opt/dbtrail and /srv/dbtrail)
would share their data.
The ports the first installation holds are found taken. Metrics move to a
free port by themselves. The PostgreSQL port (5433) is left unpublished: a second PostgreSQL installation adds a ports: line
to its pg-router service (such as 127.0.0.1:5434:5433) and connects to
that number.
If the servers file already holds both families (it was edited by hand, or comes from a version before this rule), nothing stops: every server is still captured and served, an error in the log names the servers, and a server can still be edited, which is how a changed password is put right. No server can be added until one family is left. Remove the servers of one family to get there.
Capture and recovery
UNLOGGEDtables are not captured. They bypass the WAL by design, so logical decoding never sees them. bintrail-pg warns when an UNLOGGED table is in capture scope (atstreamstartup and inbintrail-pg doctor), under aFOR ALL TABLESpublication and under aFOR TABLES IN SCHEMA(PostgreSQL 15+) publication's member schemas alike, but the changes are still not captured, so don't rely on bintrail for UNLOGGED data.- A cascade child must be in the publication. A foreign-key
ON DELETE CASCADE/SET NULLis captured (PostgreSQL performs it as ordinary row changes) only if the child table is published. If a published parent has an unpublished cascade child, the cascade rewrites are not captured: bintrail-pg warns (startup- doctor); add the child to the publication.
TRUNCATEis recorded as an audit marker, not a reversible change. A PostgreSQLTRUNCATEemits no per-rowDELETE, so left uncaptured it would be indistinguishable from "nothing happened". bintrail-pg records it as aschema_changesrow (ddl_type = TRUNCATE TABLE): surfaced by thelist_schema_changesMCP tool and in theschema_changestable. It is a record that the truncate happened, not a reversible event:recoverhas no per-row before-images to put back, and areconstructwhose window crosses the truncate refuses instead of bringing the removed rows back. A multi-tableTRUNCATE a, brecords one marker per published table; a truncate of an out-of-scope table records nothing. All of this needs a publication that publishestruncate: without it PostgreSQL sends nothing and no marker is recorded (see step 4).- Other schema changes are inferred, not read. See Schema changes on PostgreSQL.
- Sequence cursors are not captured. The materialized id values in your rows
are captured; the sequence's own
last_value(a separate catalog object) is not: logical decoding does not replicate sequences. After a restore, re-point eachSERIAL/IDENTITYsequence pastMAX(id): recipe and when it matters in Sequences after recovery. GENERATED ... AS IDENTITY/ generated columns can need care on recovery (GENERATED ALWAYS AS IDENTITYrejects an explicit insert;STOREDgenerated columns are absent from the stream before PostgreSQL 18). Treat as best-effort. The copy never holds a generated column: the database computes it. On PostgreSQL 18 a table with aVIRTUALgenerated column cannot be captured, and one with aSTOREDone needspublish_generated_columns = storedon the publication (PostgreSQL 18 and generated columns).- Full-table
reconstructwrites snapshots (--output-format parquet, andbaseline refresh) or SQL psql loads (--output-format psql) (see Full-table snapshots).bintrail-pg drillrehearses the restore into a scratch PostgreSQL from the psql files.verifyis supported too: baseline-anchored, live-source, and recover-input modes are all supported for PostgreSQL sources (see Verify a recovery, including how the live-source coverage check differs). Single-rowreconstructand the shim's single-row_snapshotwork against a PG baseline and are validated end-to-end for scalar types, including the GUC-sensitive set, rendered under session GUCs pinned identically at capture and baseline; container types remain best-effort (see Querying and recovering). (recoverandrecover-cascadework unconditionally, with no baseline needed; cascades are captured as ordinary row changes: see Querying and recovering.) - No connection attribution.
pgoutputdoes not carry the backend PID, so theconnection_idcolumn is empty for PostgreSQL sources. Forensic attribution ("which session made this change") is therefore not available for PostgreSQL sources, and this is a settled decision, not a pending gap (#1212): the only way to recover the backend PID is to install something into your database, and bintrail installs nothing into a source. Everything else forensics offers (the full before/after row images, the change timeline,--query-hashgrouping where the source logs statements) works identically on PostgreSQL. - A large transaction arrives whole, after it commits. PostgreSQL sends a transaction only once it has committed, and every change committed after it waits behind it. One that changed a few million rows can leave the copy minutes behind; it catches up by itself. What counts is how many rows it changed, not how long it stayed open. A job that changes rows in bulk keeps the copy close by committing in batches.
- A partitioned table published through its parent
(
publish_via_partition_root): a change whose earlier row holds an empty (NULL) column is stored with its key only, and undo refuses that change. Nothing wrong is stored. A table that is not partitioned is not affected. - One database per slot. A logical slot is scoped to a single database; to
capture multiple databases on one cluster, run one
bintrail-pg stream(and slot/publication) per database. - No BYOS agent. The web interface captures PostgreSQL sources (+ Add
server → PostgreSQL);
bintrail agent(BYOS) does not support PostgreSQL.
The data-safety gates for PostgreSQL are closed
(#597): the data-safety set
(type fidelity, identity/generated recovery, slot/WAL monitoring, RI-FULL
validation, DDL-drift handling, the silent-loss coverage guards above),
baseline-anchored single-row reconstruct / time-travel with the
baseline↔delta rendering-GUC identity and its fold-validated type matrix
(#593), the managed-PostgreSQL smoke matrix (RDS and Aurora: see
Managed PostgreSQL), and source-aware web interface
presentation including the live replication-health panel (v0.20.1).
Full-table reconstruct writes snapshots (--output-format parquet, and
baseline refresh) or SQL psql loads (--output-format psql). A dump in any other format stays out of scope. verify
(baseline-anchored, live-source and recover-input) is supported.
Divisions and avg() on the PostgreSQL port
From 0.139.1 the copy answers a division and an avg() of numerics or whole
numbers written without round(), so percentages, shares and averages no
longer have to run on your PostgreSQL. The value is the same number, written
with another count of decimals (by design):
| Same statement | PostgreSQL | The copy |
|---|---|---|
| A quotient from 1 to 9999 | often 16 decimals: 7.5000000000000000 | 7.5000000000000000 |
| A quotient of 10000 or more | 12 decimals | 16 decimals |
| A quotient below 1 | 0.33333333333333333333 | 0.3333333333333333 |
2.00 / 2 | 20 decimals | 16 decimals |
Where such a value filters, groups, sorts or is summed, the rows can differ when the result turns on a digit past the sixteenth decimal:
amount / 3 = 33333.333333333333can match a row on one side and not on the other.a / b * b = acan be true on one side and false on the other.GROUP BY a / bof two quotients that differ only past the sixteenth decimal can be one group on one side and two on the other.
To get PostgreSQL's exact text, write round(a / b, k) or
round(avg(x), k). Those did not change. A server that hides tables or
columns, which sends nothing to your PostgreSQL, divides and averages as
before. What still goes to your PostgreSQL, such as a
divisor of zero, two whole numbers or a double precision:
which side answers a statement.