postgres.git / summary / log / commit / refs
commit 3df129b8d7217e50e7dfbc501c0e00e46320fabd
Author: Amit Kapila <akapila@postgresql.org>
Date: Thu Aug 06 05:50:26 2026 +0000
First released in: 16.15, 17.11, 18.6
Fix race condition in subscription TAP test 023_twophase_stream.
Buildfarm member olingo intermittently failed this test, timing out while
waiting for the subscriber log to report an ERROR because
max_prepared_transactions is zero there. The test captured the log offset
only after issuing the publisher's
BEGIN/INSERT/PREPARE TRANSACTION/COMMIT PREPARED sequence.
Since streaming is enabled, the subscriber can receive and apply the
transaction, and log the expected ERROR, before that publisher SQL command
even returns, i.e. before the test captures the offset. The subsequent
wait_for_log() calls then searched only from a point after the message had
already been written, and timed out waiting for it.
Fix by moving the offset capture to before the publisher's transaction is
issued, ensuring it always precedes the point where the ERROR can appear
in the subscriber log.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Backpatch-through: 16, where test was introduced
Discussion: https://postgr.es/m/c43753d8-5265-4f77-83ff-9b1167276ec5@gmail.com
src/test/subscription/t/023_twophase_stream.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/test/subscription/t/023_twophase_stream.pl b/src/test/subscription/t/023_twophase_stream.pl
index 5a5516ba787..884a364c9fd 100644
--- a/src/test/subscription/t/023_twophase_stream.pl
+++ b/src/test/subscription/t/023_twophase_stream.pl
@@ -439,6 +439,8 @@ debug_logical_replication_streaming = buffered
));
$node_subscriber->restart;
+$offset = -s $node_subscriber->logfile;
+
$node_publisher->safe_psql(
'postgres', q{
BEGIN;
@@ -447,8 +449,6 @@ $node_publisher->safe_psql(
COMMIT PREPARED 'xact';
});
-$offset = -s $node_subscriber->logfile;
-
# Confirm the ERROR is reported because max_prepared_transactions is zero
$node_subscriber->wait_for_log(
qr/ERROR: ( [A-Z0-9]+:)? prepared transactions are disabled/,
[parent: 8acfaa12a4c7]