Fork me on GitHub
#datomic
<
2019-01-03
>
johanatan00:01:09

@marshall this is what is contained in the CloudWatch logs:

"Error": "Fault",
"CognitectAnomaliesMessage": "java.lang.AssertionError: Assert failed: cfg, compiling:(core.clj:25:1)"

johanatan00:01:39

line 25 is the last line of the following block:

(defonce system "datomic")
(defonce region "us-east-1")
(defonce cfg {:server-type :ion
              :region region
              :system system
              :creds-profile "personal"
              :endpoint (format "" system region)
              :proxy-port 8182})

(defonce client (d/client cfg))

johanatan04:01:26

tried inlining the cfg as follows and am still getting the same error (although there is no longer a binding named cfg):

(defonce client (d/client {:server-type :ion   <== error points to this line
                           :region region
                           :system system
                           :creds-profile "personal"
                           :endpoint (format "" system region)
                           :proxy-port 8182}))

lilactown05:01:15

does this work locally for you?

lilactown05:01:35

e.g. in a REPL, connecting to the system through the SOCKS proxy?

johanatan05:01:36

yep, it works locally. i just tried without the cred-profile because that is needed for local only

johanatan05:01:55

but i just found that the ion-starter has a :query-group specified which i am missing

johanatan05:01:01

perhaps that is the problem?

lilactown05:01:23

yeah that’s the only real difference I can see between what you have and what my Ions code looks like

johanatan05:01:32

ok, i'll try it

johanatan05:01:35

same error with :query-group

lilactown05:01:35

it’s an assertion error?

johanatan05:01:07

