Fork me on GitHub
#datomic
<
2022-08-11
>
jumar04:08:32

I'm following the Max Datom tutorial - level 10: https://max-datom.com/#/DB612D03-9AF7-49B7-98B5-4C77ADE029D2 I have troubles making a proper query. They basically want to count posts of given user. I tried the following query but it only returns 1 as a count - it should return 3 because this user has 3 posts associated with them.

(d/q '[:find  ?user-name (count ?post-author)
         :where
         [?user :user/id #uuid "1B341635-BE22-4ACC-AE5B-D81D8B1B7678"]
         [?user :user/first+last-name ?user-name]
         [?post :post/author ?user]
         [?post :post/author ?post-author]
         ]
       db)
;; => [[["E. L." "Mainframe"] 1]]

jumar04:08:46

I'm wondering whether I should simply count :post/id instead of :post/author - but they say :post/author in the tutorial, which is confusing...

(d/q '[:find  ?user-name (count ?post-id)
         :where
         [?user :user/id #uuid "1B341635-BE22-4ACC-AE5B-D81D8B1B7678"]
         [?user :user/first+last-name ?user-name]
         [?post :post/author ?user]
         [?post :post/id ?post-id]
         ]
       (db))
  ;; => [[["E. L." "Mainframe"] 3]]

shane05:08:18

[?post :post/author ?user] is already making the connection between user and posts - you don't need to go into the post entity like that to pull out a field value.

jumar05:08:59

@U0V0HQWAE I'm not sure I understand. How do I count the posts then?

jumar05:08:22

Ah, it's just (count ?post) 🙂

defa13:08:36

We just ran into a production issue with pedestal/lacinia/datomic service. it worked fine until a few days ago and now we see a lot of the following errors:

ERROR:  Transactor not available {:cognitect.anomalies/category :cognitect.anomalies/unavailable, :cognitect.anomalies/message Transactor not available}
#error {
 :cause Transactor not available
 :data {:cognitect.anomalies/category :cognitect.anomalies/unavailable, :cognitect.anomalies/message Transactor not available}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message Transactor not available
   :data {:cognitect.anomalies/category :cognitect.anomalies/unavailable, :cognitect.anomalies/message Transactor not available}
   :at [datomic.peer$transactor_unavailable invokeStatic peer.clj 167]}]
 :trace
 [[datomic.peer$transactor_unavailable invokeStatic peer.clj 167]
  [datomic.peer$transactor_unavailable invoke peer.clj 164]
  [datomic.peer.Connection transactAsync peer.clj 328]
  [datomic.peer.Connection transact peer.clj 311]
  [datomic.api$transact invokeStatic api.clj 107]
  [datomic.api$transact invoke api.clj 105]
  
...

  [java.lang.Thread run Thread.java 829]]}
2022-08-10 13:49:37,916 [ERROR] org.apache.activemq.artemis.core.client - AMQ214016: Failed to create netty connection
java.nio.channels.ClosedChannelException: null
	at io.netty.handler.ssl.SslHandler.channelInactive(SslHandler.java:1063)
...
	at java.base/java.lang.Thread.run(Thread.java:829)
2022-08-10 13:49:38,310 [INFO ] datomic.common - {:event :common/retry, :backoff 1000, :attempts 4, :max-retries 9223372036854775807, :pid 2528, :tid 143}
clojure.lang.ExceptionInfo: Error communicating with HOST  on PORT 4334
	at datomic.connector$endpoint_error.invokeStatic(connector.clj:53)
...
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException: AMQ119007: Cannot connect to server(s). Tried with all available servers.
	at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:787)
	at datomic.artemis_client$create_session_factory.invokeStatic(artemis_client.clj:114)
	at datomic.artemis_client$create_session_factory.invoke(artemis_client.clj:104)
	at datomic.connector$try_hornet_connect.invokeStatic(connector.clj:96)
	at datomic.connector$try_hornet_connect.invoke(connector.clj:81)
	at datomic.connector$create_hornet_factory.invokeStatic(connector.clj:128)
	... 21 common frames omitted
2022-08-10 13:49:38,311 [WARN ] datomic.common - ... caused by ...
org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException: AMQ119007: Cannot connect to server(s). Tried with all available servers.
	at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:787)
	at datomic.artemis_client$create_session_factory.invokeStatic(artemis_client.clj:114)
...
	at java.base/java.lang.Thread.run(Thread.java:829)


...

2022-08-10 13:50:33,608 [INFO ] datomic.common - {:event :common/retry, :backoff 1000, :attempts 1, :max-retries 9223372036854775807, :pid 2528, :tid 143}
clojure.lang.ExceptionInfo: Error communicating with HOST transactor.host.name.removed on PORT 4334
	at datomic.connector$endpoint_error.invokeStatic(connector.clj:53)
...
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException: AMQ119010: Connection is destroyed
	at org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:335)
...
	at clojure.lang.RestFn.invoke(RestFn.java:464)
	at datomic.connector.TransactorHornetConnector$fn__10264.invoke(connector.clj:214)
	... 17 common frames omitted
Any ideas what’s going on here?

defa13:08:19

This is an Datomic on-prem and management has decided to not renew the license because everything is running fine :face_with_rolling_eyes:

defa13:08:41

I’m going to convince them to get proper support and bugfixes by renewing the license but meanwhile some help would be greatly appreciated.

defa13:08:13

The the pedestal-based server, datomic-transactor and the postgres-db are all running on separate virtual machines.

manutter5113:08:32

I’m not a very good resource for datomic debugging, but we’ve had some Transactor Not Available issues earlier in the summer and I can pass on what I’ve overheard. Check for out-of-memory issues and out-of-disk-space issues. Also check the network connections between the transactor and the backend store — we finally tracked our issues down to a bad network switch.

1
👍 1
defa14:08:17

Thanks, I already checked that. At least in my Grafana dashboard (node exporter) I can so no anomalies. But a broken switch might not be detected that way. Thanks.

👍 1