postgres.git / summary / log / commit / refs

commit    f4e44f184cef6a80b4d11bbaeaf2b13e59c1dd8e
Author:   Amit Kapila <akapila@postgresql.org>
Date:     Thu Aug 06 06:03:05 2026 +0000

    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 e9e0f753f7c..fbb2dffbd95 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/, $offset); [parent: 4edd59de5277]