question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setReadOnly does not work with pgbouncer and transaction pooling mode

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:22 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
azrainocommented, May 12, 2020

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.

0reactions
azrainocommented, May 20, 2020

@davecramer please find the PR for documentation fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Readonly connections occasionally being used as writeable ...
1, and since 1.7, PgBouncer only runs its server_reset_query for connection pools using the "session"-level pooling mode, not "transaction"- ...
Read more >
setReadOnly not working on PostgreSQL Connection
Problem seems related to a bug of the driver. These two workaround both worked for me: proposed by kayaman: executing first the sql...
Read more >
PgBouncer config
Connections in transaction-pooling mode should not have any need for a reset query. This setting is for working around broken setups that run...
Read more >
PgBouncer and 20,000 TPS on one node | Manualzz
advanced tuning, hacks and problem solving ... What doesn't work in PgBouncer ... setReadOnly does not work with pgbouncer and transaction pooling mode....
Read more >
The connection class — Psycopg 2.9.5 documentation
The connection can be also set in “autocommit” mode: no transaction is ... To avoid this problem you can ensure to terminate the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found