Dmitrii Bondar · GitHub

Commits on Aug 21, 2026

  1. Remove synchronous prepare from pgbench

    Pgbench waits for the result of a prepare packet synchronously
    when the prepared protocol flag is provided. For this reason
    it is impossible to use it with some poolers (such as PgBouncer)
    in the session pooling mode.
    Replace the blocking PQprepare() call in the single-command path
    with an async PQsendPrepare(), and add a new CSTATE_WAIT_PREPARE_RESULT
    state to the connection state machine that drains the prepare result
    without stalling the thread's event loop. After the prepare succeeds,
    the prepared flag is set and the actual query is sent via
    PQsendQueryPrepared as before. The pipeline path
    (prepareCommandsInPipeline) is left synchronous because prepares must
    complete before PQenterPipelineMode to avoid acquiring a snapshot
    that would break BEGIN ISOLATION LEVEL SERIALIZABLE.
    Also fix a latent bug: prepareCommand used to set the prepared flag
    to true even when the prepare failed, so subsequent attempts ran
    PQsendQueryPrepared against a non-existent statement. The flag is
    now set only on success, and prepare failures are routed through the
    normal error path (CSTATE_ERROR for retryable errors, CSTATE_ABORTED
    otherwise). Update the sql-syntax-error TAP test accordingly: it no
    longer expects the downstream "prepared statement does not exist"
    error.

    Dmitrii Bondar Commitfest Bot

    authored and Commitfest Bot committed

    Aug 21, 2026
    Configuration menu

    Browse the repository at this point in the history

  2. Configuration menu

    Browse the repository at this point in the history

Read the original on github.com ↗