RE: [bug fix] prepared transaction might be lost when max_prepared_transactions is zero on the subscriber

From: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, shveta malik <shveta(dot)malik(at)gmail(dot)com>
Subject: RE: [bug fix] prepared transaction might be lost when max_prepared_transactions is zero on the subscriber
Date: 2026-08-05 05:25:04
Message-ID: TY4PR01MB177187B1A2B34DC0F1010EBDF94D32@TY4PR01MB17718.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
On Wednesday, August 5, 2026 1:00 PM Alexander Lakhin <exclusion(at)gmail(dot)com> wrote:
>
> Buildfarm animal olingo discovered a way to break this test, [1]:
> 400/402 subscription - postgresql:subscription/023_twophase_stream
> ERROR           230.82s   (exit status 255 or 0xff)
>
> pgsql.build/testrun/subscription/023_twophase_stream/log/023_twophase_s
> tream_subscriber.log
> ...
> That is, there is only one "ERROR:  logical replication parallel apply worker
> exited due to error" in the log, all the following errors are produced not by
> parallel worker, but by a leader worker...
>
> I'm able to reproduce this failure with:
> --- a/src/test/subscription/t/023_twophase_stream.pl
> +++ b/src/test/subscription/t/023_twophase_stream.pl
> @@ -445,2 +445,3 @@ $node_publisher->safe_psql(
>      INSERT INTO test_tab_2 values(2);
> +    SELECT pg_sleep(0.5);
>      PREPARE TRANSACTION 'xact';
>
> Could you have a look, please?

Thanks for reporting this. I confirmed that this is a race condition in the test
- the log offset is captured after the publisher's prepared transaction runs, so
the expected ERROR may have already been written before the offset was recorded.
This would cause the subsequent search to miss the message. To fix it, we can
simply get the offset before the prepared transaction runs.

The patch fixes the timeout on my machine (after adding the mentioned pg_sleep(0.5)).

Best Regards,
Zhijie Hou

Attachment Content-Type Size
v1-0001-Fix-BF-failure-for-023_twophase_stream.patch application/octet-stream 1.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Rafia Sabih 2026-08-05 05:49:14 Re: [PATCH] Add tests for src/backend/nodes/extensible.c
Previous Message Ayush Tiwari 2026-08-05 05:23:58 Backup manifests accept out-of-range LSNs