pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
[pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
18+ messages / 5 participants
[nested] [flat]

* [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2023-01-31 12:43 "prokop7 (@prokop7)" <[email protected]>
  0 siblings, 0 replies; 18+ messages in thread

From: prokop7 (@prokop7) @ 2023-01-31 12:43 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

add transaction isolation mode to be able to work with transaction pooling tools like pgbouncer

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing](https://github.com/pgjdbc/pgjdbc/blob/master/CONTRIBUTING.md) document?
* [x] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change?

<!-- You can erase any parts of this template not applicable to your Pull Request. -->

### New Feature Submissions:

1. [x] Does your submission pass tests?
2. [x] Does `./gradlew autostyleCheck checkstyleAll` pass ?
3. [x] Have you added your new test classes to an existing test suite in alphabetical order?

### Transaction isolation mode
Adding this functionality discussed here https://github.com/pgjdbc/pgjdbc/issues/1880. Currently isolation level is set on connection level. This solution doesn't work with transaction pooling because the connection can be replaced after setting isolation.

Proposed solution adds transaction isolation mode, which can be on of `transaction` or `session`, by default it's session. 
If the mode set to `transaction` then all `BEGIN` statements appended with isolation level like `BEGIN ISOLATION LEVEL SERIALIZABLE`

The solution also works with READ ONLY modifier which was added in earlier versions.

Implementation requires 3 flags, one for mode (0 - session mode, 1 - transaction mode) and two for isolation level (00 - READ UNCOMMITTED, 01 - READ COMMITTED, 10 - REPEATABLE READ, 11 - SERIALIZABLE)

--- 

Solves https://github.com/pgjdbc/pgjdbc/issues/1880
Related to this PR, but it's already outdated and solved https://github.com/pgjdbc/pgjdbc/issues/848

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2023-01-31 13:26 ` "davecramer (@davecramer)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: davecramer (@davecramer) @ 2023-01-31 13:26 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Thanks for the PR. 
We will have to add tests to confirm behaviour

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2023-02-27 16:48 ` "prokop7 (@prokop7)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: prokop7 (@prokop7) @ 2023-02-27 16:48 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

@davecramer, I have managed to add test to confirm intended behaviour

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2023-03-28 09:38 ` "prokop7 (@prokop7)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: prokop7 (@prokop7) @ 2023-03-28 09:38 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Is there any chance of getting it into the main branch?

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2023-03-28 10:54 ` "davecramer (@davecramer)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: davecramer (@davecramer) @ 2023-03-28 10:54 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on pgjdbc/src/main/java/org/postgresql/PGProperty.java:810)

I'm unclear what 'setting readOnly to setting isolation level' is trying to convey ?

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2023-03-28 10:57 ` "davecramer (@davecramer)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: davecramer (@davecramer) @ 2023-03-28 10:57 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java)

using shift right is probably clearer as to what you are really doing.

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2023-03-28 12:17 ` "davecramer (@davecramer)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: davecramer (@davecramer) @ 2023-03-28 12:17 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java)

Does this change the current behaviour? Currently we throw an exception if the leveName is null. https://github.com/pgjdbc/pgjdbc/blob/3c3e5b62349c42d9d3dfe1fe0102776d4de8c353/pgjdbc/src/main/java/...

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2023-03-30 14:21 ` "prokop7 (@prokop7)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: prokop7 (@prokop7) @ 2023-03-30 14:21 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java)

This method wan't used at all, removed it

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2023-03-30 14:22 ` "prokop7 (@prokop7)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: prokop7 (@prokop7) @ 2023-03-30 14:22 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on pgjdbc/src/main/java/org/postgresql/PGProperty.java:810)

Wrong copy-paste, thanks for catching it

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2023-04-13 09:25 ` "prokop7 (@prokop7)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: prokop7 (@prokop7) @ 2023-04-13 09:25 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

May I kindly remind about this PR?

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2023-04-13 12:11 ` "davecramer (@davecramer)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: davecramer (@davecramer) @ 2023-04-13 12:11 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java)

probably worth adding & 3 in case this ever becomes a negative number

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2023-04-13 12:12 ` "davecramer (@davecramer)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: davecramer (@davecramer) @ 2023-04-13 12:12 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Need to fix checker framework errors .

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2023-10-02 12:10 ` "prokop7 (@prokop7)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: prokop7 (@prokop7) @ 2023-10-02 12:10 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

@davecramer can you please revisit this PR, I've fixed all issues?

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2024-09-25 16:07 ` "vdharam18 (@vdharam18)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: vdharam18 (@vdharam18) @ 2024-09-25 16:07 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Hey Folks, Thanks for raising the fix for this issue. I also observe a similar data inconsistency issue with PgBouncer and transaction pooling mode. It would be better if this fix could be prioritised and more people can use it.

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2024-09-25 16:08 ` "vdharam18 (@vdharam18)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: vdharam18 (@vdharam18) @ 2024-09-25 16:08 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

In the meantime, has anyone found any alternatives to solve this problem?

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2024-11-22 20:35 ` "hyragano (@hyragano)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: hyragano (@hyragano) @ 2024-11-22 20:35 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

> Hey Folks, Thanks for raising the fix for this issue. I also observe a similar data inconsistency issue with PgBouncer and transaction pooling mode. It would be better if this fix could be prioritised and more people can use it.

Actually we use it in production about 2 years from this branch however we cannot find some time to fix requested changes.

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2024-12-02 10:16 ` "prokop7 (@prokop7)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: prokop7 (@prokop7) @ 2024-12-02 10:16 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

@davecramer I've updated the branch. Now it's fully compatible with new tests
Could you please recheck this?

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode
@ 2025-08-05 13:16 ` "Waldemared (@Waldemared)" <[email protected]>
  16 siblings, 0 replies; 18+ messages in thread

From: Waldemared (@Waldemared) @ 2025-08-05 13:16 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

@davecramer Any news on when this feature might be available?

^ permalink  raw  reply  [nested|flat] 18+ messages in thread


end of thread, other threads:[~2025-08-05 13:16 UTC | newest]

Thread overview: 18+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-01-31 12:43 [pgjdbc/pgjdbc] PR #2741: feat: add transaction isolation mode "prokop7 (@prokop7)" <[email protected]>
2023-01-31 13:26 ` "davecramer (@davecramer)" <[email protected]>
2023-02-27 16:48 ` "prokop7 (@prokop7)" <[email protected]>
2023-03-28 09:38 ` "prokop7 (@prokop7)" <[email protected]>
2023-03-28 10:54 ` "davecramer (@davecramer)" <[email protected]>
2023-03-28 10:57 ` "davecramer (@davecramer)" <[email protected]>
2023-03-28 12:17 ` "davecramer (@davecramer)" <[email protected]>
2023-03-30 14:21 ` "prokop7 (@prokop7)" <[email protected]>
2023-03-30 14:22 ` "prokop7 (@prokop7)" <[email protected]>
2023-04-13 09:25 ` "prokop7 (@prokop7)" <[email protected]>
2023-04-13 12:11 ` "davecramer (@davecramer)" <[email protected]>
2023-04-13 12:12 ` "davecramer (@davecramer)" <[email protected]>
2023-10-02 12:10 ` "prokop7 (@prokop7)" <[email protected]>
2024-09-25 16:07 ` "vdharam18 (@vdharam18)" <[email protected]>
2024-09-25 16:08 ` "vdharam18 (@vdharam18)" <[email protected]>
2024-11-22 20:35 ` "hyragano (@hyragano)" <[email protected]>
2024-12-02 10:16 ` "prokop7 (@prokop7)" <[email protected]>
2025-08-05 13:16 ` "Waldemared (@Waldemared)" <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox