Skip to content

Pgpool closes the frontend after multiple ParameterStatus messages in an extended pipeline #176

Description

@apkipa

Pgpool-II version

4.8devel (1a873669), backend_clustering_mode = raw, connection_cache = on, one configured PostgreSQL node.

Description

A query that changes two reportable session parameters, followed by another extended-protocol query in the same pipeline segment, succeeds on direct PostgreSQL but closes the Pgpool frontend.

Before waiting for the next client query, PostgreSQL reports each changed GUC_REPORT variable as a backend ParameterStatus message (guc.c, application_name, DateStyle). When handling the next Parse while the backend is idle, Pgpool sends an internal Sync, consumes at most one ParameterStatus, and then requires ReadyForQuery (pool_proto_modules.c). The second message triggers invalid read kind "S" and closes the frontend.

Reproduce

Start PostgreSQL 16 and Pgpool-II in the configuration above, install psycopg, and run:

import psycopg


def run(label, dsn):
    conn = psycopg.connect(dsn, autocommit=True)
    try:
        with conn.pipeline():
            conn.execute(
                "SELECT set_config(%s, %s, false), "
                "set_config(%s, %s, false)",
                ("application_name", "business", "DateStyle", "ISO, DMY"),
            )
            result = conn.execute("SELECT 99")
        print(f"{label}: {result.fetchone()[0]}")
    except Exception as exc:
        print(f"{label}: {type(exc).__name__}: {str(exc).splitlines()[0]}; closed={conn.closed}")
    finally:
        conn.close()


run("direct", DIRECT_DSN)
run("pgpool", PGPOOL_DSN)

Expected behavior

Both endpoints should complete the pipeline, remain usable, and print:

direct: 99
pgpool: 99

Actual behavior

The reproducer prints:

direct: 99
pgpool: OperationalError: consuming input failed: server closed the connection unexpectedly; closed=True

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions