Hello :wave: Question about how DB connections are...
# talk-kratos
g
Hello ๐Ÿ‘‹ Question about how DB connections are handled in Kratos From my understanding, when a DB connection is opened, it will be kept open as long as possible while the software is running. Is that correct? And if yes, what's the reasoning behind this? ๐Ÿ™‚ Avoid dangling connections? More info in ๐Ÿงต
We had a case recently, where our main DB failed, and we had a failover to the read-replica. Kratos queries started failing because the DB was unavailable, and after the failover occurred, Kratos re-connected to the read-replica. Obviously, write queries failed while connected to the read-replica. But once the main DB was recovered, our Kratos instances kept calling the read-replica, because it keeps DB connections open. Would it make sense to have a mechanism that regularly closes connections and re-open new ones? If yes, how could it we do it? ๐Ÿ™‚ Either only on our side, or also by contributing to the Kratos codebase
s
you can configure quite a lot in the DSN: https://www.ory.sh/docs/self-hosted/deployment#sql-persistent
namely
max_conn_lifetime
g
Damn it, I missed this one! Thanks a lot Patrik ๐Ÿ™‡