pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: vlsi (@vlsi) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: Re: [pgjdbc/pgjdbc] PR #3778: fix: avoid IllegalStateException: Timer already cancelled  when StatementCancelTimerTask.run throws a runtime error
Date: Fri, 22 Aug 2025 16:27:37 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

I'm leaning towards adding a test with mock that triggers an exception from `.cancel()`
Will try adding it shortly.

----

>Is there any explanation though why it works on v42.7.4 but not on others?

https://github.com/pgjdbc/pgjdbc/commit/bac3d0add5626006ce41db53618da2190bf00910 landed at 42.7.6, and it changed `int` to `byte[]`. Previously, an unset `cancelKey` was just `0`, so it did not cause any harm. After PR #3592 the `null` `byte[]` could cause NPE.
Interestingly, `castNonNull` caused NPE, so writing code in a way that does not require `castNotNull` seems the right way to go.

At the same time, backend should always supply `cancel key` in the startup messages, so I don't understand how is it possible that you have `null` `cancelKey`. I wonder if you could capture logging for `org.postgresql.core.QueryExecutorBase` in order to check if it does indeed end up with null cancel keys.
Do you use a load balancer?

It does not explain the reason 42.7.5 fails though. Just to double-check: does 42.7.5 fail for you as well?

view thread (6+ 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] PR #3778: fix: avoid IllegalStateException: Timer already cancelled  when StatementCancelTimerTask.run throws a runtime error
  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