pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: jamesagnew (@jamesagnew) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #3530: JDBC Shared Timer set to cancelled
Date: Wed, 19 Feb 2025 20:02:09 +0000
Message-ID: <[email protected]> (raw)
**Describe the issue**
I have a Java-based server using Postgresql as a persistence layer that occasionally gets into a state where it is completely unable to perform any new JDBC calls, requiring a JVM restart to bring it back. Once the driver is in this state, any attempt to execute any SQL statement is aborted immediately with the message: java.lang.IllegalStateException: Timer already cancelled
I have observed that this always starts when the server experiences an OutOfMemoryException while processing a resultset. Obviously that shouldn't happen and that's a separate issue, but I don't think an OOM should result in the driver becoming unusable either.
Shortly after an OOM, I typically see an exception with the following stack trace in my logs (presumably the JVM is unstable at this point while the GC tries to recover):
```
Caused by: org.postgresql.util.PSQLException: SSL error: Broken pipe
at org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:53)
at org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:638)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:201)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:268)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:54)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:273)
at org.postgresql.Driver.makeConnection(Driver.java:446)
at org.postgresql.Driver.connect(Driver.java:298)
at org.apache.commons.dbcp2.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:52)
at org.apache.commons.dbcp2.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:414)
```
The exception above appears once, and then from that moment onward, all JDBC calls fail with the following stack trace:
```
Caused by: java.lang.IllegalStateException: Timer already cancelled.
at java.base/java.util.Timer.sched(Timer.java:409)
at java.base/java.util.Timer.schedule(Timer.java:205)
at org.postgresql.jdbc.PgConnection.addTimerTask(PgConnection.java:1351)
at org.postgresql.jdbc.PgStatement.startTimer(PgStatement.java:995)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:516)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:434)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:194)
at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:137)
at org.apache.commons.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.
java:123)
at org.apache.commons.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.
java:123)
```
**Driver Version?**
This is occurring on 42.7.4 but this behaviour has been observed on a number of older versions as well over the last 6 months.
**Java Version?**
openjdk version "17.0.7" 2023-04-18 LTS
OpenJDK Runtime Environment Corretto-17.0.7.7.1 (build 17.0.7+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.7.7.1 (build 17.0.7+7-LTS, mixed mode, sharing)
**OS Version?**
Ubuntu 24.04.2 LTS
**PostgreSQL Version?**
PostgreSQL 16.6 (Ubuntu 16.6-0ubuntu0.24.04.1) on x86_64-pc-linux-gnu
view thread (17+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: github://pgjdbc/pgjdbc
Cc: [email protected], [email protected]
Subject: Re: [pgjdbc/pgjdbc] issue #3530: JDBC Shared Timer set to cancelled
In-Reply-To: <<[email protected]>>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox