r2dbc / r2dbc-pool

Connection Pooling for Reactive Relational Database Connectivity
https://r2dbc.io
Apache License 2.0
332 stars 55 forks source link

Default maxLifeTime value result in immediate eviction of all connections #129

Closed bezmax closed 2 years ago

bezmax commented 3 years ago

Bug Report

The default for maxLifeTime is defined as NO_TIMEOUT = Duration.ofNanos(-1), which is supposed to mean "No timeout". However, the current implementation of actual evectionPredicate, attempts to do toMillis conversion, which results in 0, thus resulting in the if (maxIdleTimeMills == 0 || maxLifeTimeMillis == 0) always returning true.

Possible Solution

Replace maxLifeTimeMillis == 0 with maxLifeTime.isZero().

mp911de commented 3 years ago

Care to submit a pull request to fix the problem?

bezmax commented 3 years ago

Sure, will do!

GabrielCalin commented 2 years ago

Just a friendly ping, could someone merge this PR? The fact is that this is a major bug at the moment, as the pool behaves poorly when maxLifeTime is not explicitly set.

Inego commented 2 years ago

Current workaround: set spring.r2dbc.pool.max-life-time to -1.