datalevin icon indicating copy to clipboard operation
datalevin copied to clipboard

Storing an error becomes unretractable

Open rschmukler opened this issue 5 months ago • 1 comments
trafficstars

It seems that storing an error as a value in datalevin is unretractable, and therefor the entity also becomes unretractable. Here is an example that can be run on a fresh database.

  (let [conn (d/create-conn "db.dl")]
    (d/transact!
      conn
      [{:entity-with-error (ex-info "Boom" {})}])
    (d/entity (d/db conn) 1) ;; Looks good
    (d/transact!
      conn
      [[:db/retractEntity 1]])
    (d/entity (d/db conn) 1) ;; Still exists
    (d/touch (d/entity (d/db conn) 1))) ;; Can still return data

On further investigation, I found the following behaviors:

  1. You can still add attributes to the affected entity via :db/add
  2. You cannot retract the error attribute via :db/retract or :db/retractAttribute
  3. You cannot retract the entity via :db/retractEntity (probably because of 2)
  4. You can retract still retract other attributes on the entity via :db/retract

rschmukler avatar Jun 09 '25 14:06 rschmukler

Seems to be related to https://github.com/juji-io/datalevin/issues/234

In doing so, we will disallow storing arbitrary objects that are not registered.

huahaiy avatar Jun 20 '25 17:06 huahaiy