juji-io / datalevin

A simple, fast and versatile Datalog database
https://github.com/juji-io/datalevin
Eclipse Public License 1.0
1.07k stars 60 forks source link

Options not recovered after automatic reconnection #241

Closed euccastro closed 4 months ago

euccastro commented 4 months ago

I've been noticing that when I create a connection using (d/get-conn "dtlv://datalevin:xxxx@host/db" schema {:validate-data? true :auto-entity-time? true}) and hold on to it for long, at some point the :auto-entity-time? flag stops working. That is, immediately after creating the connection, any newly created entities get a :db/created-at and a :db/updated-at, but at some point down the road any new entities still get created correctly but without those attributes.

I inquired about this in the Clojurians slack and @huahaiy replied:

It is possible that this is a bug, the options are not recovered after an automatic reconnection happens, please file an issue

huahaiy commented 4 months ago

Please let me know if 0.8.29 fixes this.

euccastro commented 4 months ago

Even after upgrading the server and client to 0.8.29, :auto-entity-time? was still failing to be honored in the particular datalog database where I first reproduced this, as in newly created entities didn't get :db/created-at nor :db/updated-at attributes.

It was honored, though, in newly created datalog databases in the same server.

Even in the original "broken" database, auto-entity-time? started working again after calling datalevin.core/re-index: entities created after that do get :db/created-at and :db/updated-at datoms. I waited a few minutes hoping to force a reconnect and things kept working OK.

So I think this is fixed. I'll reopen the issue if this ever happens again.

Thank you very much for fixing this so promptly!