Fork me on GitHub
#xtdb
<
2020-07-13
>
Vincent Cantin07:07:15

Hello, today I am trying the web UI and ran into a JS crash.

Vincent Cantin07:07:36

On the webapp served at localhost:3000. My query:

{:find [e]
 :where [[e :crux.db/id _]]}
It displays a table of entity's ids (in my case, they are all maps containing 2 entries). When I click on the id of one of the listed entities, the browser is sent to a page which crashes JS.

Vincent Cantin07:07:20

The page becomes white with a footer, there are React errors in the console.

Vincent Cantin07:07:34

The same bug happens when in the UI I manually search for an entity from its crux.db/id . In my case, it is in the form:

{:product-life/id 1234567, :product-life/product-type :foobar}

Vincent Cantin07:07:24

I am not 100% sure that I am running the right UI, in this video the port used was 8080, and the UI style looked better. https://www.youtube.com/watch?v=ykbYNBE-V3k&amp;feature=youtu.be&amp;t=1655

Lu07:07:53

The console is still WIP. Do you mind sharing the react error so it’s very straight forward for us to fix the issue? Thanks :)

Vincent Cantin07:07:03

not sure how to share it efficiently, but here is a screenshot

Vincent Cantin07:07:09

I am using

juxt/crux-core {:mvn/version "20.07-1.9.2-beta"}
juxt/crux-rocksdb {:mvn/version "20.07-1.9.2-beta"}
juxt/crux-http-server {:mvn/version "20.07-1.9.2-alpha"}

Lu07:07:06

Thanks will reproduce locally and keep you updated

👍 3
refset08:07:32

@U8MJBRSR5 hey, the UI seen in the Strange Loop video is a previous re-frame implementation that did everything fully client-side (it used an unsupported cljs client lib + CORS). The feedback on the styling is appreciated, we've been more focussed on the functionality whilst we get ready for an official release 🙂

Vincent Cantin08:07:44

I don't know what to say about the styling, for now I can only see half of the UI, the other is crashing. Will provide feedback once I see the whole picture.

👍 3
refset08:07:38

Well it works without JavaScript too, you should be able to get almost-the-same experience

Vincent Cantin08:07:12

After a restart of my repl, the crash disappeared. However, the list of entities became a list of .. white space, and the search for an entity from its id show an error telling that the entity was not found.

Vincent Cantin08:07:30

The white space is only for the column crux.db/id

refset08:07:36

Can you see the entities are in the db via a normal query at the repl?

Vincent Cantin08:07:49

yes, I can see them

Vincent Cantin08:07:29

right now, the entities are loaded, but the id part is rendered in blank, and not clickable.

refset08:07:42

Hmm, can you check what happens with javascript disabled also?

refset08:07:13

What kind of IDs are you using? Keywords? UUIDs? Maps?

Vincent Cantin08:07:18

with JS disabled, it displays the ids in the table correctly.

Vincent Cantin08:07:52

in the repl, when I look for the entity using crux.api/entity , it returns nil

Vincent Cantin08:07:35

.. but the entity is found when I use crux.api/q

refset08:07:52

it would make sense that the UI doesn't understand that IDs can be maps (sounds like it will be easy to reproduce @UE35Y835W!) but what you're describing now seems very strange. Are you definitely passing the same db value for entity?

Vincent Cantin08:07:57

I had the same bug last week, after getting some errors in a transaction function (crux.api/entity returning nil). I am no longer using transaction functions and the problem is there again.

Vincent Cantin08:07:31

When I restart the (local) repl, the problem persists.

Vincent Cantin08:07:54

(let [db (crux/db crux-node)]
  (crux/entity db {:product-life/id 1234567, :product-life/product-type :foobar}))

👍 3
refset08:07:56

did you start with a clean tx-log for 1.9.2? Or did you upgrade from 1.9.0/1 ?

Vincent Cantin08:07:56

{:crux.node/topology [crux.standalone/topology
                                     crux.kv.rocksdb/kv-store
                                     crux.http-server/module]
                :crux.kv/db-dir "crux-store"}
I deleted "crux-store/" between the 2 versions and repopulated the DB.

