Ertuğrul Çetin
Ertuğrul Çetin

Reputation: 5231

:db.error/connection-released the connection has been released in Datomic

I'm running my Transactor(EC2) and Datomic(DynamoDB) on AWS and after a while, I started getting the following error which I did not understand anything:

:db.error/connection-released The connection has been released.
....

Also, I was running my app for a month before but did not get this error at the time.

Any ideas?, if this happens regularly should I re-establish database connection in app code?

Upvotes: 3

Views: 545

Answers (2)

Ertuğrul Çetin
Ertuğrul Çetin

Reputation: 5231

It turned out that when transactor instance reboots I get that error so I found a work around for this problem here is the code:

(defn establish-conn
  []
  (try
      (d/create-database (conf/get :db-uri))
      (reset! conn (d/connect (conf/get :db-uri)))
    (catch Throwable t
      (println "Could not establish db conn." t))))

(defn fix-if-conn-ex
  ;;getting exception's error message
  [err-msg]
  (when (str/includes? err-msg ":db.error/connection-released")
    (db/establish-conn)))

Upvotes: 3

Timothy Baldridge
Timothy Baldridge

Reputation: 10683

Are you ever calling release on the DB? That's one thing I think could cause this, once you call release you can't use any Datomic connections again for the life of the app. Connections are really lightweight, so there's very rarely a reason to call this function.

Upvotes: 2

Related Questions