datalevin

Johnny 2024-09-28T16:33:27.598499Z

Hello everyone, I can't quite wrap my head around this result:

(let [db (d/db conn)]
  (println (d/q '[:find ?u :where [?u :garden.user/name "sample-user"]] db))
  (println (d/q '[:find ?u :where [?u :garden.user/name _]] db)))

Johnny 2024-09-28T16:33:44.076689Z

It outputs:

#{[3]}
#{}

Johnny 2024-09-28T16:35:07.620159Z

I simply don't understand how this is possible. Shouldn't the second result relation always be the same as or bigger than the first?

Johnny 2024-09-28T19:28:10.155249Z

It appears the problem resolved itself... I don't know how I reached this state to begin with, but after clearing out the database completely and starting over it works as expected

Johnny 2024-09-29T09:57:44.031129Z

I was just returning to this channel because it happened again... and yeah it seems like it happens on initial setup. What's the recommended version to revert to?

Johnny 2024-09-29T10:09:10.029769Z

0.9.8 seems to work

2024-09-29T11:49:36.562339Z

Yeah 0.9.8 doesn’t have the issue. I tried looking into what the actual cause was but I’m out of depth. I’ve just got this commit checked out: 14502e772184a9564131e92575c554e724917be2 https://github.com/juji-io/datalevin/commit/14502e772184a9564131e92575c554e724917be2

Huahai 2024-09-29T22:31:11.739749Z

Fixed in master

🎉 1
2024-09-28T21:04:06.898329Z

Sounds like it might be related to this issue https://github.com/juji-io/datalevin/pull/269

2024-09-30T08:47:08.435229Z

Amazing, I’ll switch to the latest master commit. 🚀

2024-09-30T08:52:57.149319Z

Ahh so count were not happening when a-size was zero. Did that cause the query planner just to ignore that attribute completely?

Huahai 2024-09-30T18:11:55.798689Z

Right, the shortcut in the query processing will return nil immediately when some attributes found to have zero size.

👍 1
2024-09-28T22:39:22.872639Z

Hello ppl! I encountered a weird problem about testids. Details are in thread.

2024-09-29T09:06:07.330299Z

I will try today. Fast attempt to isolate case yesterday failed :(

2024-09-29T12:04:32.450669Z

duckie So… the rubber duck works. While trying to create an isolated case, I found out that there was an error in the :tariff/servers value, which is also a ref type with :db.cardinality/many. I had to include reverse lookups there. However, the error message is a bit confusing, though…

Huahai 2024-09-29T18:36:41.845819Z

What kind of error?

Huahai 2024-09-29T18:38:16.642489Z

If it is something that the system should check for, we can add the check

2024-09-29T18:43:58.222639Z

I put in :tariff/servers such a vector like [:serv-1 :serv-2 ...etc...] , but :serv-1 and others are values of :server/id . I had to put reverse lookup there. So, the problem was that system complained about problems with transient maps, but better would be to say something like "Values in :tariff/servers have to be existent :tempid or reverse lookup clause, but found ':serv-1'"

Huahai 2024-09-29T22:30:40.264899Z

ok, maybe file an issue so we can add such checks?

👌 1
2024-09-28T22:51:58.727759Z

Error message:

Exception in thread "main" clojure.lang.ExceptionInfo: Unable to write transit:#error {
 :cause "Not supported: class clojure.lang.PersistentArrayMap$TransientArrayMap"
 :via
 [{:type java.lang.RuntimeException
   :message "java.lang.Exception: Not supported: class clojure.lang.PersistentArrayMap$TransientArrayMap"
   :at [com.cognitect.transit.impl.WriterFactory$1 write "WriterFactory.java" 65]}
  {:type java.lang.Exception
   :message "Not supported: class clojure.lang.PersistentArrayMap$TransientArrayMap"
   :at [com.cognitect.transit.impl.AbstractEmitter marshal "AbstractEmitter.java" 195]}]
 :trace
 [[com.cognitect.transit.impl.AbstractEmitter marshal "AbstractEmitter.java" 195]
  [com.cognitect.transit.impl.JsonEmitter emitMap "JsonEmitter.java" 171]
  [com.cognitect.transit.impl.AbstractEmitter emitMap "AbstractEmitter.java" 86]
  [com.cognitect.transit.impl.AbstractEmitter marshal "AbstractEmitter.java" 185]
  [com.cognitect.transit.impl.AbstractEmitter marshalTop "AbstractEmitter.java" 212]
  [com.cognitect.transit.impl.JsonEmitter emit "JsonEmitter.java" 41]
  [com.cognitect.transit.impl.WriterFactory$1 write "WriterFactory.java" 62]
  [cognitect.transit$write invokeStatic "transit.clj" 171]
  [datalevin.protocol$write_transit_string invokeStatic "protocol.clj" 45]
  [pod.huahaiy.datalevin$run$fn__28160 invoke "datalevin.clj" 896]
  [pod.huahaiy.datalevin$run invokeStatic "datalevin.clj" 878]
  [datalevin.main$_main invokeStatic "main.clj" 527]
  [datalevin.main$_main doInvoke "main.clj" 513]
  [clojure.lang.RestFn invoke "RestFn.java" 397]
  [clojure.lang.AFn applyToHelper "AFn.java" 152]
  [clojure.lang.RestFn applyTo "RestFn.java" 132]
  [datalevin.main main nil -1]]} {:value {:error :transact/syntax, :tempids #object[clojure.lang.PersistentArrayMap$TransientArrayMap 0x54507296 "clojure.lang.PersistentArrayMap$TransientArrayMap@54507296"], :type "class clojure.lang.ExceptionInfo"}}
        at datalevin.protocol$write_transit_string.invokeStatic(protocol.clj:52)
        at pod.huahaiy.datalevin$run$fn__28160.invoke(datalevin.clj:896)
        at pod.huahaiy.datalevin$run.invokeStatic(datalevin.clj:878)
        at datalevin.main$_main.invokeStatic(main.clj:527)
        ………
Data passed to d/transact!:
[{:db/id -1, :price/amount {:months 1}, :price/price 100M}
                  {:db/id -2, :price/amount {:months 6}, :price/price 500M}
                  {:db/id -3, :price/amount {:years 1}, :price/price 800M}
                  {:tariff/description "Test 1",
                   :tariff/id :test,
                   :tariff/name "Test",
                   :tariff/prices [-1 -2 -3],
                   :tariff/priority 0,
                   :tariff/servers ["srv-1"],
                   :tariff/type :date}]}
The :tariff/prices attribute is of :db.type/ref and :db.cardinality/many Sure I checked many times that no any transient collection appears in my data. But if I try to run simple transaction like this, it works fine:
(comment
  (require '[pod.huahaiy.datalevin :as d]
           '[babashka.fs :as fs])

  
  (let [dtlv-dir (str "/tmp/dtlv-sandbox-" (random-uuid))
        conn (d/get-conn dtlv-dir {:a/x {:db/valueType :db.type/long}
                                   :a/y {:db/valueType :db.type/keyword}
                                   
                                   :b/as {:db/valueType :db.type/ref
                                          :db/cardinality :db.cardinality/many}})]
    (try
      (d/transact! conn [{:db/id -1
                          :a/x 1 :a/y :a1}
                         {:db/id -2
                          :a/x 2 :a/y :a2}
                         {:db/id -3
                          :a/x 3 :a/y :a3}
                         {:b/as [-1 -2 -3]}])

      (d/q '[:find (pull ?b [* {:b/as [*]}])
             :where [?b :b/as]] (d/db conn))
      
      (finally
        (d/close conn)
        (fs/delete-tree dtlv-dir)))))
So… what could be a problem?

Huahai 2024-09-29T04:40:45.268819Z

tempids collection is transient. so some error in the transaction logic

Huahai 2024-09-29T04:41:11.967939Z

somewhere in the db.clj

Huahai 2024-09-29T04:41:28.611469Z

could you isolate a test case?