Vincent Cantin08:07:17

last week, I was using 1.9.1-beta

refset08:07:29

ah, so you don't have an event-log-dir for standalone persistence? you're re-populating every time you restart the repl?

Lu08:07:11

The UI definitely understands maps. I am still trying to reproduce

👌 3
🙂 3
Vincent Cantin08:07:39

@UE35Y835W the problem might be on the server, the DB reached a state where any call to crux.api/entity returned nil for any id.

6
Vincent Cantin08:07:13

I am deleting the DB and try to reproduce.

👍 3
Vincent Cantin09:07:41

The weird state happened while I was doing queries only, but the problem persisted after a restart of the REPL.

Vincent Cantin09:07:28

[wild guess] I suspect that some invalid queries are kept by the DB and retried, and it leads to failure.

Daniel Mason09:07:50

Hello vincent - I believe map ids (and a few other types of ids) may still be a problem with the 1.9.2 UI - there was recently some work on it on master to sort out the general handling entity ids, but we mostly brought in bug fixes to the 1.9.2 release so I don't believe they were released in it.

Vincent Cantin09:07:45

... could it be the way I stop the repl ? (without closing the crux-node)

Vincent Cantin09:07:53

Ok, I got the problem repeated. Now looking for the minimal problematic scenario.

Vincent Cantin09:07:46

I think the crux.api/entity problem is related to me not closing the crux-node correctly.

3
Vincent Cantin09:07:38

no .. it has nothing to do with closing, I do it correctly

Vincent Cantin09:07:59

How I reproduce the bug: 1. I delete the db's directory. 2. I start a repl, start a crux node. 3. I insert documents in the db. 4. I query 1 entity from its id, works fine. Multiple times, still works fine. 5. I close the crux-node, recreate one. 6. I query the same entity, nil is returned.

refset09:07:58

@U8MJBRSR5 do you fancy sharing your screen and pairing on it briefly?

Vincent Cantin09:07:39

let's continue the conversation in PM

Vincent Cantin03:07:58

For whom it may be useful .. the problem I faced has been resolved by adding those extra lines to my standalone crux config, thanks to the help of @taylor.jeremydavid:

:crux.standalone/event-log-kv-store crux.kv.rocksdb/kv
:crux.standalone/event-log-dir "dbeventlog"

👍 9
mauricio.szabo23:07:54

Hi, I was looking at Crux and though: how hard would it be to use another service as a kv backend for Crux? Is there some documentation somewhere, or can you point me to the right places so I can experiment a little bit? I'm quite curious 😄

dominicm06:07:58

I don't think there's docs, but it's very easy. There's a protocol you can extend. Reading the source of existing implementations would be enlightening.

3
refset08:07:27

Yep, we don't have docs on how to write a module currently but looking at how we implemented rocks/lmdb is a good idea. Which backend are you considering?

mauricio.szabo14:07:55

I was considering MongoDB or PostgreSQL JSONB. But mostly, I just want to study a little bit 🙂 Can you link me the source files I could use as reference? Thanks a lot!

refset14:07:21

One thing to consider is that the KV indexes should as physically close as possible to the Datalog engine (ideally in-process like Rocks/LMDB) as the algorithm is fairly chatty, but you might be able to get good performance with remote stores like Mongo/Postgres, it would certainly be an interesting experiment. You can see the 3 levels of KV protocols mentioned here: https://github.com/juxt/crux/blob/master/crux-rocksdb/src/crux/kv/rocksdb.clj#L82

👍 3
refset14:07:16

This is no longer up-to-date with how Crux modules work, but you can see how the Avisi team managed to get Xodus working as a KV index backend last year (without any help/input from JUXT, I might add!): https://github.com/avisi-apps/crux-xodus/blob/master/src/avisi/crux/kv/xodus.clj

👍 6
Vincent Cantin03:07:58

For whom it may be useful .. the problem I faced has been resolved by adding those extra lines to my standalone crux config, thanks to the help of @taylor.jeremydavid:

:crux.standalone/event-log-kv-store crux.kv.rocksdb/kv
:crux.standalone/event-log-dir "dbeventlog"

👍 9