Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to do scheduled connection validation #187

Open
grantas33 opened this issue Jan 11, 2023 · 6 comments
Open

Provide a way to do scheduled connection validation #187

grantas33 opened this issue Jan 11, 2023 · 6 comments
Labels
status: blocked An issue that is blocked on an external project change type: enhancement A general enhancement

Comments

@grantas33
Copy link

Feature Request

Is your feature request related to a problem? Please describe

Idle connections can become invalid due to timeouts on the database or the network side or other causes. In such case, when performing a database call we potentially would have to retry the acquirement of the whole pool size of connections and re-warmup the pool if no valid connections exist. This adds a substantial amount of time to the database call, which could have been avoided if the connection validation was periodically run in the background.

Describe the solution you'd like

The implementation behind backgroundEvictionInterval configuration parameter could be extended. Instead of checking for each connection if it has exceeded its maxIdleTime, it would also check for each connection if it is valid. Also, after the checks, the connection pool should be re-warmuped, so that it contains at least minIdle connections.

This feature exists in popular JDBC pool libraries like HikariCP (keepaliveTime) and C3P0 (idleConnectionTestPeriod) and the lack of scheduled validation could be a problem when migrating to r2dbc-pool

@ifindya
Copy link

ifindya commented Mar 29, 2023

Yes, it seems to be a problem for me as well. I implemented it in my program, and I hope there
has a plan about supporting things like "keep-alive".

@mp911de
Copy link
Member

mp911de commented Mar 29, 2023

Background validation would require taking the connection from the pool, testing it, and putting it back to ensure that the pool doesn't use it concurrently and another process that allocates the connection. In any case, that kind of functionality would be required to be provided by Reactor Pool. Feel free to file a ticket at https://github.com/reactor/reactor-pool/issues

@mp911de mp911de added type: enhancement A general enhancement status: blocked An issue that is blocked on an external project change labels Mar 29, 2023
@grantas33
Copy link
Author

Issue was created at reactor/reactor-pool#169

@grantas33
Copy link
Author

Background validation would require taking the connection from the pool, testing it, and putting it back to ensure that the pool doesn't use it concurrently and another process that allocates the connection. In any case, that kind of functionality would be required to be provided by Reactor Pool. Feel free to file a ticket at https://github.com/reactor/reactor-pool/issues

@mp911de reactor/reactor-pool#169 (comment) is this functionality provided by reactor-pool sufficient?

@ifindya
Copy link

ifindya commented Apr 20, 2023

Connection is removed if invalid when getting from the pool. How did this happen? Any help would be appreciated.

@mp911de
Copy link
Member

mp911de commented Apr 20, 2023

@grantas33 the comment refers to warmup, not scheduled validations. For scheduled validation, we would need to have a scheduler and a task to allocate/de-allocate a connection from the pool. When we do this from the outside, then we have to follow the pool order and therefore, we cannot guarantee that we've verified every connection.

That being said, we require support for scheduled validation in Reactor Pool first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: blocked An issue that is blocked on an external project change type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants