The following bug has been logged on the website:
Bug reference: 15808
Logged by: Mansour Behabadi
Email address: mansour@oxplot.com
PostgreSQL version: 10.6
Operating system: Amazon RDS
Description:
We have some custom logical replication client that makes
pg_logical_slot_get_changes() calls in SQL. E.g.:
select max(1) from pg_logical_slot_get_changes('testslot', '5754/E9332B68',
1000);
Once every few thousand calls, we get the following error:
ERROR: subtransaction logged without previous top-level txn record (SQLSTATE
XX000)
which will persist on all subsequent calls, essentially forcing us to drop
the slot and create a new one.
We had little success looking for solutions online and the only lead is that
of a recent commit
(https://github.com/postgres/postgres/commit/f49a80c481f74fa81407dce8e51dea6956cb64f8)
whose commit message seem to correlate to the error we're getting. Below is
the relevant excerpt:
The second issue concerns SnapBuilder snapshots and subtransactions.
SnapBuildDistributeNewCatalogSnapshot never assigned a snapshot to a
transaction that is known to be a subtxn, which is good in the common
case that the top-level transaction already has one (no point in doing
so), but a bug otherwise. To fix, arrange to transfer the snapshot from
the subtxn to its top-level txn as soon as the kinship gets known.
test_decoding's snapshot_transfer verifies this.
We're not sure if this is a fix to our problem and whether upgrading to
Postgres 11 (which has this change in it) will solve the issue.
Please let me know if any more info is needed.