| From: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
|---|---|
| To: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
| Cc: | a(dot)kozhemyakin(at)postgrespro(dot)ru, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19556: Segmentation fault in test_decoding |
| Date: | 2026-07-22 06:07:25 |
| Message-ID: | CAA4eK1LVSRw83h_x5hWPkjurk2zKooAq89ch+uW4O4o+7vVGvQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Wed, Jul 22, 2026 at 8:22 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> While researching this bug, I found another one that is related and
> probably should be fixed first: even in PG17 and earlier, logical
> decoding calls the commit_prepared callback without first calling the
> prepare callback:
>
> BEGIN;
> SELECT * FROM test WHERE id = 1 FOR SHARE;
> PREPARE TRANSACTION 'p1';
> COMMIT PREPARED 'p1';
>
> In logical replication, the subscriber ends up with an error because
> the prepared transaction doesn't exist on it.
>
> In summary, with the above scenario, logical decoding calls:
>
> - the prepare and commit_prepared callbacks (PG18+)
> - the commit_prepared callback (PG17-)
>
> Neither is correct.
>
> I think we shouldn't call the commit_prepared callback for an empty
> transaction (one that has no base snapshot), so in this case we
> shouldn't call any of the begin_prepare, prepare, or commit_prepared
> callbacks. Thoughts?
>
I agree that when base_snapshot is not set, we shouldn't send these
transaction commands. I checked HEAD and it seems below change in
commit 072ee847ad lead to sending prepare:
- if (txn->concurrent_abort && !rbtxn_is_streamed(txn))
+ if (!rbtxn_sent_prepare(txn))
+ {
rb->prepare(rb, txn, txn->final_lsn);
+ txn->txn_flags |= RBTXN_SENT_PREPARE;
+ }
Why did we remove the check of the aborted xact?
I'll check PG17 and share my findings with you.
--
With Regards,
Amit Kapila.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | PG Bug reporting form | 2026-07-22 06:49:37 | BUG #19567: Redundant outer DISTINCT causes a second full aggregation above UNION |
| Previous Message | Masahiko Sawada | 2026-07-22 02:51:33 | Re: BUG #19556: Segmentation fault in test_decoding |