Fork me on GitHub
#missionary
<
2024-05-06
>
Absolute Negativity03:05:42

I got java.lang.InterruptedException when running this form with Datomic.

(m/?
  (m/sp
    (m/? (m/race
           (m/via m/blk
             @(dm/transact-async db-conn [{:db/ident :user/name}]))))
    (m/? (m/sp (println (dm/db db-conn))))))
Taking m/race out works however:
(m/?
  (m/sp
    (m/? (m/via m/blk
             @(dm/transact-async db-conn [{:db/ident :user/name}])))
    (m/? (m/sp (println (dm/db db-conn))))))
Does anyone know what's wrong? Here is the stack trace:
1. Unhandled java.lang.InterruptedException
   (No message)

AbstractQueuedSynchronizer.java: 1100  java.util.concurrent.locks.AbstractQueuedSynchronizer/acquireSharedInterruptibly
       CountDownLatch.java:  230  java.util.concurrent.CountDownLatch/await
                  core.clj: 7199  clojure.core/promise/reify
                  core.clj: 2337  clojure.core/deref
                  core.clj: 2323  clojure.core/deref
                  peer.clj:   59  datomic.peer/get-cstate
                  peer.clj:   56  datomic.peer/get-cstate
                  peer.clj:  283  datomic.peer.Connection/db
                   api.clj:   73  datomic.api/db
                   api.clj:   71  datomic.api/db
                      REPL:  301  <my-domain>/eval2530684/cr2530685-block-1/cr2530685-place-8
                 impl.cljc:   60  cloroutine.impl$coroutine$fn__12664/invoke
           Sequential.java:   88  missionary.impl.Sequential/step
           Sequential.java:  125  missionary.impl.Sequential/run
                 core.cljc:  187  missionary.core$sp_run/invokeStatic
                 core.cljc:  186  missionary.core$sp_run/invoke
                 impl.cljc:   65  cloroutine.impl$coroutine$fn__12664/invoke
                  core.clj: 2642  clojure.core/partial/fn
           Sequential.java:   74  missionary.impl.Sequential/suspend
           Sequential.java:   40  missionary.impl.Sequential$Process/park
                Fiber.java:   85  missionary.impl.Fiber/park
                 core.cljc:  174  missionary.core$park/invokeStatic
                 core.cljc:  173  missionary.core$park/invoke
                      REPL:  297  <my-domain>/eval2530684/cr2530685-block-1
                 impl.cljc:   60  cloroutine.impl$coroutine$fn__12664/invoke
           Sequential.java:   88  missionary.impl.Sequential/step
           Sequential.java:  112  missionary.impl.Sequential$1/invoke
             RaceJoin.java:   51  missionary.impl.RaceJoin/terminated
             RaceJoin.java:   71  missionary.impl.RaceJoin$1/invoke
             RaceJoin.java:   86  missionary.impl.RaceJoin$2/invoke
                Thunk.java:   59  missionary.impl.Thunk$Process/run

leonoel08:05:30

Try latest version, there is a recent fix related to m/via cancellation and thread interruption state. You could also consider calling (dm/db db-conn) in a m/via as it's a blocking call

❤️ 1
Absolute Negativity09:05:17

Ok that's a fix. Thank you! dm/db from the doc says it doesn't block? "Retrieves a value of the database for reading. Does not communicate with the transactor, nor block."

Absolute Negativity09:05:32

Well I guess judging from my stack trace, it derefs promise hence it blocks...

leonoel11:05:00

yes it looks like accidentally blocking, I guess a synchronous call is acceptable here