`Loading database` exception

We are getting this exception more and more often on d/db calls, even on a freshly provisioned Datomic Cloud system, using the latest CF templates and almost latest Clojure libs (the versions before the 2024 Feb 12 release):

clojure.lang.ExceptionInfo: Loading database #:cognitect.anomalies{:category :cognitect.anomalies/unavailable, :message "Loading database"}
	at datomic.core.anomalies$throw_if_anom.invokeStatic(anomalies.clj:94)
	at datomic.core.anomalies$throw_if_anom.invoke(anomalies.clj:88)
	at datomic.core.anomalies$throw_if_anom.invokeStatic(anomalies.clj:89)
	at datomic.core.anomalies$throw_if_anom.invoke(anomalies.clj:88)
	at datomic.cloud.client.local.Client$thunk__29831.invoke(local.clj:175)
	at datomic.cloud.client.local$create_db_proxy.invokeStatic(local.clj:282)
	at datomic.cloud.client.local$create_db_proxy.invoke(local.clj:280)
	at datomic.cloud.client.local.Connection.db(local.clj:103)
	at datomic.client.api$db.invokeStatic(api.clj:186)
	at datomic.client.api$db.invoke(api.clj:175)

In the past years, it only happened on instances smaller than i3.large, eg. t3.medium & t3.small, so the issue seemed to be related to the instance type, but it did happen on our previous i3.large system in the ap-southeast-1 region and keeps happening even more often on our fresh system in us-west-2.

What should I do about it?

Should I wrap my d/db calls with with-retry too, like we wrap our d/connect calls?

We are not creating new databases on our ion startup, but we indeed call d/create-database unconditionally, since it seemed idempotent, returns fast, if the DB already exists and it’s less code, than trying to do it conditionally.

Is it possible that we are triggering the scenario described in the docs (Troubleshooting | Datomic) about this error?

Would it help to provide a :timeout to the d/connect call, assuming it’s also considered by the d/db call?


We are not even calling d/create-database unconditionally anymore:

(defn ensure-db!
  "Returns Datomic DB reference (`{:db-name \"<database-name>\"}`) and ensures
   that the database is created."
  [datomic-client db-name]
  (let [db-ref {:db-name db-name}]
    (when-not (-> datomic-client (d/list-databases {}) set (contains? db-name))
      (d/create-database ($ :client) db-ref))

I too have been issuing the create-database unconditionally and so far have not correlated that to any run time issues. I wish it were documented as being idempotent and efficient to perform unconditionally.

1 Like