datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
Paulo Bardes 2021-06-02T23:07:49.151400Z

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?

alexmiller 2021-06-02T23:10:36.153400Z

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

alexmiller 2021-06-02T23:11:03.154200Z

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

alexmiller 2021-06-02T23:12:47.155600Z

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

alexmiller 2021-06-02T23:13:45.155800Z

https://clojure.org/guides/faq#agent_shutdown

Paulo Bardes 2021-06-02T23:18:15.157500Z

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

favila 2021-06-02T23:21:04.158800Z

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

alexmiller 2021-06-02T23:33:24.159300Z

Oh, even better :)

alexmiller 2021-06-02T23:33:41.159600Z

It’s been a while :)