Fork me on GitHub
#xtdb
<
2021-07-06
>
richiardiandrea15:07:56

Hi there, this morning I started my Crux server from scratch and I started receiving these WARNings

2021-07-06 09:45:00,872 WARN                                                       crux.tx - Transaction function failed when originally evaluated: #crux/id dfd920ebfa0088055b91222ad2e0c99713febdcd #uuid "00bc7b58-10cb-4496-b09a-db4ef308a766" {:crux.db.fn/exception java.lang.NullPointerException, :crux.db.fn/message nil, :crux.db.fn/ex-data nil}
These is some transaction function I was trying out but I am not sure which one is failing - and is there a way to delete them? Also, why is the transaction function called at startup (just curious to know how it all works)?

refset17:07:14

Hey again. It's generally best to leave the functions where they are, if you can, as it will make things easier to reason about. You can delete/evict them but I really wouldn't recommend it. Regardless, it wouldn't get rid this message though, The transaction function warning is being printed each time you restart the node because I gather your node is using an in-memory index (as per your "am for now using in-memory indexing" comment from the other thread) > I am not sure which one is failing You should be able to figure this out by inspecting the tx-log (via open-tx-log ) but there's not a straighforward API for this. You can add some side-effecting logging code into your transaction function to help too.

👍 2
richiardiandrea22:07:24

Hi again, one use case we have that we encode ranges like {:lower-bound 10 :lower-bound-inclusive true :upper-bound 12 :upper-bound-inclusive false} An idea that I have is to have a rule that conditionally uses Range Queries depending on the above data structure. I was wondering if I can "swap-in" the right operator conditionally, kind of like when in Clojure you do (if foo > <) and you use that in function position. I suspect I can do that with a custom Clojure function, was wondering if I can have a "conditional" rule

refset10:07:37

Hey 🙂 I think you can do something with multiple rule bodies, like:

{:find [r]
 :where [[(identity true) foo]
         (my-rule foo 2 3 r)]
 :rules [[(my-rule [x a b] r)
          [(true? x)]
          [(< a b) r]]
         [(my-rule [x a b] r)
          [(false? x)]
          [(> a b) r]]]}
          

👍 2
richiardiandrea15:07:31

I have noticed the (identity true) pattern in some of the crux tests...is that a way to use hardcoded values and assign them to variables?

refset17:07:32

that's exactly right. The other edn Datalog dbs have a special ground function which in theory provides some performance benefit, but we've not evaluated whether there's really any point to implementing such a thing in Crux (probably no benefit, in my opinion, given how the query engine works) so we stick with identity

😉 2