We started adding a :timeout
to our d/query
calls, and noticed that this made our app and test suite not shutdown properly anymore. I have pinpointed this to an thread pool-2-thread-1
that is keeping the VM alive, because it does not have the daemon flag set. If we don't use :timeout
, this thread is not being created.
It seems that the ThreadFactory used by datomic.datalog/cancel-service
does not set this daemon flag. Is this intentional?
As a workaround we now use this, which seems to work and doesn't block shutdown:
(.setThreadFactory datomic.datalog/cancel-service
(reify java.util.concurrent.ThreadFactory
(newThread [_this runnable]
(doto (Thread. runnable)
(.setName "cancel-service")
(.setDaemon true))
I think the current behavior is a bug/oversight, and it would be great if these threads were made daemons by default in the future (just like every other thread Datomic seems to create).