"Msg": ":datomic.cluster-node/-main failed: java.lang.AssertionError: Assert failed: cfg, compiling:(core.clj:17:1)",
    "Ex": {
        "Cause": "java.lang.AssertionError: Assert failed: cfg, compiling:(core.clj:17:1)",
        "Via": [
            {
                "Type": "clojure.lang.ExceptionInfo",
                "Message": "java.lang.AssertionError: Assert failed: cfg, compiling:(core.clj:17:1)",
                "Data": {
                    "CognitectAnomaliesCategory": "CognitectAnomaliesFault",
                    "DatomicAnomaliesException": {
                        "Cause": "Assert failed: cfg",
                        "Via": [
                            {
                                "Type": "clojure.lang.Compiler$CompilerException",
                                "Message": "java.lang.AssertionError: Assert failed: cfg, compiling:(core.clj:17:1)",
                                "At": [
                                    "clojure.lang.Compiler",
                                    "load",
                                    "Compiler.java",
                                    7526
                                ]
                            },
                            {
                                "Type": "java.lang.AssertionError",
                                "Message": "Assert failed: cfg",
                                "At": [
                                    "datomic.client.impl.local$create_client",
                                    "invokeStatic",
                                    "local.clj",
                                    97
                                ]
                            }
                        ],
                        "Trace": [
                            [
                                "datomic.client.impl.local$create_client",
                                "invokeStatic",
                                "local.clj",
                                97
                            ],
                            [
                                "datomic.client.impl.local$create_client",
                                "invoke",
                                "local.clj",
                                94
                            ],
                            [
                                "clojure.lang.Var",
                                "invoke",
                                "Var.java",
                                381
                            ],
                            [
                                "datomic.client.api.impl$dynarun",
                                "invokeStatic",
                                "impl.clj",
                                19
                            ],
...

johanatan05:01:36

would it be a problem that this file has a -main defined?

johanatan05:01:42

[i'm using that main to run locally from command line]

lilactown05:01:25

oooo probably

johanatan05:01:32

hmm, let me try removing it

lilactown05:01:51

I’m not sure how ions get loaded, but I could see that mucking with it

johanatan05:01:00

yea, me too 🙂

johanatan05:01:14

bummer. same problem without the -main

lilactown05:01:39

would you be willing to post your source file?

johanatan05:01:17

let me see how much i can strip from it to still reproduce the problem

johanatan05:01:19

{:allow [
         ;; lambda handlers
         core/ion-func
         ]
 :lambdas {:load-chains
           {:fn core/ion-func
            :description "A description."}
           }
 :app-name "datomic"}

johanatan05:01:34

{:paths ["src" "resources"]
 :extra-paths ["resources"]
 :deps
 {clj-time {:mvn/version "0.15.0"}
  com.rpl/specter {:mvn/version "1.1.2"}
  aleph {:mvn/version "0.4.6"}
  org.clojure/clojure {:mvn/version "1.9.0"}
  com.datomic/ion {:mvn/version "0.9.28"}
  com.datomic/client-cloud {:mvn/version "0.8.71"}
  org.clojure/data.json {:mvn/version "0.2.6"}
  com.cognitect/transit-java #:mvn{:version "0.8.311"}
  com.datomic/client-api #:mvn{:version "0.8.12"}
  org.msgpack/msgpack #:mvn{:version "0.6.10"},
  com.cognitect/transit-clj #:mvn{:version "0.8.285"}
  com.cognitect/s3-creds #:mvn{:version "0.1.22"}
  com.amazonaws/aws-java-sdk-kms #:mvn{:version "1.11.349"}
  com.amazonaws/aws-java-sdk-s3 #:mvn{:version "1.11.349"}}
 :mvn/repos {"datomic-cloud" {:url ""}}
 :aliases
 {:dev {:extra-deps {com.datomic/ion-dev {:mvn/version "0.9.186"}}}}}

johanatan05:01:54

^^ that should be the entirety of it.

lilactown05:01:04

hm, I wonder if it could be the fact that you’re creating the client when your code is first run

lilactown05:01:30

in the Ions tutorial / example (which I pretty much copied), they define get-client:

(defonce get-client
  ;; "This function will return a local implementation of the client
  ;; interface when run on a Datomic compute node. If you want to call
  ;; locally, fill in the correct values in the map."
  (memoize #(d/client {:server-type :ion
                       :region "us-west-2"
                       :system "datomic"
                       :query-group "datomic"
                       :endpoint ""
                       :proxy-port 8182})))
I made it a defonce for REPL-ing but it’s still a function, that has to be invoked when your Ion is first invoked

lilactown05:01:29

I know there’s a bunch of spinning up and down that the Datomic system does when new code gets deployed. For example, a lot of times the first request I send after a deployment fails because it can’t connect to the database

johanatan05:01:25

ah yea. that could be it

johanatan06:01:41

yep, that was it.

johanatan06:01:21

thanks for your help!

johanatan06:01:14

btw, the docs at: https://docs.datomic.com/cloud/ions/ions-reference.html don't mention the need to delay the client creation

johanatan06:01:24

/ has the code I was trying to run initially

stijn11:01:18

it changed recently, because previously you could do this, although it wasn't recommended, but now, with the preloading of the active databases, you can't do this anymore

johanatan20:01:59

Oh ok. It might be a good idea to update the rest of the documentation (linked to previously) so that people don’t continue going down this path.

dmarjenburgh14:01:21

Hi, is there a way to pull :db/ident values (like enums). E.g. taking the tutorial example of colors and inventory items (https://docs.datomic.com/cloud/tutorial/assertion.html):

clojure
(d/pull db
          {:selector [:inv/type :inv/size :inv/color]
           :eid [:inv/sku "SKU-60"]})
; =>
; #:inv{:type #:db{:id 15617463160930376, :ident :shirt},
;      :size #:db{:id 29304183903486023, :ident :xlarge},
;      :color #:db{:id 32330039903125571, :ident :yellow}}
I would like to retrieve: #:inv{:type :shirt :size :xlarge :color :yellow} without transforming the query result. Is this possible?

markbastian14:01:00

Anyone know if there are plans to bring the datomic cloud find-spec up to date with the on-prem version? For example, support for . and ... to return scalars and vectors?

Jules White15:01:53

I have a strange issue. The following rule works fine when invoked via the REPL, but fails when invoked via a Lambda in Datomic Cloud. However, if I deploy, invoke the rule via the REPL, and then invoke it via Datomic Cloud Lambda, it will work from then on when invoked via Lambda. Code: [(foo ?x ?y) [(my.namespace/foo ?x ?y) [?q ?r]]] Initial error when invoking from Datomic Cloud: The following forms do not name predicates or fns: (my.namespace/foo)

timgilbert17:01:21

@dmarjenburgh: basically no, to my knowledge, though you could use [{:inv/type [:db/ident]} {:inv/size [:db/ident]}] as your pull expression to elide the :db/id stuff out of there. One possible alternative is to just use keywords as your data types for enum values, though there are tradeoffs.

eoliphant14:01:46

it’s not gonna work, AFAIK with pull, as they’re just regular distinct entities as far as datomic is concerned, even though we group them together ‘mentally’. We do what you’re after with regular queries. Like the following returns all of our :action/.. enums

:where
             [?a :db/ident ?i]                               ;;finds all :db/idents
             [((comp #{"action"} namespace) ?i)]

timgilbert17:01:17

There's a bit of background on the difference between how those approaches behave here, although this is in a datomic on-prem/peer context, not a cloud/client context: http://docs.workframe.com/stillsuit/current/manual/#_stillsuit_enums

idiomancy19:01:08

hey, I assume the answer to this question is "no, that's not a thing, you have to use a query", but is there any way to specify the combination of a key and a value as a unique identifier. so, only one user at a time (who I would like to have easy access to) will have ::role ::admin but many users might have ::role ::moderator. so I'd love to be able to use [::role ::admin] as an eid.

favila19:01:59

what is the difference between what you want and making ::role a unique attribute?

idiomancy19:01:54

As in a db.unique/identifier? Well the fact that for certain values of ::role, multiple distinct entities can share the same value

lilactown19:01:19

are you sure you only ever want one admin role? I don’t know your use case but almost everywhere I look that has a role-based permission system has the capability to add more than one administrator

idiomancy19:01:18

Honestly role is the wrong semantics to signal. We have a smart contract that ensures the existence of one and only one admin.

idiomancy19:01:45

But i was trying to find a way to describe that which could be general purposed

idiomancy19:01:19

Because making ::admin true a unique identifier seems weird

idiomancy19:01:03

Technically there is one admin and one 'owner' where the only thing the owner can do is assign a new admin

idiomancy19:01:17

So, its a unique value

lilactown19:01:01

could the owner and admin be the same person?

idiomancy19:01:16

Unfortunately, yes

lilactown19:01:55

sounds like the best way would be to use a bool value then IME. ::admin true ::owner true

lilactown19:01:06

for ease of querying

idiomancy19:01:10

I think youre right

idiomancy19:01:28

Thats what I was kind of landing on myself

lilactown19:01:08

sure thing! 🙂

johanatan20:01:59

Oh ok. It might be a good idea to update the rest of the documentation (linked to previously) so that people don’t continue going down this path.

johanatan20:01:33

hi, is there an env var i can check the presence for to determine if my ion is running in the cloud or locally?

johanatan20:01:44

[or some other/better way to do this?]

johanatan20:01:53

i ended up going with:

(clojure.core/string? (System/getenv "AWS_LAMBDA_FUNCTION_NAME"))
(which should work fine)

johanatan20:01:21

i am getting an error when trying to query my solo datomic instance while a process is inserting data in the bkg:

1. Unhandled clojure.lang.ExceptionInfo
   Datomic Client Exception
   {:cognitect.anomalies/category :cognitect.anomalies/busy,
    :http-result
    {:status 429,
     :headers
     {"content-length" "9",
      "server" "Jetty(9.3.7.v20160115)",
      "date" "Thu, 03 Jan 2019 20:44:43 GMT",
      "content-type" "text/plain"},
     :body nil}}
is this because my solo server can't handle the load I'm trying to place on it?

johanatan20:01:29

do i need to change it to production?

marshall20:01:18

https://docs.datomic.com/cloud/troubleshooting.html#busy @johanatan You should either retry or potentially, yes, move up to production

johnj20:01:14

solo its just a demo

johanatan20:01:35

what's the easiest way to upgrade from solo to production?

marshall20:01:41

not sure i’d categorize it as a demo lots of workloads are totally feasible on solo

marshall20:01:49

but if you need more than that - then yes, production

johanatan21:01:22

fyi.. i did a simple distribution of my load (~20 reqs spaced 250 ms apart) and it fixed my "busy" issue:

(defn- distribute-load [funcs stagger]
  (map-indexed (fn [idx itm] (mt/in (* idx stagger) itm)) funcs))

johanatan21:01:35

mt is manifold.time

johanatan21:01:53

anyone know what's going on with this?

13:49 $ clojure -A:dev -m datomic.ion.dev '{:op :push :creds-profile "personal"}'             

{:command-failed "{:op :push :creds-profile \"personal\"}",
 :causes
 ({:message
   "Bad Request (Service: Amazon S3; Status Code: 400; Error Code: 400 Bad Request; Request ID: 98AED4A6FE429CBB; S3 Extended Request ID: LsWqYlVK8gDQAwmUPwh32CFjQp6B2UCos0IDDnNGzwnxokfkPJkeJLrw4wiurwi517UY42Rho8g=)",
   :class AmazonS3Exception})}

johanatan21:01:42

somewhere i can look for additional diagnostics?

marshall21:01:22

@johanatan try explicitly adding :region

johanatan21:01:16

[and the one without :region has been working for me for the last week or so]

marshall21:01:29

what changed?

johanatan21:01:46

i added a new lambda to ion-config.edn and tweaked the code a bit. nothing drastic

marshall21:01:06

i’d check to be sure the ion-config.edn is formatted properly

johanatan21:01:29

yea, that was my thought too. i've double checked. but i'll triple check it

johanatan21:01:20

looks good to me:

{:allow [
         ;; lambda handlers
         core/load-chains
         core/volatility-skews
         ]
 :lambdas {:load-chains
           {:fn core/load-chains
            :description "Loads latest option chain data from td ameritrade into datomic."
            :timeout-secs 900}
           :volatility-skews
           {:fn core/volatility-skews
            :description "Returns any current volatility skew opportunities."
            :timeout-secs 60}
           }
 :app-name "datomic"}

johanatan21:01:33

and the code's buffer is loading fine in CIDER

marshall22:01:02

not sure what else could be responsible if your creds profile file is correct and all

johanatan22:01:16

hmm, maybe my creds have expired or something

johanatan22:01:20

i'll look into that

marshall22:01:33

you can submit an AWS support ticket with the Request ID and the extended request ID and they might be able to tell you what the actual error cause was

marshall22:01:05

using latest ion-dev and all that?

johanatan22:01:05

it could be intermittent AWS issues (but that seems unlikely)

johanatan22:01:13

yep, i have all of those versions

johanatan22:01:43

this works so the creds seem valid:

14:37 $ aws s3 --profile personal ls
2018-12-28 13:07:14 datomic-code-2025dbc4-e342-4b10-99d8-24ce8346fec1
2018-12-28 13:03:05 datomic-storagef7f305e7-ulwi6f7m5ipi-s3datomic-1xpzc6j152563
2017-05-02 19:20:12 numerai-data

johanatan23:01:17

are there additional diagnostic steps I can take? I’m not sure if I can call AWS support as this is just a personal playground account

johnj23:01:40

If I'm not wrong, you are entitled to cognitect support: https://support.cognitect.com/hc/en-us/requests/new

johnj23:01:30

ah solo doesn't have standard support https://www.datomic.com/pricing.html