Fork me on GitHub
#datomic
<
2018-06-04
>
Ethan Miller01:06:57

Hi all, I've been struggling with what seems to be a dependency conflict problem between Datomic Cloud and ring. At least, it first presented itself in that guise. Now I'm less sure, but it's an error that appears when d/client is called. I've created a branch on a test repo to show what I mean: https://github.com/ezmiller/datomic-ring-dep-conflict/tree/exlusions-from-datomic-cloud. The errors that arise still smack of a dep conflict in the sense that there's a missing class: java.lang.ClassNotFoundException: org.eclipse.jetty.client.HttpClient, compiling:(cognitect/http_client.clj:1:1) and Caused by java.lang.ClassNotFoundException org.eclipse.jetty.client.HttpClient`. The full stack trace is in the README in the repo.

Alex Miller (Clojure team)01:06:16

This is doc’ed on the Datomic faq page I think

Ethan Miller01:06:26

@alexmiller I think you are referring to the troubleshooting section referencing the jetty dep conflict? This: https://docs.datomic.com/cloud/troubleshooting.html#dependency-conflict

Ethan Miller02:06:00

Right. Yeah. In that branch of the repo, I've got those exclusions added. The error happens when you call d/client.

Alex Miller (Clojure team)02:06:55

Hmm, well that’s more than I can diagnose on my phone :)

Ethan Miller02:06:09

🙂 So far it's been more than I can diagnose at all!

Ethan Miller02:06:22

Wasted at least 6 hours on this today.

Alex Miller (Clojure team)02:06:46

If you exclude Jetty don’t you need to include it somehow ?

Alex Miller (Clojure team)02:06:42

If you lein deps :tree what’s including jetty?

Ethan Miller02:06:31

Both datomic.cloud and ring reference parts of jetty normally, which creates the dependency conflicts. My understanding is that the exclusions are placed on one side to defer to the inclusions by the other package. In this case, the recommendation in the troubleshooting doc is I think deferring to the versions included by ring. Part of this, also, I gather, is that the way these packages work you can only have one version dependency in a project since they all somehow exist in a global space. (I'm not sure about this but I gathered it from a comment at the end of this thread: http://discuss.purelyfunctional.tv/t/how-to-detect-and-workaround-dependency-conflicts/516/4). Here's the relevant part of lein deps :tree with the exclusions applied:

...
[ring "1.7.0-RC1"]
   [ring/ring-core "1.7.0-RC1"]
     [clj-time "0.14.3"]
     [commons-fileupload "1.3.3"]
     [commons-io "2.6"]
     [crypto-equality "1.0.0"]
     [crypto-random "1.2.0"]
   [ring/ring-devel "1.7.0-RC1"]
     [clj-stacktrace "0.2.8"]
     [hiccup "1.0.5"]
     [ns-tracker "0.3.1"]
       [org.clojure/java.classpath "0.2.3"]
       [org.clojure/tools.namespace "0.2.11"]
   [ring/ring-jetty-adapter "1.7.0-RC1"]
     [org.eclipse.jetty/jetty-server "9.2.24.v20180105"]
       [javax.servlet/javax.servlet-api "3.1.0"]
       [org.eclipse.jetty/jetty-http "9.2.24.v20180105"]
         [org.eclipse.jetty/jetty-util "9.2.24.v20180105"]
       [org.eclipse.jetty/jetty-io "9.2.24.v20180105"]

Ethan Miller05:06:40

What seems to be a solution was provided by @shohs on the Datomic Forum: https://forum.datomic.com/t/dependency-conflict-with-ring/447/4?u=emiller

Ethan Miller05:06:41

The exclusions suggested in the "Troubleshooting" text did not work. Removing them and then adding [org.eclipse.jetty/jetty-server “9.3.7.v20160115”] as a top-level dep does. At least so far...

jumar08:06:58

@ezmiller77 I tried to diagnose your problem a bit more and I think you can solve it by explicitly using newer version of jetty-server and jetty-client explicitly. See my answer here: https://stackoverflow.com/a/50676715/1184752 Also the related change: https://github.com/ezmiller/datomic-ring-dep-conflict/pull/1/files

jumar08:06:29

I've been following official datomic cloud tutorial which is pretty good. However, I've struggled a bit with following

#:cognitect.anomalies{:category :cognitect.anomalies/forbidden,
                         :message
                         "Forbidden to read keyfile at ************/juraj-datomic-cloud/datomic/access/admin/.keys. Make sure that your endpoint is correct, and that your ambient AWS credentials allow you to GetObject on the keyfile."}

