BUG #15808: ERROR: subtransaction logged without previous top-level txn record (SQLSTATE XX000) - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15808: ERROR: subtransaction logged without previous top-level txn record (SQLSTATE XX000)
Date
Msg-id 15808-b2c1d6d05b7ef045@postgresql.org
Whole thread Raw
Responses Re: BUG #15808: ERROR: subtransaction logged without previoustop-level txn record (SQLSTATE XX000)
List pgsql-bugs
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.


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #15804: Assertion failure when using logging_collector with EXEC_BACKEND
Next
From: Michael Paquier
Date:
Subject: Re: BUG #15804: Assertion failure when using logging_collector withEXEC_BACKEND