r2dbc / r2dbc-pool

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

maxCreateConnectionTime may cause connection leak #165

Closed patriknw closed 2 years ago

patriknw commented 2 years ago

Bug Report

Versions

Current Behavior

More connections than max and connections are not closed if maxCreateConnectionTime is defined.

Steps to reproduce

Set a small maxCreateConnectionTime that causes timeout. Look in database for open connections:

SELECT * FROM   pg_stat_activity;

Expected behavior/code

No connection leak.

Possible Solution

I think the underlying connection can still be established but not added to the pool, or closed. The maxCreateConnectionTime is only a timeout on the Mono.

I suggest to remove maxCreateConnectionTime and let users define the timeout with ConnectionFactoryOptions.CONNECT_TIMEOUT.

I don't know if maxAcquireTime can cause something similar.

mp911de commented 2 years ago

It is possible that the timeout operator cancels the connection creation but the connection was partially established. In that case, the timeout operator drops the connection but we never close it on our side. That's something we need to fix.

mp911de commented 2 years ago

That's fixed now.