Thread

  1. [PATCH] Make sure discardUntilSync() discards until the last sync point

    Yugo Nagata <nagata@sraoss.co.jp> — 2025-11-11T01:14:30Z

    ---
     src/bin/pgbench/pgbench.c | 15 ++++++++++-----
     1 file changed, 10 insertions(+), 5 deletions(-)
    
    diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
    index d8764ba6fe0..c31dd30672b 100644
    --- a/src/bin/pgbench/pgbench.c
    +++ b/src/bin/pgbench/pgbench.c
    @@ -3563,14 +3563,14 @@ doRetry(CState *st, pg_time_usec_t *now)
     }
     
     /*
    - * Read results and discard it until a sync point.
    + * Read and discard results until the last sync point.
      */
     static int
     discardUntilSync(CState *st)
     {
     	bool		received_sync = false;
     
    -	/* send a sync */
    +	/* Send a sync since all PGRES_PIPELINE_SYNC may be already received. */
     	if (!PQpipelineSync(st->con))
     	{
     		pg_log_error("client %d aborted: failed to send a pipeline sync",
    @@ -3588,10 +3588,15 @@ discardUntilSync(CState *st)
     		else if (received_sync)
     		{
     			/*
    -			 * PGRES_PIPELINE_SYNC must be followed by another
    -			 * PGRES_PIPELINE_SYNC or NULL; otherwise, assert failure.
    +			 * If a PGRES_PIPELINE_SYNC is followed by something other than
    +			 * PGRES_PIPELINE_SYNC or NULL, another PGRES_PIPELINE_SYNC will
    +			 * eventually follow.
     			 */
    -			Assert(res == NULL);
    +			if (res)
    +			{
    +				received_sync = false;
    +				continue;
    +			}
     
     			/*
     			 * Reset ongoing sync count to 0 since all PGRES_PIPELINE_SYNC
    -- 
    2.43.0
    
    
    --Multipart=_Tue__11_Nov_2025_10_50_37_+0900_fFU4O7H.CCoN7ou=--