pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
[pgjdbc/pgjdbc] issue #3107: JDBC driver sends "SAVEPOINT" query without finishing extended query protocol cycle
3+ messages / 2 participants
[nested] [flat]

* [pgjdbc/pgjdbc] issue #3107: JDBC driver sends "SAVEPOINT" query without finishing extended query protocol cycle
@ 2024-02-01 11:20  "tatsuo-ishii (@tatsuo-ishii)" <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: tatsuo-ishii (@tatsuo-ishii) @ 2024-02-01 11:20 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

**Describe the issue**
If autosave=always option is specified, JDBC driver sends "SAVEPOINT PGJDBC_AUTOSAVE" in simple query protocol without finishing extended query protocol cycle.
This is not recommended. A an extended query protocol cycle should be ended before sending a simple protocol query.
See the discussion in pgsql-hackers: 
https://www.postgresql.org/message-id/20240130.082257.800729082723903188.t-ishii%40sranhm.sra.co.jp

**Driver Version?** 

Not known.

**Java Version?**

Not known.

**OS Version?**

Not known.

**PostgreSQL Version?**

Not known.

**To Reproduce**
Steps to reproduce the behaviour:

Use connection string autosave=always&cleanupSavepoints=true

**Expected behaviour**

The JDBC driver should end the extended query protocol cycle before sending "SAVEPOINT PGJDBC_AUTOSAVE".
I am not familiar with the internal of JDBC driver but in general you could do this by either:

- sending a sync message before sending "SAVEPOINT PGJDBC_AUTOSAVE".

- sending "SAVEPOINT PGJDBC_AUTOSAVE" using an extended query protocol messages.

Probably the latter is safer?

**Logs**

Not available.

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

* Re: [pgjdbc/pgjdbc] issue #3107: JDBC driver sends "SAVEPOINT" query without finishing extended query protocol cycle
@ 2024-02-21 01:43  "tatsuo-ishii (@tatsuo-ishii)" <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

From: tatsuo-ishii (@tatsuo-ishii) @ 2024-02-21 01:43 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

The driver version is  42.5.1.

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

* Re: [pgjdbc/pgjdbc] issue #3107: JDBC driver sends "SAVEPOINT" query without finishing extended query protocol cycle
@ 2025-07-09 08:40  "vlsi (@vlsi)" <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

From: vlsi (@vlsi) @ 2025-07-09 08:40 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Here's the discussion thread on hackers:
* https://www.postgresql.org/message-id/20240130.082257.800729082723903188.t-ishii%40sranhm.sra.co.jp

Note that pgjdbc can't use extended protocol for `savepoint pgjdbc_autosave` since we can't allow "prepared statement doe snot exist" for autosave queries (it defeats the purpose of `autosave`): https://www.postgresql.org/message-id/CAB%3DJe-HqHHqryuebk8MZGLpginRATRXHbP5_XvGG1arKtCWe0g%40mail.g...

At the same time, currently, the error message is pgpool2-specific only. PostgreSQL does not throw such errors yet: https://www.postgresql.org/message-id/CAB%3DJe-HQ0Zwy1QWo2OpRcu3d41XW_o35ZV%3D12cS94%3D4DP6fw1A%40ma...

The fix could probably be sending extra sync message before sending a simple query, however:
1) The error is pgpool2-specific only
2) Probably we should inject `sync` messages if we send a simple query before sending an extended one: https://www.postgresql.org/message-id/20240228.210532.1955389974353647116.t-ishii%40sranhm.sra.co.jp
3) We probably need to account for transaction safety as it looks like extra `sync` might close the currently active transaction: https://www.postgresql.org/message-id/CAGECzQSEeZMR%2Bhc9%2BtM%2BiGeOxWEx53VB0WKLyx1EOjt_y%3DNAKg%40...

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


end of thread, other threads:[~2025-07-09 08:40 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-02-01 11:20 [pgjdbc/pgjdbc] issue #3107: JDBC driver sends "SAVEPOINT" query without finishing extended query protocol cycle "tatsuo-ishii (@tatsuo-ishii)" <[email protected]>
2024-02-21 01:43 ` "tatsuo-ishii (@tatsuo-ishii)" <[email protected]>
2025-07-09 08:40 ` "vlsi (@vlsi)" <[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