This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-15
Channels
- # babashka (4)
- # beginners (136)
- # calva (63)
- # clerk (7)
- # clj-kondo (8)
- # clojure (43)
- # clojure-boston (1)
- # clojure-europe (37)
- # clojure-nl (1)
- # clojure-norway (11)
- # clojure-uk (3)
- # clojurescript (6)
- # clr (1)
- # code-reviews (16)
- # cursive (45)
- # datomic (2)
- # docker (32)
- # emacs (10)
- # events (2)
- # exercism (1)
- # fulcro (3)
- # hugsql (1)
- # hyperfiddle (47)
- # leiningen (3)
- # lsp (30)
- # malli (39)
- # missionary (1)
- # off-topic (24)
- # pathom (2)
- # portal (14)
- # practicalli (5)
- # rdf (13)
- # reagent (18)
- # reitit (18)
- # releases (7)
- # remote-jobs (1)
- # sci (2)
- # shadow-cljs (45)
- # sql (7)
- # tools-build (11)
- # xtdb (13)
Playing around with XTDB using PostgreSQL as storage and am running into an error when attempting transactions. The error:
; Execution error (NullPointerException) at xtdb.cache/evict (cache.clj:14).
; Cannot invoke "xtdb.cache.ICache.evict(Object)" because "cache" is null
Any guidance on why this might be would be greatly appreciated. 😃
The entirety of the project consists of deps.edn
and a core.clj
file.
The contents of the deps.edn
file:
{:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.11.1"}
com.xtdb/xtdb-jdbc {:mvn/version "1.23.1"}
org.postgresql/postgresql {:mvn/version "42.5.1"}}}
The contents of the core.clj
file:
(ns api.db.core
(:require [xtdb.jdbc]
[xtdb.jdbc.psql]
[xtdb.api :as xt]))
;; Edited after assistance: note quoting of dialect, tx-log, and document-store.
(def config
{:xtdb.jdbc/connection-pool
{:dialect {:xtdb/module 'xtdb.jdbc.psql/->dialect}
:pool-opts {}
:db-spec {:host "127.0.0.1"
:port 5432
:dbname "..."
:user "..."
:password "..."}}
:xtdb/tx-log {:xtdb/module 'xtdb.jdbc/->tx-log
:connection-pool :xtdb.jdbc/connection-pool}
:xtdb/document-store {:xtdb/module 'xtdb.jdbc/->document-store
:connection-pool :xtdb.jdbc/connection-pool}})
(def xtdb-node (xt/start-node config))
(comment
(.close xtdb-node)
;; Example from docs
(xt/submit-tx xtdb-node
[[::xt/put
{:xt/id :dbpedia.resource/Pablo-Picasso :first-name :Pablo}]])
(xt/q (xt/db xtdb-node)
'{:find [?e]
:where [[?e :xt/id ?eid]]}))
The query below the transaction in the listing above returns #{}
, which I suspect is due to nothing having been transacted to the database.
Thanks for your time!Hey @U03CPPKDXBL I'll have a proper think tomorrow, but briefly just noticed you're missing xtdb-core in your deps. I'm not sure what the behaviour is without it. Might be a red herring
Thanks @U899JBRPF, I've added it to be safe:
;; deps.edn
{:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.11.1"}
com.xtdb/xtdb-core {:mvn/version "1.23.1"}
com.xtdb/xtdb-jdbc {:mvn/version "1.23.1"}
org.postgresql/postgresql {:mvn/version "42.5.1"}}}
Running clj -P
after didn't pull in any new dependencies AFAICT. Think it might've been pulled in with xtdb-jdbc
. Seeing the same error as before.
(Separately: is https://discuss.xtdb.com the preferred place to engage nowadays?)perhaps you have a race condition here, what happens if you add xt/await-tx after xt/submit-tx?
Like this:
(->> [[::xt/put
{:xt/id :dbpedia.resource/Pablo-Picasso :first-name :Pablo}]]
(xt/submit-tx xtdb-node)
(xt/await-tx xtdb-node))
Thanks for the suggestion, @U052A8RUT. Tested this approach now; ran into the same error as above.
Ah sorry, i read the issue too quickly. My suggestion is irrelevant for your issue, my bad.
@U03CPPKDXBL can you share the full stack trace please? Is it happening consistently? Try quoting 'xtdb.jdbc.psql/->dialect
naively it sounds like the CachedDocumentStore isn't initialised properly (likely along with much of the rest of node config), so it's failing on the start-node
step but not giving you proper feedback
; Execution error (NullPointerException) at xtdb.cache/evict (cache.clj:14).
; Cannot invoke "xtdb.cache.ICache.evict(Object)" because "cache" is null
xtdb.cache/evict (cache.clj:14)
xtdb.cache/evict (cache.clj:13)
xtdb.document-store.CachedDocumentStore/iter (document_store.clj:56)
clojure.lang.LazySeq/sval (LazySeq.java:42)
clojure.lang.LazySeq/seq (LazySeq.java:51)
clojure.lang.RT/seq (RT.java:535)
clojure.lang.LazilyPersistentVector/create (LazilyPersistentVector.java:44)
clojure.core/vec (core.clj:379)
clojure.core/vec (core.clj:369)
xtdb.document-store.CachedDocumentStore/submit_docs (document_store.clj:54)
xtdb.node.XtdbNode/submit_tx_async (node.clj:220)
xtdb.node.XtdbNode/submit_tx (node.clj:223)
api.db.core/eval25867 (NO_SOURCE_FILE:28)
clojure.lang.Compiler/eval (Compiler.java:7194)
clojure.core/eval (core.clj:3215)
clojure.core/eval (core.clj:3211)
nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:87)
clojure.core/apply (core.clj:667)
clojure.core/with-bindings* (core.clj:1990)
nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:87)
clojure.main/repl (main.clj:437)
clojure.main/repl (main.clj:458)
clojure.main/repl (main.clj:368)
nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:84)
nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:56)
nrepl.middleware.interruptible-eval/interruptible-eval (interruptible_eval.clj:152)
nrepl.middleware.session/session-exec (session.clj:218)
nrepl.middleware.session/session-exec (session.clj:217)
java.lang.Thread/run (Thread.java:833)
https://clojurians.slack.com/archives/CG3AM2F7V/p1678964829898239?thread_ts=1678919045.358149&cid=CG3AM2F7V Thanks @U899JBRPF. Should've thought about quoting; it works! For fellow travelers in future:
(def config
{:xtdb.jdbc/connection-pool
{:dialect {:xtdb/module 'xtdb.jdbc.psql/->dialect}
:pool-opts {}
:db-spec {:host "127.0.0.1"
:port 5432
:dbname "..."
:user "..."
:password "..."}}
:xtdb/tx-log {:xtdb/module 'xtdb.jdbc/->tx-log
:connection-pool :xtdb.jdbc/connection-pool}
:xtdb/document-store {:xtdb/module 'xtdb.jdbc/->document-store
:connection-pool :xtdb.jdbc/connection-pool}})
Great, thanks for confirming that. I just opened https://github.com/xtdb/xtdb/issues/1919 to improve the error handling - apologies for the confusion 🙂