r2dbc / r2dbc-pool

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

Allow updating the password after the initialisation of Connection Pool #174

Closed vsantwana closed 2 years ago

vsantwana commented 2 years ago

Feature Request

Is your feature request related to a problem? Please describe

Currently I am working on migrating my Database from using static username and password to dynamic credentials, more specifically IAM DB authentication. The Auth Token that is used as a password expires every 15 minutes. We use R2DBC Connection Pool to get the connection pool and subsequently the connection. As I understand it so far, there is no way to update the password provided to the pool after the pool has been initialised. My current way of doing things is that I have a wrapper around my ConnectionPool object, which has a background thread that closes the current connection pool and initialises a new one every 13 minutes. There are two problems with the approach that I am doing:

  1. It does not allow me to leverage the full power of Connection Pools
  2. It can lead to errors when I am trying to close the connection pool and some connections are actively running during that time.

Since the password would be needed again, when the connection pool has to scale up or has to restart for a reason, one solution could be to trust that the connection is correct and update the connection pool only when the new connections start failing, but it increases the number of errors in my application.

Describe the solution you'd like

  1. Add another option to ConnectionFactoryOptions, with the name link scheduledUpdate which takes a callback to update other options taken by the factory.

Describe alternatives you've considered

[See Description]

Teachability, Documentation, Adoption, Migration Strategy

mp911de commented 2 years ago

Looks like a duplicate of https://github.com/pgjdbc/r2dbc-postgresql/issues/529. The pool works on top of a ConnectionFactory and a factory does not have public API to reconfigure it.

vsantwana commented 2 years ago

Thanks @mp911de for pointing it to me. Closing this issue.