Fork me on GitHub
#duct
<
2022-08-03
>
erwinrooijakkers08:08:06

Hi all, we noticed that our application does not restart when there’s an exception in HikariCP (it cannot connect) on startup

erwinrooijakkers08:08:24

We use startup code similar to

(defn -main [& args]
  (let [keys     (or (duct/parse-keys args) [:duct/daemon])
        profiles [:duct.profile/prod]
        config (-> (duct/resource "simple/config.edn")
                   (duct/read-config)
                   (duct/prep-config profiles))
        system (ig/init config keys)]
    (reset! stored-config config)
    (reset! stored-system system)
    (duct/await-daemons system)))
(I still work at that company ;))

😬 1
erwinrooijakkers09:08:29

HikariPool-1 - Exception during pool initialization

erwinrooijakkers09:08:42

We want to restart the application when that happens, how can that be accomplished?

ts150309:08:44

If hikary throws an exception then you probably can wrap the body of -main function in try/catch block and do a retry

erwinrooijakkers13:08:02

do you know why the exception does not crash the application?

ts150307:08:29

I see in your message HikariPool-1 it seems like exception was in thread 1. I’m not an expert but assume that hikary launching separate threads and not joining them to the main application thread. So if one thread dies others will still continue to work

ts150307:08:56

so this exception doesn’t happening during Duct initialization

erwinrooijakkers07:08:26

so maybe an exception on a separate thread that only crashes the thread

erwinrooijakkers07:08:42

but fact of the matter is there’s no database connection after the exception, it does not retry

erwinrooijakkers07:08:05

but not a duct issue then, but hikari

ts150308:08:09

there’s a bunch of parameters tho

ts150308:08:41

maybe you need to play with them and setup some timeouts or increase the pool size

erwinrooijakkers09:08:03

Now it stays in a “Healthy” state after it