Re: ERROR: subtransaction logged without previous top-level txn record
Arseny Sher <a.sher@postgrespro.ru>
From: Arseny Sher <a.sher@postgrespro.ru>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Andres Freund <andres@anarazel.de>, "Hsu\, John" <hsuchen@amazon.com>,
"pgsql-bugs\@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>
Date: 2020-02-09T16:07:50Z
Lists: pgsql-bugs, pgsql-hackers
Attachments
Amit Kapila <amit.kapila16@gmail.com> writes:
>> 1) Decoding from existing slot (*not* initial snapshot construction)
>> starts up, immediately picks up snapshot at restart_lsn (getting into
>> SNAPBUILD_CONSISTENT) and in some xl_xact_assignment learns that it
>> hadn't seen in full (no toplevel records) transaction which it is not
>> even going to stream -- but still dies with "subtransation logged
>> without...". That's my example above, and that's what people are
>> complaining about. Here, usage of serialized snapshot and jump to
>> SNAPBUILD_CONSISTENT is not just legit, it is essential: or order to be
>> able to stream data since confirmed_flush_lsn, we must pick it up as we
>> might not be able to assemble it from scratch in time. I mean, what is
>> wrong here is not serialized snapshot usage but the check.
>>
>
> I was thinking if we have some way to skip processing of
> xl_xact_assignment for such cases, then it might be better. Say,
> along with restart_lsn, if have some way to find corresponding nextXid
> (below which we don't need to process records).
I don't believe you can that without persisting additional
data. Basically, what we need is list of transactions who are running at
the point of snapshot serialization *and* already wrote something before
it -- those we hadn't seen in full and can't decode. We have no such
data currently. The closest thing we have is xl_running_xacts->nextXid,
but
1) issued xid doesn't necessarily means xact actually wrote something,
so we can't just skip xl_xact_assignment for xid < nextXid, it might
still be decoded
2) snapshot might be serialized not at xl_running_xacts anyway
Surely this thing doesn't deserve changing persisted data format.
Somehow I hadn't realized this earlier, so my comments/commit messages
in patches above were not accurate here; I've edited them. Also in the
first patch serialized snapshots are not no longer used for new slot
creation at all, as Andres suggested above. This is not principal, as I
said, but arguably makes things simpler a bit.
I've also found a couple of issues with slot copying feature, will post
in separate thread on them.
Commits
-
Stop demanding that top xact must be seen before subxact in decoding.
- 05555f7aaa08 9.5.22 landed
- 59c1a03f0736 9.6.18 landed
- b448aa44170b 10.13 landed
- bff456d7a0b3 11.8 landed
- 59112f235549 12.3 landed
- e3ff789acfb2 13.0 landed
-
logical decoding: process ASSIGNMENT during snapshot build
- bac2fae05c77 13.0 cited
- 96b5033e1171 12.0 cited
-
Fix operator naming in pg_trgm GUC option descriptions
- 959792087a10 9.6.14 cited