Spring boot version: 2.5.5 r2dbc-pool version: 0.9.0.M2

Autoconfiguration creates the pool successfully, but the connections are released immediately after returning to the pool because: io.r2dbc.pool.ConnectionPool

BiPredicate<Connection, PooledRefMetadata> evictionPredicate = (connection, metadata) -> {
            long maxIdleTimeMills = maxIdleTime.toMillis();
            long maxLifeTimeMillis = maxLifeTime.toMillis();

            if (maxIdleTimeMills == 0 || maxLifeTimeMillis == 0) {
                return true;
            }

            boolean isIdleTimeExceeded = maxIdleTimeMills > 0 && metadata.idleTime() >= maxIdleTimeMills;
            boolean isLifeTimeExceeded = maxLifeTimeMillis > 0 && metadata.lifeTime() >= maxLifeTimeMillis;
            return isIdleTimeExceeded || isLifeTimeExceeded;
        };

returns true because maxLifeTimeMillis == 0 and connection gets evicted immediately. to fix this I added spring.r2dbc.pool.max-life-time=365d because default value is 'PT-0.000000001S' and automatically converted to 0 during toMillis()

This issue is hard to detect and harder still to find a cause for it and fix. How about changing the default value for maxLifeTime and issue a clear warning if this value is set too small?

Comment From: wilkinsona

Thanks for the report. Spring Boot does not yet support R2DBC Pool 0.9.0 which introduced this change in behaviour. We can't change the default value for maxLifeTime or consider 0 to be too small as we would then no longer align with R2DBC Pool 0.8.x.

We'll align our defaults when we upgrade to R2DBC Pool 0.9 which I suspect will be in Spring Boot 2.7.x.