jumar08:06:03

Eventually, I've found that I can specify :creds-profile in datomic client config, but found that only by reading source code. Although it was related to credentials profiles which datomic cloud's documentation doesn't use I think it would be useful to mention that in the documentation because it's pretty common to use profiles.

marshall13:06:03

You should be able to use any standard method of AWS credential management

marshall13:06:21

the environment you run in must have proper IAM credentials

marshall13:06:32

(envars, aws profile)

Ethan Miller13:06:17

@jumar I was also able to get in with IAM. Did you grant access to the IAM group for SSH?

Ethan Miller13:06:42

Oh I see @U05120CBV already pointed you to the relevant section of the docs.

jumar09:06:54

I'm evaluating Datomic cloud (Solo) and using socks proxy for connecting to the database. I'm suffering from frequent connection errors (socks proxy connection being broken every ~10 mins). Did you encounter such problems before or is there some issue in my network?

Ethan Miller12:06:58

@jumar: that solution, specifying the server, worked for me as well. How did you think to try specifying the server? Was it named at some point in the lein deps :tree output? Or did you work it out somehow? I'm curious to know as I tried so many combinations, but never saw the jetty-server named...

jumar13:06:54

It's a transitive ring dependency therefore you should see it in lein deps :tree output. I had been already thinking about specifying jetty server deps in project.clj explicitly because that's one way how you enforce proper versions to be used in your project effectively overriding transitive dependencies.

Ethan Miller12:06:18

Regarding your trouble with the broken socks proxy connection, I am also experiencing the same behavior. It troubled me but I hadn't gotten to the point where I had the luxury of considering what to do about that. I thought I might use some sort of service that restarts something when it fails. Can't remember the names off-hand.

👍 4
jaret13:06:10

@jumar @ezmiller77 re: connection errors. We don’t see that happening. I do recall a previous user reporting something similar and they used autossh to get around laptop sleeps etc.

jaret13:06:02

>Autossh for keeping alive the socks proxy: >Not sure who to message with this, but I have a suggestion. >I’m using datomic cloud and developing against it, which basically means a long running datomic-socks-proxy process. This was quite painful due to frequent timeouts and disconnects, causing me to having to keep jumping across and restarting it. >I installed autossh instead and hacked the script to use this, and it is now much more stable (and survives sleeps of my laptop). I wonder whether it might be worth having the standard script check for the installation of autossh and if found, use that instead (and maybe print a message to the user if not found, before continuing with the regular ssh client). >For anybody interested in my little hack, I just commented out the ssh command at the bottom of the script, and added the autossh one. Like this...

`#ssh -v -i $PK -CND ${SOCKS_PORT:=8182} ec2-user@${BASTION_IP}`
`autossh -M 0 -o "ServerAliveInterval 5" -o "ServerAliveCountMax 3" -v -i $PK -CND ${SOCKS_PORT:=8182} ec2-user@${BASTION_IP}`

cjsauer14:06:40

Thanks for this. I've saved your suggestion as a gist for future reference: https://gist.github.com/cjsauer/01b288a7e6fe306372b90d1930575836

jaret13:06:34

That was their suggestion, I have not tested it ^

👍 12
🙏 8
conan13:06:28

Is it possible to add an entity reference in a trasaction by using a lookup ref?

conan13:06:46

so for example (d/transact db-conn [{:person/name "conan" :person/team [:team/id 123]}]) if i want to add a ref to a specific team entity to a person

grierson14:06:11

In Datomic how would I model a Runner's time during a race? for example "Alice" started at 10:35 but is still currently running. Would I have a :end nil then (update :end (now)) when she finishes? But then I need to ask question about the race such as "Who is currently running?" (filter #(nil? (:end %)) runners)

Alex Miller (Clojure team)14:06:14

you can find all runners without an end attribute with something like

(d/q
    '[:find ?runner
      :in $
      :where
      [(missing? $ ?runner :end)]]
    (d/db conn))

donaldball20:06:44

Quick modeling question: I want to mark attributes as deprecated, indicating they should neither exist nor be asserted in a database. I could justify using a boolean (though there’d be no reason for a false value to ever exist), a long (the t-value of the deprecation), or an instant (the time of the deprecation). Does anyone have any opinions on the best choice?

Alex Miller (Clojure team)21:06:50

Well you can get the t and instant from the transaction that contains the assertion already