Skip to content

Can't use pgx5's QueryExecModeSimpleProtocol to avoid prepared statements when using connection pooling #1153

@casparwylie

Description

@casparwylie

Hi there,

We use PgBouncer as our connection pooler in transaction mode, which means we cannot use prepared statements. In our application, we disable prepared statements by using QueryExecModeSimpleProtocol. I believe this is a common setup given the limitation of transaction mode.

The problem is running the River client produces:

level=ERROR
msg="producer: Error fetching initial queue settings"
err="ERROR: invalid input syntax for type json (SQLSTATE 22P02)"

Which I believe is likely related to river_queue.metadata database column which is JSONB. According to pgx's comment on QueryExecModeSimpleProtocol:

 This is especially significant for []byte values. []byte values are encoded as PostgreSQL bytea. string must be used
instead for text type values including json and jsonb.

This means I'm pretty sure the following line is the issue:

Metadata: []byte("{}"),

I appreciate this isn't a direct problem with River, though I think River's pgx driver would ideally know which exec mode is being used and use the according types?

Any advice would be much appreciated! Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions