Fork me on GitHub
#datomic
<
2021-07-07
>
souenzzo11:07:28

#client Why this query returns nothing

(count  (d/q
          '[:find (pull ?e [*]) 
            :where
            [?e _ #uuid"ca92f40a-998b-5fef-96c0-7a3074c55ab1"]]
          db))
=> 0
and this query find the entity?
(count  (d/q
          '[:find (pull ?e [*]) 
            :where
            [?a :db/ident]
            [?e ?a #uuid"ca92f40a-998b-5fef-96c0-7a3074c55ab1"]]
          db))
=> 1
This behavior feels wrong to me

thumbnail14:07:53

There's no index for EVAT, only EAVT, AEVT AVET and VAET

souenzzo14:07:23

So it should throw an exception, right?! I remember to get "full database scan" in peer api

thumbnail14:07:54

Yeah; I wondered why this doesn't throw a full database scan error either

thumbnail14:07:48

The client api will throw "full database scan" errors too btw; just not in this example.

souenzzo14:07:37

datomic client is way harder to create minimal examples 😞

Joe Lane17:07:23

Why is it harder @souenzzo?

souenzzo16:07:36

where order matter: In "devtime", I was trying to find "all attributes that point into an entity"

(d/q '[:find ?ident 
       :where 
       [?a :db/ident ?ident]
       [?x ?a ?e]
       [?e :user/id]]
   db)
Execution error (IllegalArgumentException) at datomic.core.datalog/resolve-id (datalog.clj:330).
Cannot resolve key: Sun Jun 13 05:00:44 BRT 2021
(d/q '[:find ?ident 
       :where 
       [?a :db/ident ?ident]
       [?e :user/id]
       [?x ?a ?e]]
   db)
=> [[:a] [:b] [:c]]
Is it a know issue? Should I report at http://ask.datomic.com?

ghadi17:07:39

@souenzzo it's not clear what you are trying to do

ghadi17:07:19

are you trying to figure out which attributes are refs? because ref attributes point to entities

[?attr :db/ident ?ident]
[?attr :db/valueType :db.valueType/ref]
or are you asking about which attribute entities have refs pointing to other entities?

ghadi17:07:49

(because attributes are defined in datomic as ordinary entities, and they can have arbitrary facts asserted about those entities)

souenzzo17:07:29

My original problem was "or are you asking about which attribute entities have refs pointing to other entities?" But I'm not reporting this. I already solved my problem. I'm reporting ":where order may change the results of the query" As far I know, by design, change the :where order should only affect the performance, right?!

ghadi18:07:51

it is not clear what happened in your first query. The error doesn't seem to correlate to the query

souenzzo18:07:37

Yes, related Datomic find all ?a for each ?a, find ?x and ?e once ?e is used as a id at [?e :user/id], datomic tries to call resolve-id in ?e But ?e is an instant/date

ghadi18:07:20

an entity can never be a date

souenzzo18:07:26

Execution error (IllegalArgumentException) at datomic.core.datalog/resolve-id (datalog.clj:330).
Cannot resolve key: Sun Jun 13 05:00:44 BRT 2021
*e
=>
#error{:cause "Cannot resolve key: Sun Jun 13 05:00:44 BRT 2021",
       :via [{:type clojure.lang.ExceptionInfo,
              :message "processing clause: [?e :cs.model.monitored.machine-type/id], message: Cannot resolve key: Sun Jun 13 05:00:44 BRT 2021",
              :data #:cognitect.anomalies{:category :cognitect.anomalies/incorrect,
                                          :message "processing clause: [?e :cs.model.monitored.machine-type/id], message: Cannot resolve key: Sun Jun 13 05:00:44 BRT 2021"},
              :at [datomic.core.datalog$throw_query_ex_BANG_ invokeStatic "datalog.clj" 50]}
             {:type java.lang.IllegalArgumentException,
              :message "Cannot resolve key: Sun Jun 13 05:00:44 BRT 2021",
              :at [datomic.core.datalog$resolve_id invokeStatic "datalog.clj" 330]}],
       :trace [[datomic.core.datalog$resolve_id invokeStatic "datalog.clj" 330]
               [datomic.core.datalog$resolve_id invoke "datalog.clj" 327]
               [datomic.core.datalog$fn__22911$bind__22923 invoke "datalog.clj" 442]
               [datomic.core.datalog$fn__22911 invokeStatic "datalog.clj" 619]
               [datomic.core.datalog$fn__22911 invoke "datalog.clj" 399]
               [datomic.core.datalog$fn__22761$G__22735__22776 invoke "datalog.clj" 119]
               [datomic.core.datalog$join_project_coll invokeStatic "datalog.clj" 184]
               [datomic.core.datalog$join_project_coll invoke "datalog.clj" 182]
               [datomic.core.datalog$fn__22834 invokeStatic "datalog.clj" 289]
               [datomic.core.datalog$fn__22834 invoke "datalog.clj" 285]
               [datomic.core.datalog$fn__22740$G__22733__22755 invoke "datalog.clj" 119]
               [datomic.core.datalog$eval_clause$fn__23495 invoke "datalog.clj" 1460]
               [datomic.core.datalog$eval_clause invokeStatic "datalog.clj" 1455]
               [datomic.core.datalog$eval_clause invoke "datalog.clj" 1421]
               [datomic.core.datalog$eval_rule$fn__23527 invoke "datalog.clj" 1541]
               [datomic.core.datalog$eval_rule invokeStatic "datalog.clj" 1526]
               [datomic.core.datalog$eval_rule invoke "datalog.clj" 1505]
               [datomic.core.datalog$eval_query invokeStatic "datalog.clj" 1569]
               [datomic.core.datalog$eval_query invoke "datalog.clj" 1552]
               [datomic.core.datalog$qsqr invokeStatic "datalog.clj" 1658]
               [datomic.core.datalog$qsqr invoke "datalog.clj" 1597]
               [datomic.core.datalog$qsqr invokeStatic "datalog.clj" 1615]
               [datomic.core.datalog$qsqr invoke "datalog.clj" 1597]
               [datomic.core.query$q_STAR_ invokeStatic "query.clj" 619]
               [datomic.core.query$q_STAR_ invoke "query.clj" 606]
               [datomic.core.local_query$local_q invokeStatic "local_query.clj" 58]
               [datomic.core.local_query$local_q invoke "local_query.clj" 52]
               [datomic.core.local_db$fn__25618 invokeStatic "local_db.clj" 28]
               [datomic.core.local_db$fn__25618 invoke "local_db.clj" 24]
               [datomic.client.api.impl$fn__11642$G__11635__11649 invoke "impl.clj" 41]
               [datomic.client.api.impl$call_q invokeStatic "impl.clj" 150]
               [datomic.client.api.impl$call_q invoke "impl.clj" 147]
               [datomic.client.api$q invokeStatic "api.clj" 393]
               [datomic.client.api$q invoke "api.clj" 365]
               [datomic.client.api$q invokeStatic "api.clj" 395]
               [datomic.client.api$q doInvoke "api.clj" 365]
               [clojure.lang.RestFn invoke "RestFn.java" 423]

ghadi18:07:44

can you make a reproducible case?

ghadi18:07:09

including input form

souenzzo18:07:33

(let [hello {:server-type :dev-local :system "hello" :db-name "hello"}
      conn (-> (d/client hello)
             (doto (d/create-database hello))
             (d/connect hello))
      tx-schema [{:db/ident       :user/id
                  :db/valueType   :db.type/string
                  :db/cardinality :db.cardinality/one}
                 {:db/ident       :address/user
                  :db/valueType   :db.type/ref
                  :db/cardinality :db.cardinality/one}]
      {:keys [db-after]} (d/transact conn {:tx-data tx-schema})
      {:keys [db-after]} (d/transact conn {:tx-data [{:db/id   "a"
                                                      :user/id "a"}
                                                     {:address/user "a"}]})]
  (d/q '[:find ?ident
         :where
         [?a :db/ident ?ident]
         [?x ?a ?e]
         [?e :user/id]]
    db-after))

souenzzo18:07:39

Sometimes throw by date, sometimes by string

Execution error (IllegalArgumentException) at datomic.core.datalog/resolve-id (datalog.clj:330).
Cannot resolve key: Retract all facts about an entity, including references from other entities and component attributes recursively.

souenzzo18:07:51

Expected result

=> [[:address/user]]

souenzzo18:07:58

Is it enough?

jdkealy20:07:33

Is it possible to run datomic inside a docker-compose? Everything seems to work fine, except my clojure app cannot seem to access datomic:

favila21:07:40

is port 4335 open also? The dev storage is special because it’s also acting as storage (h2 sql) on port 4335.

jdkealy21:07:36

oh gotcha! trying that thanks

jdkealy21:07:25

yes, actually 4334,4335,4336

tvaughan21:07:27

If the clojure app is also running in a container, localhost won't work. You'll need to use the name of the running container, as well as place both on the same bridge network. No need to export the ports in this case either, fyi

favila21:07:02

4336 is the h2 web console. if you don’t need it you could keep that closed

Drew Verlee22:07:35

re posting my question here in case something jumps out at anyone 🙂 My next step is to ... re-read the docs again? Then flush out the websocket functionality more, as i worry that my mock/toy example might be complicating things rather then simplifying them. https://forum.datomic.com/t/where-do-i-view-output-of-datomic-ion-cast-alert/1892

Joe Lane23:07:32

Hey @drewverlee, a couple of things right off the bat: • https://docs.datomic.com/cloud/operation/monitoring.html#searching-cloudwatch-logs-aws for viewing the cloudwatch logs for your solo system. The log group should be called datomic-{name-of-your-system} • Per the https://docs.datomic.com/cloud/ions/ions-reference.html#entry-points table, Lambda ions MUST return either a String, InputStream, ByteBuffer, or File. Cast functions don't return any of those. • I don't think you want to cast an alert, I think you want https://docs.datomic.com/cloud/ions/ions-monitoring.html#events. Also, custom metrics are not supported in solo (to keep the cost down). • Your alert would not show up in the lambda logs, those have a completely separate log group than your system. • You are on the right track!

👍 2
Joe Lane23:07:32

Hey @drewverlee, a couple of things right off the bat: • https://docs.datomic.com/cloud/operation/monitoring.html#searching-cloudwatch-logs-aws for viewing the cloudwatch logs for your solo system. The log group should be called datomic-{name-of-your-system} • Per the https://docs.datomic.com/cloud/ions/ions-reference.html#entry-points table, Lambda ions MUST return either a String, InputStream, ByteBuffer, or File. Cast functions don't return any of those. • I don't think you want to cast an alert, I think you want https://docs.datomic.com/cloud/ions/ions-monitoring.html#events. Also, custom metrics are not supported in solo (to keep the cost down). • Your alert would not show up in the lambda logs, those have a completely separate log group than your system. • You are on the right track!

👍 2
Drew Verlee23:07:05

> Your alert would not show up in the lambda logs, those have a completely separate log group than your system. Ah, this is the issue.

🎸 2
Drew Verlee23:07:46

Thanks a ton btw

👍 3