pgjdbc: setReadOnly does not work with pgbouncer and transaction pooling mode

https://github.com/pgjdbc/pgjdbc/blob/REL42.1.1/pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java#L698

Currently setReadOnly change mode for all session, not for transaction. It breaks work through pgbouncer in transaction pooling mode.

Can this be changed? For example like in psycopg2 python driver, see: https://github.com/psycopg/psycopg2/blob/2_7_1/psycopg/pqpath.c#L504

psycopg2 can set read only as part of BEGIN clause, like: BEGIN READ ONLY; this work perfectly over pgbouncer in transaction pooling mode too.

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 22 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Hi Dave, Thank you very much for answer. I guess this issue is now fixed from 42.2.10 right ?

How can I ignore the read-only transaction with the new feature implemented? I see the PGProperty class but don’t know how to set them on my spring boot application.

Thank you again.