Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[BUGS] BUG #14279: Logical decoding misses a transaction completely

1 view
Skip to first unread message

ma...@joh.to

unread,
Aug 4, 2016, 3:18:22 PM8/4/16
to
The following bug has been logged on the website:

Bug reference: 14279
Logged by: Marko Tiikkaja
Email address: ma...@joh.to
PostgreSQL version: 9.5.3
Operating system: Linux
Description:

Hi,

The following transaction does not get decoded at all in logical decoding:

BEGIN;
INSERT INTO foo VALUES ('bar');
SAVEPOINT s;
SELECT 1 FROM foo FOR UPDATE;
RELEASE SAVEPOINT s;
COMMIT;

The problem seems to be that ReorderBufferCommitChild() overwrites the main
transaction's base_snapshot with a NULL because it thinks the
subtransaction's base_snapshot_lsn=0 is older than the main transaction's
actual snapshot, which in ReorderBufferCommit:

/*
* If this transaction didn't have any real changes in our database,
it's
* OK not to have a snapshot. Note that ReorderBufferCommitChild will
have
* transferred its snapshot to this transaction if it had one and the
* toplevel tx didn't.
*/
if (txn->base_snapshot == NULL)
{
Assert(txn->ninvalidations == 0);
ReorderBufferCleanupTXN(rb, txn);
return;
}

causes the entire transaction to be skipped. I didn't debug further.

(Thanks to Andres Freund and Andrew Gierth for helping me track this problem
down!)


--
Sent via pgsql-bugs mailing list (pgsql...@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Andrew Gierth

unread,
Aug 4, 2016, 3:40:29 PM8/4/16
to
>>>>> "marko" == marko <ma...@joh.to> writes:

marko> The problem seems to be that ReorderBufferCommitChild()
marko> overwrites the main transaction's base_snapshot with a NULL
marko> because it thinks the subtransaction's base_snapshot_lsn=0 is
marko> older than the main transaction's actual snapshot

i.e. here in ReorderBufferCommitChild:

/*
* Pass the our base snapshot to the parent transaction if it doesn't have
* one, or ours is older. That can happen if there are no changes in the
* toplevel transaction but in one of the child transactions. This allows
* the parent to simply use it's base snapshot initially.
*/
if (txn->base_snapshot == NULL ||
txn->base_snapshot_lsn > subtxn->base_snapshot_lsn)
{

it's possible for subtxn to exist, but for subtxn->base_snapshot to be
NULL and base_snapshot_lsn to be 0, and obviously propagating this to
txn is wrong.

--
Andrew (irc:RhodiumToad)
0 new messages