Fork me on GitHub
#xtdb
<
2023-10-26
>
Namit Shah07:10:54

Can anyone help me with the syntax to fetch the entity via http client library where the eid is namespaced? For example the following doesnโ€™t work: (xt/entity (xt/db node) (keyword "movie" "123")). Gives me the following error,

; Execution error (ExceptionInfo) at xtdb.remote-api-client/api-request-sync (remote_api_client.clj:88).
; HTTP status 500

refset08:10:27

Hey again, I don't obviously see what could be going wrong there :thinking_face: Does it return the entity okay when not using the http client lib? Are non-namespaced keyword eids working fine?

Namit Shah09:10:28

Yes the non-namespaced keyword eids work just fine.

Namit Shah09:10:45

It also throws an error via making the direct API call. Can you point out if I am doing anything wrong? The API Call:

curl --location '' \
--header 'Accept: application/edn'

refset10:10:07

you are possibly hitting some edge case from using a number for the name component of the keyword...which Clojure doesn't properly support, see https://ask.clojure.org/index.php/10225/problem-using-numbers-as-keywords

refset10:10:31

if so, I don't think XT can easily fix this without it being resolved in Clojure first

Namit Shah10:10:29

Right. Any workaround using eid-json or just eid. Or the only workaround right now is not to use number for the name component?

Namit Shah10:10:05

(xt/entity (xt/db node) (keyword "movie" "123")) This works when node is not the xtdb-http-client but a node with its own configuration.

refset13:10:29

I expect it's something getting lost in the transit encode/decode steps. Given the number is essentially stored as string anyway (keywords are handled near enough the same as strings in general), I suggest just prefixing it with an extra char would be simple enough as a workaround (xt/entity (xt/db node) (keyword "movie" (str "n" "123")))

Ajay Jakate22:10:20

hey all, had a quick question about testing with xtdb... I've gotten testing with clojure.test working pretty well in the repl but having a few issues on the command line... I've noticed that when I run clj -X:test and there is a test that uses an xtdb node, it always hangs after the tests complete (unless there is a failing test in which case it exits). I've thinned down my test suite to a single xtdb test with no assertions and the hanging is still showing up, here is what the file looks like:

(ns ajakate.seekwence.game-test
  (:require [clojure.test :refer :all]
            [xtdb.api :as xt]))

(deftest test-xtdb
  (testing "xtdb"
    (with-open [node (xt/start-node {})]
      (xt/submit-tx node
                    [[::xt/put
                      {:xt/id "7823"
                       :game/state :init}]]))))
I've tried all kinds of different ways of using the xtdb node, including with-open, (.close node) and test fixtures, but I can't seem to get rid of the hanging... just wondering if anyone has run into this or has any insight (Using kit if that makes any difference)

seancorfield22:10:30

If you leave it alone for a minute or so, do you get the command-line back? If so, it's due to agents running in the background (that a (shutdown-agents) call in -main would normally take care of).

Ajay Jakate22:10:18

doesn't seem to give it back... there is a lot of xtdb debug logging I see in the console and the repl, the ending output for the command line tests looks like:

2023-10-26 17:44:57,593 [main] DEBUG xtdb.system - Starting [:xtdb/node]
2023-10-26 17:44:57,593 [main] DEBUG xtdb.system - Starting [:xtdb.bus/bus-stop]
2023-10-26 17:44:57,598 [main] DEBUG xtdb.mem-kv - Using fsync on MemKv has no effect.
2023-10-26 17:44:57,598 [xtdb-standalone-submit-tx-1] DEBUG xtdb.memory - :pool-allocation-stats {:allocated 262144, :deallocated 0, :in-use 262144}
2023-10-26 17:44:57,600 [xtdb-tx-subscription-1] DEBUG xtdb.memory - :pool-allocation-stats {:allocated 393216, :deallocated 0, :in-use 393216}
2023-10-26 17:44:57,603 [main] INFO  xtdb.tx - Shut down tx-ingester

Ran 2 tests containing 1 assertions.
0 failures, 0 errors.

Ajay Jakate22:10:39

the last line makes me think at least a shutdown signal is being sent to the xtdb node, but not sure

seancorfield23:10:41

It may also be futures/agents in your own code or some other library you're using. "shutdown signal [is] being sent to the xtdb node" is not what I'm talking about here, just to be clear.

Ajay Jakate23:10:45

gotcha, makes sense. I'll poke around further and see if I can figure out what's going on. thanks for the help!

refset11:10:23

Hey @UR5D2FW06 we had a report about something similar at the beginning of the year https://github.com/xtdb/xtdb/issues/1882 Are you running 1.24.1?

Ajay Jakate15:10:28

ah interesting... I tried adding the shutdown-agents call to my :once fixture, and got that working on the CLI, but then that ended up crashing my repl ๐Ÿ™‚ FWIW, after playing around with a lot of solutions, changing my command line call from clj -X:test to clojure -A:test seemed to do the trick (command line doesn't exit and repl tests work using my code from above). Haven't had a chance yet to poke into why that may be but at least I can get back to doing stuff ๐Ÿคท . The alias for test defined in my deps.edn is just the default that comes with kit

clojure-spin 1
๐Ÿ‘ 1
Ajay Jakate15:10:45

oh and I'm on 1.23.0

๐Ÿ™ 1
Ajay Jakate16:10:34

looks like I can try bumping to 1.24.1 in that case

refset16:10:42

yeah looks like we fixed it a bit in 1.23.1, so worth trying the later version(s)

seancorfield17:10:54

@UR5D2FW06 what CLI version are you using? clj -version

seancorfield18:10:30

OK, that's after the change of behavior in the CLI around thread pools and waiting (1.10.3.933, July 2021) but yours is still a pretty old version (August 2022). So this may be addressed by updating XTDB as above.

๐Ÿ‘ 1
๐Ÿ™ 1