Re: TRAP: FailedAssertion("prev_first_lsn < cur_txn->first_lsn", File: "reorderbuffer.c", Line: 927, PID: 568639)
Tomas Vondra <tomas.vondra@enterprisedb.com>
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: "Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>,
Amit Kapila <amit.kapila16@gmail.com>
Cc: Alexander Lakhin <exclusion@gmail.com>,
Masahiko Sawada <sawada.mshk@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2023-06-14T15:27:10Z
Lists: pgsql-hackers
On 6/14/23 15:39, Zhijie Hou (Fujitsu) wrote:
> On Wednesday, June 14, 2023 5:05 PM Tomas Vondra <tomas.vondra@enterprisedb.com> wrote:
>> ...
>>
>> Also, can you try if we still stream the partial transaction with
>> create_logical_replication_slot building a full snapshot?
>
> Yes, It can fix this problem because force create_logical_replication_slot
> build a full snapshot can avoid restoring the snapshot. But I am not sure if
> this is the best fix for this for the same reason(it's costly) mentioned by
> Amit[1].
>
Costly compared to the current behavior? Sure, but considering the
current behavior is incorrect/broken, that seems rather irrelevant.
Incorrect behavior can be infinitely faster.
I doubt it's significantly costlier than just setting the "full
snapshot" flag when building the initial snapshot - sure, it will take
more time than now, but that's kinda the whole point. It seems to me the
problem is exactly that it *doesn't* wait long enough.
I may be misunderstanding the solution you proposed, but this:
One idea to fix the partial change stream problem would be that we
record all the running transaction's xid when restoring the snapshot
in SnapBuildFindSnapshot(), and in the following decoding, we skip
decoding changes for the recorded transaction
sounds pretty close to what building a correct snapshot actually does.
But maybe I'm wrong - ultimately, the way to compare those approaches
seems to be to prototype this proposal, and do some tests.
There's also the question of back branches, and it seems way simpler to
just flip a flag and disable broken optimization than doing fairly
complex stuff to save it.
I'd also point out that (a) this only affects the initial snapshot, not
every time we start the decoding context, and (b) the slots created from
walsender already do that with (unless when copy_data=false).
So if needs_full_snapshot=true fixes the issue, I'd just do that as the
first step - in master and backpatches. And then if we want to salvage
the optimization, we can try fixing it in master.
regards
--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Commits
-
Fix executing invalidation messages generated by subtransactions during decoding.
- 343afa967106 15.1 landed
- 4fbe6096b954 14.6 landed
- 38dbaaf27387 13.9 landed
- 02600886c8a8 12.13 landed
- 216af69aec0d 11.18 landed
-
Fix assertion failures while processing NEW_CID record in logical decoding.
- 64ff0fe4e8c4 15.1 landed
- a592ed923e67 14.6 landed
- 25f7be1ca236 13.9 landed
- 1bf4d92060ee 12.13 landed
- 5f7076cb609e 11.18 landed
- 10ed7b9e4b19 10.23 landed
- 16b1fe0037dc 16.0 landed
-
Immediately WAL-log subtransaction and top-level XID association.
- 0bead9af484c 14.0 cited
-
Stop demanding that top xact must be seen before subxact in decoding.
- e3ff789acfb2 13.0 cited