How to detect DNS change of DB?
Closed this issue · 2 comments
In out project we are using AWS RDS with multi AZ. If the master DB goes in backup another DB comes back up (because of multi AZ). This behaviour is more like creating a DB and putting behind CNAME.
However if I restart the application or the max-lifetime expires the connection pool is re-created, but till that time out application gives timeout.
I have asked for help over stack overflow, but didn't have a satisfactory answer https://stackoverflow.com/questions/48421107/hikaricp-doesnt-detect-db-dns-change.
What I have tried implementing:
- Create a scheduler that polls every 30 sec to check if the DNS has changed. If so, recreate the new connection pool. -> This is not a very reliable source as if the CPU reaches 100%, there is a chance that the thread might be killed (JVM will randomly kill threads to make it stable)
- Created a Haproxy layer and our application will that will poll the db connection from haproxy (HAProxy supports postgres connection)
-> This implementation works but if the Db changes we need to reload HAProxy to get it done (Restarting HAProxy is faster than restarting the application). But there is a manual step involved.
We are currently on hikari-cp-1.7 and upgrading to higher version will take some time. Any suggestions will be hugely appreciated.
Hi Vikash, thanks for taking time to file the issue. I'm not sure if we can help with this problem. hikari-cp is just a thin layer on top of HikariCP meant to adapt the original Java API to Clojure idioms. I'm afraid addressing networking and DNS-level problems is out of its scope. We can provide a solution only if HikariCP's API offers one.
Hi @vikashgupta2000. Please consider raising an issue at https://github.com/brettwooldridge/HikariCP