Fork me on GitHub
#xtdb
<
2019-09-11
>
jjttjj15:09:16

Just want to check, is this a correct implementation of a "blocking-submit" that just blocks until the db contains the submitted entities?

(defn blocking-submit [node tx]
  (let [result (crux/submit-tx node tx)]
    (crux/sync node (:crux.tx/tx-time result) (Duration/parse "pt1s"))
    result))
I'm hitting some weird hard to reproduce bug in my functions. Working on a minimal example now but wanted to see if this had any red flags

jjttjj15:09:17

Ok here is the problem I'm hitting

(defn put-and-return-id [node]
  (let [id (java.util.UUID/randomUUID)
        tx [:crux.tx/put {:crux.db/id id}]]
    (blocking-submit node [tx])
    id))

(crux/entity (crux/db db) (put-and-return-id db)) ;;returns nil

(let [id (put-and-return-id db)] ;;correctly returns entity
  (crux/entity (crux/db db) id))

jjttjj15:09:38

The strangest thing is this doesn't work either:

(crux/entity (crux/db db)
             (do (let [x (put-and-return-id db)]
                   (Thread/sleep 1000)
                   (prn x)
                   x))) ;;=> nil
But when I call entity on the printed ID it does work

jjttjj15:09:38

OH nevermind I get it now

jjttjj15:09:45

the (crux/db db) call is evaluated before the entity is put in the DB, so it's not in the database at that point.

👍 4
refset17:09:09

@jjttjj Ahh, yeah I think this whole area remains a gap in the docs / examples / tutorial - sorry. We should probably figure out and document some backoff & retry patterns too. Have you seen the sync function?

jjttjj17:09:51

Yes, my first message above uses sync to wrap submit-tx

jjttjj17:09:05

but this was kinda a different issue it turns out

refset17:09:11

Ohh yeah, my bad 🙂

jjttjj17:09:24

No worries 🙂 just glad I eventually realized this haha

denik18:09:17

in trying to switch from rocks-db to jdbc I'm getting this error

Execution error (FileNotFoundException) at  (io.clj:149).
Could not locate crux/kv/rocksdb__init.class, crux/kv/rocksdb.clj or crux/kv/rocksdb.cljc on classpath.

denik18:09:50

I've commented out the rocks-db dependency and even the call to (crux/start-standalone-node crux-options) and still get this error with a fresh repl

denik18:09:17

oh looks like kafka and jdbc are only for the tx-log? I assumed postgres could be used as a kv-store via hstore

denik18:09:09

that would be optimal! the way I was planning to use this is with a deployed postgres cluster I have for young side projects. if this works I could use one cluster with many relational tables and as targets for crux nodes

denik18:09:17

so, am I right that I couldn't get away with one DB (postgres) at the moment because an additional kv-store is required?

jonpither18:09:04

Hi @denik currently that's the case, it should be straight enough to have postgresql as a kv store

jonpither18:09:59

If the k/v store is over the wire to the node, then queries would be slower. This is because the query engine is chatty with the k/v store that is currently local.

denik18:09:21

@jonpither thanks for the quick response. Yes, it would be over the wire but in the same data-center. Will the k/v store be rebuilt from the tx-log? I don't mind using rocks-db as a kv-store, just want to avoid buying storage volumes for every deployment.

jonpither18:09:58

Yes the k v store is always rebuilt from the log.