Fork me on GitHub
#datomic
<
2020-12-04
>
jcf17:12:36

Hi all! I'm swapping out on-disk storage with dev-local for an in-memory database (I don't need durability for CI/tests) and I've followed the docs here by adding :storage-dir :mem to my client config… https://docs.datomic.com/cloud/dev-local.html#memdb That call is blowing up with this trace however:

1. Caused by java.lang.IllegalArgumentException
   No implementation of method: :as-file of protocol:
   #' found for class: clojure.lang.Keyword

          core_deftype.clj:  583  clojure.core/-cache-protocol-fn
                    io.clj:   35  
                    io.clj:  424  
                    io.clj:  418  
                  impl.clj:  331  datomic.dev-local.impl/require-storage-dir!
                  impl.clj:  328  datomic.dev-local.impl/require-storage-dir!
                  impl.clj:  340  datomic.dev-local.impl/create-client
                  impl.clj:  337  datomic.dev-local.impl/create-client
                  impl.clj:  373  datomic.dev-local.impl.DevLocal/fn
                 Atom.java:   37  clojure.lang.Atom/swap
                  core.clj: 2352  clojure.core/swap!
                  core.clj: 2345  clojure.core/swap!
                  impl.clj:  361  datomic.dev-local.impl.DevLocal/_impl_configure_system
                  impl.clj:  433  datomic.dev-local.impl/ensure-client
                  impl.clj:  423  datomic.dev-local.impl/ensure-client
                  Var.java:  384  clojure.lang.Var/invoke
                  impl.clj:   24  datomic.client.api.impl/dynarun
                  impl.clj:   21  datomic.client.api.impl/dynarun
                  impl.clj:   31  datomic.client.api.impl/dynacall
                  impl.clj:   28  datomic.client.api.impl/dynacall
                   api.clj:  100  datomic.client.api/client
                   api.clj:   48  datomic.client.api/client
That looks to me like I should have a :storage-dir that's resolvable to a file but the docs say this keyword :mem is supported. Given it's gone 5pm here and it's been a long week I'm guessing this is me missing something obvious but it's not jumping out at me… I'll try jacking in and see if I can jump to the source to see how this works. Clojure is so awesome! 😄

jcf17:12:19

My client config looks like this:

{:server-type :dev-local
 :storage-dir :mem
 :system      "ci"}

kenny17:12:56

Can you provide the code you're using to get this stacktrace?

jcf17:12:06

@U083D6HK9 it's the call to datomic.client.api/client in this component:

(defrecord Datomic [client-config conn db-name]
  component/Lifecycle
  (start [c]
    (let [client  (d/client client-config)
          _       (d/create-database client {:db-name db-name})
          conn    (d/connect client {:db-name db-name})
          tx-data (schema c)]
      (d/transact conn {:tx-data tx-data})
      (assoc c :client client :conn conn)))
  (stop [c]
    #_(some-> c :client (d/delete-database {:db-name db-name}))
    (dl/release-db client-config)
    (dissoc c :client :conn)))

jcf17:12:49

The next line in the trace would be the (let [client (d/client ... line above.

kenny17:12:23

Thanks. What version of dev-local are you running?

jcf17:12:51

I've tapped the client-config just to be safe, and can see this in REBL:

jcf17:12:00

Versions coming right up! 🙂

jcf17:12:22

com.datomic/dev-local {:mvn/version "0.9.203"}

kenny17:12:50

Can you try updating to the latest 0.9.229? Also ensure you're on the latest client version 0.8.102.

jcf17:12:58

Will do!

jcf17:12:38

Client is up to date. Bumping dev-local now and restart my JVM.

jcf17:12:06

Progress! Looks like updating the dev-local dep has gotten me the :mem support I need. Now I just need to pass in :system and :db-name to release-db. I wonder if I can merge the client config and the arg-map passed to release-db et al… :thinking_face:

jcf17:12:12

Probably not a good idea.

kenny17:12:12

I could be mistaken but I believe release-db has always needed a :db-name.

kenny17:12:38

If you'd like to release all dbs, you can call d/list-databases and loop over that.

jcf17:12:40

Makes sense. Thanks for the pointers, @U083D6HK9!

jcf17:12:10

I wonder if there's a footnote to add to spec-ulation about acretion not helping people like me with old code and newer docs. 😄