Set HikariCP connectionTimeout to 30s to prevent thread starvation#310
Set HikariCP connectionTimeout to 30s to prevent thread starvation#310NicoPiel wants to merge 1 commit into
Conversation
Previously connectionTimeout was set to 0, which HikariCP interprets as wait indefinitely for a pool connection. Under any connection pressure this causes caller threads to block forever, silently starving the application with no way to detect or recover from the condition. Change the value to 30000 ms (30 seconds), which matches the HikariCP default. Callers will now receive a SQLException after 30 s instead of hanging, surfacing pool starvation quickly and allowing the application to fail fast and recover. Signed-off-by: Nico Piel <nico.piel@hotmail.de>
|
Can you clarify the problem case? What is calling this on a threadpool? I don't understand how this would block forward progress. With a queuing system, forward progress is usually the primary test. Presumably there is some excess of work entering the threadpool - which I presume is the problem. If this is a "just in case" for infinite waits, I don't have a problem with a pathologically long timeout (e.g. 30 minutes). |
|
There's no scenario where thread A holds a connection waiting for thread B who holds a connection waiting for thread A. Each Risks with
The other pool ( |
|
That sounds like you agree this is not a deadlock and not threadpool exhaustion. I still do not understand the repro. What is this meant to address? For example, I'm guessing: Repro:
Expected behavior:
Actual behavior:
|
|
Your repro is exactly right.
|
|
Can you document the configuration required to exhibit the issue? I assume it does not happen in the default derby config. Unless this is an unusual configuration, this seems like something that needs to be configurable. 30s is not that long - database servers can exceed that during HA failover or high load. Especially given the legacy behavior, I would suggest 60s or more. The primary consumer of the pool (I presume) is message processing, where it is beneficial to insulate from intermittent failures. The admin API would benefit from a shorter timeout, but a longer timeout is just annoying. Losing messages is critical. |
|
Defaulted to the current value of 0 and configurable. Changing it may break working configurations. |
Previously connectionTimeout was set to 0, which HikariCP interprets as
wait indefinitely for a pool connection. Under any connection pressure
this causes caller threads to block forever, silently starving the
application with no way to detect or recover from the condition.
Change the value to 30000 ms (30 seconds), which matches the HikariCP
default. Callers will now receive a SQLException after 30 s instead of
hanging, surfacing pool starvation quickly and allowing the application
to fail fast and recover.