atlassian-labs / db-replica

Automatically chooses between database connections to read-write main or read-only replica
Apache License 2.0
10 stars 11 forks source link

Add Support for custom connection provider for replica discovery #180

Closed wyrzyk closed 1 year ago

wyrzyk commented 1 year ago

…AuroraMultiReplicaConsistency`

wyrzyk commented 1 year ago

We are discovering replicas during isConsistent check. Previously we used a replica connection as a consistency check method parameter. Later, the same connection was reused for the consistency check and hopefully for the user query. This connection was part of the DB replica connection lifecycle and the connection was eventually closed when no longer needed. Yesterday I introduced changes where we inject the connection provider outside of the lifecycle, but I forgot that it now needs to be closed manually. The fix ensures that the connection is closed, while leaving the old path (detecting replicas with a replica connection) unchanged.