pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14279: Logical decoding misses a transaction completely
7+ messages / 6 participants
[nested] [flat]
* BUG #14279: Logical decoding misses a transaction completely
@ 2016-08-04 19:17 marko@joh.to
2016-08-04 19:40 ` Re: BUG #14279: Logical decoding misses a transaction completely Andrew Gierth <andrew@tao11.riddles.org.uk>
0 siblings, 1 reply; 7+ messages in thread
From: marko@joh.to @ 2016-08-04 19:17 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 14279
Logged by: Marko Tiikkaja
Email address: marko@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-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: BUG #14279: Logical decoding misses a transaction completely
2016-08-04 19:17 BUG #14279: Logical decoding misses a transaction completely marko@joh.to
@ 2016-08-04 19:40 ` Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-08-07 10:49 ` Re: BUG #14279: Logical decoding misses a transaction completely Marko Tiikkaja <marko@joh.to>
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Gierth @ 2016-08-04 19:40 UTC (permalink / raw)
To: marko@joh.to; +Cc: pgsql-bugs
>>>>> "marko" == marko <marko@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)
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: BUG #14279: Logical decoding misses a transaction completely
2016-08-04 19:17 BUG #14279: Logical decoding misses a transaction completely marko@joh.to
2016-08-04 19:40 ` Re: BUG #14279: Logical decoding misses a transaction completely Andrew Gierth <andrew@tao11.riddles.org.uk>
@ 2016-08-07 10:49 ` Marko Tiikkaja <marko@joh.to>
2016-08-07 11:11 ` Re: BUG #14279: Logical decoding misses a transaction completely Michael Paquier <michael.paquier@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Marko Tiikkaja @ 2016-08-07 10:49 UTC (permalink / raw)
To: Andrew Gierth <andrew@tao11.riddles.org.uk>; +Cc: pgsql-bugs
Ping. This is a very serious issue and it would be really good to
include it in the minor releases. I've attached a patch for 9.5 with a
test case and verified that it fixes the problem with our application.
.m
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
bug_14279.patch (text/x-patch, 4.6K) download
*** a/contrib/test_decoding/expected/xact.out
--- b/contrib/test_decoding/expected/xact.out
***************
*** 6,14 **** SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_d
init
(1 row)
- -- bug #13844, xids in non-decoded records need to be inspected
CREATE TABLE xact_test(data text);
INSERT INTO xact_test VALUES ('before-test');
BEGIN;
-- perform operation in xact that creates and logs xid, but isn't decoded
SELECT * FROM xact_test FOR UPDATE;
--- 6,14 ----
init
(1 row)
CREATE TABLE xact_test(data text);
INSERT INTO xact_test VALUES ('before-test');
+ -- bug #13844, xids in non-decoded records need to be inspected
BEGIN;
-- perform operation in xact that creates and logs xid, but isn't decoded
SELECT * FROM xact_test FOR UPDATE;
***************
*** 33,38 **** SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc
--- 33,60 ----
COMMIT
(6 rows)
+ -- bug #14279
+ BEGIN;
+ -- first insert
+ INSERT INTO xact_test VALUES ('main-txn');
+ SAVEPOINT foo;
+ -- and then perform operation in subxact that creates and logs xid, but isn't decoded
+ SELECT 1 FROM xact_test FOR UPDATE LIMIT 1;
+ ?column?
+ ----------
+ 1
+ (1 row)
+
+ COMMIT;
+ -- and now show those changes
+ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
+ data
+ -------------------------------------------------------
+ BEGIN
+ table public.xact_test: INSERT: data[text]:'main-txn'
+ COMMIT
+ (3 rows)
+
DROP TABLE xact_test;
SELECT pg_drop_replication_slot('regression_slot');
pg_drop_replication_slot
*** a/contrib/test_decoding/sql/xact.sql
--- b/contrib/test_decoding/sql/xact.sql
***************
*** 3,12 **** SET synchronous_commit = on;
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
- -- bug #13844, xids in non-decoded records need to be inspected
CREATE TABLE xact_test(data text);
INSERT INTO xact_test VALUES ('before-test');
BEGIN;
-- perform operation in xact that creates and logs xid, but isn't decoded
SELECT * FROM xact_test FOR UPDATE;
--- 3,12 ----
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
CREATE TABLE xact_test(data text);
INSERT INTO xact_test VALUES ('before-test');
+ -- bug #13844, xids in non-decoded records need to be inspected
BEGIN;
-- perform operation in xact that creates and logs xid, but isn't decoded
SELECT * FROM xact_test FOR UPDATE;
***************
*** 17,22 **** COMMIT;
--- 17,33 ----
-- and now show those changes
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
+ -- bug #14279
+ BEGIN;
+ -- first insert
+ INSERT INTO xact_test VALUES ('main-txn');
+ SAVEPOINT foo;
+ -- and then perform operation in subxact that creates and logs xid, but isn't decoded
+ SELECT 1 FROM xact_test FOR UPDATE LIMIT 1;
+ COMMIT;
+ -- and now show those changes
+ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
+
DROP TABLE xact_test;
SELECT pg_drop_replication_slot('regression_slot');
*** a/src/backend/replication/logical/reorderbuffer.c
--- b/src/backend/replication/logical/reorderbuffer.c
***************
*** 744,756 **** ReorderBufferCommitChild(ReorderBuffer *rb, TransactionId xid,
elog(ERROR, "subxact logged without previous toplevel record");
/*
! * 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)
{
txn->base_snapshot = subtxn->base_snapshot;
txn->base_snapshot_lsn = subtxn->base_snapshot_lsn;
--- 744,757 ----
elog(ERROR, "subxact logged without previous toplevel record");
/*
! * Pass 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 its base snapshot initially.
*/
! if (subtxn->base_snapshot != NULL &&
! (txn->base_snapshot == NULL ||
! txn->base_snapshot_lsn > subtxn->base_snapshot_lsn))
{
txn->base_snapshot = subtxn->base_snapshot;
txn->base_snapshot_lsn = subtxn->base_snapshot_lsn;
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: BUG #14279: Logical decoding misses a transaction completely
2016-08-04 19:17 BUG #14279: Logical decoding misses a transaction completely marko@joh.to
2016-08-04 19:40 ` Re: BUG #14279: Logical decoding misses a transaction completely Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-08-07 10:49 ` Re: BUG #14279: Logical decoding misses a transaction completely Marko Tiikkaja <marko@joh.to>
@ 2016-08-07 11:11 ` Michael Paquier <michael.paquier@gmail.com>
2016-08-07 16:14 ` Re: BUG #14279: Logical decoding misses a transaction completely Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 7+ messages in thread
From: Michael Paquier @ 2016-08-07 11:11 UTC (permalink / raw)
To: Marko Tiikkaja <marko@joh.to>; +Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-bugs; Andres Freund <andres@anarazel.de>; Robert Haas <robertmhaas@gmail.com>
On Sun, Aug 7, 2016 at 7:49 PM, Marko Tiikkaja <marko@joh.to> wrote:
> Ping. This is a very serious issue and it would be really good to include
> it in the minor releases. I've attached a patch for 9.5 with a test case
> and verified that it fixes the problem with our application.
Right. That's up to Robert or Andres to pick up that at this point. I
just added them in CC for awareness.
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: BUG #14279: Logical decoding misses a transaction completely
2016-08-04 19:17 BUG #14279: Logical decoding misses a transaction completely marko@joh.to
2016-08-04 19:40 ` Re: BUG #14279: Logical decoding misses a transaction completely Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-08-07 10:49 ` Re: BUG #14279: Logical decoding misses a transaction completely Marko Tiikkaja <marko@joh.to>
2016-08-07 11:11 ` Re: BUG #14279: Logical decoding misses a transaction completely Michael Paquier <michael.paquier@gmail.com>
@ 2016-08-07 16:14 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-08-08 01:49 ` Re: BUG #14279: Logical decoding misses a transaction completely Michael Paquier <michael.paquier@gmail.com>
2016-08-15 01:02 ` Re: BUG #14279: Logical decoding misses a transaction completely Andres Freund <andres@anarazel.de>
0 siblings, 2 replies; 7+ messages in thread
From: Tom Lane @ 2016-08-07 16:14 UTC (permalink / raw)
To: Michael Paquier <michael.paquier@gmail.com>; +Cc: Marko Tiikkaja <marko@joh.to>; Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-bugs; Andres Freund <andres@anarazel.de>; Robert Haas <robertmhaas@gmail.com>
Michael Paquier <michael.paquier@gmail.com> writes:
> On Sun, Aug 7, 2016 at 7:49 PM, Marko Tiikkaja <marko@joh.to> wrote:
>> Ping. This is a very serious issue and it would be really good to include
>> it in the minor releases. I've attached a patch for 9.5 with a test case
>> and verified that it fixes the problem with our application.
> Right. That's up to Robert or Andres to pick up that at this point. I
> just added them in CC for awareness.
Andres is on vacation, and if Robert is around it'd be better for him to
be looking at the toast snapshot problem. I can pick this up, probably.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: BUG #14279: Logical decoding misses a transaction completely
2016-08-04 19:17 BUG #14279: Logical decoding misses a transaction completely marko@joh.to
2016-08-04 19:40 ` Re: BUG #14279: Logical decoding misses a transaction completely Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-08-07 10:49 ` Re: BUG #14279: Logical decoding misses a transaction completely Marko Tiikkaja <marko@joh.to>
2016-08-07 11:11 ` Re: BUG #14279: Logical decoding misses a transaction completely Michael Paquier <michael.paquier@gmail.com>
2016-08-07 16:14 ` Re: BUG #14279: Logical decoding misses a transaction completely Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-08-08 01:49 ` Michael Paquier <michael.paquier@gmail.com>
1 sibling, 0 replies; 7+ messages in thread
From: Michael Paquier @ 2016-08-08 01:49 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Marko Tiikkaja <marko@joh.to>; Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-bugs; Andres Freund <andres@anarazel.de>; Robert Haas <robertmhaas@gmail.com>
On Mon, Aug 8, 2016 at 1:14 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Michael Paquier <michael.paquier@gmail.com> writes:
>> On Sun, Aug 7, 2016 at 7:49 PM, Marko Tiikkaja <marko@joh.to> wrote:
>>> Ping. This is a very serious issue and it would be really good to include
>>> it in the minor releases. I've attached a patch for 9.5 with a test case
>>> and verified that it fixes the problem with our application.
>
>> Right. That's up to Robert or Andres to pick up that at this point. I
>> just added them in CC for awareness.
>
> Andres is on vacation, and if Robert is around it'd be better for him to
> be looking at the toast snapshot problem. I can pick this up, probably.
I was going to review that, until I noticed that it has already been
addressed by bcbecbc. Thanks!
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: BUG #14279: Logical decoding misses a transaction completely
2016-08-04 19:17 BUG #14279: Logical decoding misses a transaction completely marko@joh.to
2016-08-04 19:40 ` Re: BUG #14279: Logical decoding misses a transaction completely Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-08-07 10:49 ` Re: BUG #14279: Logical decoding misses a transaction completely Marko Tiikkaja <marko@joh.to>
2016-08-07 11:11 ` Re: BUG #14279: Logical decoding misses a transaction completely Michael Paquier <michael.paquier@gmail.com>
2016-08-07 16:14 ` Re: BUG #14279: Logical decoding misses a transaction completely Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-08-15 01:02 ` Andres Freund <andres@anarazel.de>
1 sibling, 0 replies; 7+ messages in thread
From: Andres Freund @ 2016-08-15 01:02 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Michael Paquier <michael.paquier@gmail.com>; Marko Tiikkaja <marko@joh.to>; Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-bugs; Robert Haas <robertmhaas@gmail.com>
On 2016-08-07 12:14:02 -0400, Tom Lane wrote:
> Michael Paquier <michael.paquier@gmail.com> writes:
> > On Sun, Aug 7, 2016 at 7:49 PM, Marko Tiikkaja <marko@joh.to> wrote:
> >> Ping. This is a very serious issue and it would be really good to include
> >> it in the minor releases. I've attached a patch for 9.5 with a test case
> >> and verified that it fixes the problem with our application.
>
> > Right. That's up to Robert or Andres to pick up that at this point. I
> > just added them in CC for awareness.
>
> Andres is on vacation, and if Robert is around it'd be better for him to
> be looking at the toast snapshot problem. I can pick this up, probably.
Thanks for that. I was too tired to address this before the vacation,
sorry for that.
Andres
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2016-08-15 01:02 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-08-04 19:17 BUG #14279: Logical decoding misses a transaction completely marko@joh.to
2016-08-04 19:40 ` Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-08-07 10:49 ` Marko Tiikkaja <marko@joh.to>
2016-08-07 11:11 ` Michael Paquier <michael.paquier@gmail.com>
2016-08-07 16:14 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-08-08 01:49 ` Michael Paquier <michael.paquier@gmail.com>
2016-08-15 01:02 ` Andres Freund <andres@anarazel.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox