How do you handle app start failure because DB not yet available?

I use Hikari for db pooling against my Postgres DB, and am using Mount to orchestrate the startup and pool requisition. One problem that strikes us occasionally is that a connection to the remote DB cannot be made, usually due to losing the race when various servers are upgraded and restarted once a month. Sometimes our Clojure app tries to start before the DB has finished rebooting. Failing to start the DB component, the entire app fails to start. As I’m sure many others are using pooling out there, what do you do to guard against this situation? How do you prevent total app failure when the DB cannot be requisitioned for a few minutes?

Hum, without thinking too much about it, circuit-breaker comes to my mind: Circuit breaker design pattern - Wikipedia

1 Like

During your database initialization sequence, is there any way for you to recur (maybe with exponential backoff to avoid spamming) until you successfully land a connection to the DB?

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.