Fork me on GitHub
#datomic
<
2021-06-02
>
Paulo Bardes23:06:49

Hello there fellow clojurenauts! I’ve been diving into the datomic world, trying to learn the basics but one thing has been bothering me a bit. When running something like this:

(defn -main [& args]
  (println "Doing stuff...")
  (d/create-database client {:db-name db-name})
  (d/connect client {:db-name db-name})
  (println "Sutff done."))
Everything runs fine, both messages get printed pretty much as soon as the clojure runtime finishes loading, but… After that process just hangs in there for about a minute before exiting. So far I’ve only tested it with a dev-local client. I’ve also noticed it won’t happen when running on a memory only system. So my guess would be that the JVM process is probably waiting on for some kind of timeout on a transactor thread or something like that. So finally, my questions are: Am I on the right track here? Is there a way to signal datomic that all threads should quit immediately? Do I risk losing data if the process is killed during this timeout?

Alex Miller (Clojure team)23:06:36

A 1 minute pause is a classic sign that there a future or agent has been used, and the Clojure runtime will have a background thread that takes 1 minute to timeout before the jvm will exit

Alex Miller (Clojure team)23:06:03

(shutdown-agents) will work to allow the jvm to exit

Alex Miller (Clojure team)23:06:47

There is no active work here, it’d just a background cached for reuse if needed - this is not special to Datomic

Paulo Bardes23:06:15

Ohh, that totally makes sense! Thanks for the quick reply :)

favila23:06:04

@bardes0022 datomic on prem has a shutdown function with an optional argument to shut down the agents