leonoel/missionary

Odd interaction with xtdb

nivekuil opened this issue · 2 comments

(def test-node (xt/start-node {}))
(xt/submit-tx test-node [[::xt/put {:xt/id {:foo "1"}}]])

;; correctly returns the entity
(xt/entity (xt/db test-node) {:foo "1"})

;; returns nil?!
(y/? (y/sp (xt/entity (xt/db test-node) {:foo "1"})))
  

This only seems to happen when the :xt/id is a map, so it could be something odd on the XTDB side as well. Any ideas? repro: https://github.com/nivekuil/missionary-xtdb-repro java version is 17 (graalvm), clojure 1.11.1

The issue seems related to type hints. sp tags forms with inferred types, confusing xtdb somehow. Here is a xtdb-only minimal repro :

;; incorrectly returns nil
(xt/entity (xt/db test-node) ^clojure.lang.PersistentArrayMap {:foo "1"})

A possible workaround could be to move the eid outside of the sp block to prevent tagging :

;; correctly returns the entity
(def eid {:foo "1"})
(y/? (y/sp (xt/entity (xt/db test-node) eid)))

Ah, I think I know what problem it is.. xtdb's nippy usage takes into account metadata so that type hint actually changes the document key for that entity. Reported previously here xtdb/xtdb#1510. It's definitely a problem on xtdb's end, not sure there is anything to do for missionary.