Help me understand "leakDetectionThreshold"?

2,601 views
Skip to first unread message

Stephen Rosenthal

unread,
Jun 8, 2018, 7:21:01 AM6/8/18
to HikariCP
Hi all,

I'm trying to understand why "leakDetectionThreshold" is ignored if it is greater than maxLifetime.

Background: I'm working on a data analysis application. Many times a connection is only used for 1 second or less, but it is not abnormal for a connection to be in use for a few minutes. I want to warn about connection leaks if the connection is open for abnormally long time. I set the threshold to 60 minutes, which is quite long, but would avoid false positive warnings.

So, my settings are:
    maxLifetime = 30min
    leakDetectionThreshold=60min.

But that configuration is not valid - it logs a warning saying the leakDetectionThreshold is too high and will be ignored. (Ref: https://github.com/brettwooldridge/HikariCP/blob/603951febd167ce086c2a65ace1668cf8488db5e/src/main/java/com/zaxxer/hikari/HikariConfig.java#L984)

I thought maxLifetime only comes into play when a connection _is not_ in use (idle connections will be closed), while leakDetectionThreshold only comes into play when a connection _is_ in use (connections in use for a long time will log warnings). So why is one value restricted by the other? Is it just a "sanity test" because they tend to be correlated, or am I doing something wrong?

For now, I'll try a leakDetectionThreshold of 30min, which should be nearly as good.

Thanks!
Stephen

Brett Wooldridge

unread,
Jun 9, 2018, 2:54:57 AM6/9/18
to HikariCP
Basically, that seems like a strange use of the leakDetectionThreshold.

The assumption is that the maxLifetime is longer than the longest running query time — even though a running query would not be interrupted upon reaching it. And the assumption is that the leakDetectionThreshold would be set somewhere between the longest running query time and the maxLifetime.

I don’t see a good rationale for the leakDetectionThreshold to be greater than the maxLifetime.

Brett
Reply all
Reply to author
Forward
0 new messages