datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
daniel.spaniel 2020-11-27T09:24:44.018400Z

I am trying to set up a composite tuple index for lets say an account entity and I am doing this ( which is like something straight out of the docs )

{:db/ident       :account/company+number
 :db/valueType   :db.type/tuple
 :db/tupleAttrs  [:account/company :account/number]
 :db/cardinality :db.cardinality/one
 :db/unique      :db.unique/value
 }
where the account/company is a ref and the account/number is a long. the problem is that the account/number value (that datomic is filling in) is always -> nil. it seems like this tuple will be filled in by datomic correctly when the attrs are anything BUT ref and something else. if i do keyword and long its fine, but ref and anything else does not work. is this a known issue ?

souenzzo 2020-11-27T12:22:35.018700Z

I tryied to reproduce this issue here https://gist.github.com/souenzzo/3ba161909006ef08d53ac63a1d622fa2 But I can't understand where you are seeing this nil

tvaughan 2020-11-27T12:25:42.019800Z

@jeroen.dejong I was hoping to hear something like this. Can you share any more details? An example maybe?

2020-11-27T12:34:58.020Z

Basically we created a 2 (internal) libraries. 1 for monitoring the tx-log, and updating those values into ES. The other exposes some search functions (uses spandex to perform a query). We put that library on the classpath of our peer server. Which allows the client to use the functions in our internal library to be used in datalog:

{:query '{:find [?e] 
          :where [(ourthing/search ?client ?search-term) [?e ...]]
          :in [$ ?client ?search-term]}
 :args [(d/db ...), {:hosts ["<http://127.0.0.1:9200>"]}, "Hello world!"]}
In order to get this to work we built a second (internal) library which monitors the tx log, and updates ES indexes for any attributes we're interested in searching.

2020-11-27T12:35:21.020200Z

Most of this is very much WIP, but as far as I can tell right now it's a very viable solution.

tvaughan 2020-11-27T12:46:27.020700Z

Nice! Thanks for sharing this!

daniel.spaniel 2020-11-27T12:52:22.020900Z

i am going to run this gist in my db and see if i can alter it to show good reproduction of issue

1๐Ÿ‘
daniel.spaniel 2020-11-27T13:17:09.021200Z

this does work on my db so that was interesting. thanks. i now have to correlate this with my schema and see what is different. Muchos thanks again!

jcf 2020-11-27T14:35:59.023900Z

Is anyone here using AssumeRole/STS to delegate access to sub-accounts in AWS, and successfully connecting to a running Datomic system with the Datomic CLI?

./datomic cloud list-systems --profile example-dev
WARNING: When invoking clojure.main, use -M
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Execution error (ExceptionInfo) at datomic.tools.ops.aws/invoke! (aws.clj:83).
AWS Error: Unable to fetch credentials. See log for more details.
Running aws --profile example-dev s3 ls works as expected so I think this might be a problem in the Datomic CLI side of things. My ~/.aws/config looks good to me:
[profile example]
region=eu-west-2

[profile example-dev]
role_arn=arn:aws:iam::111111111111:role/developer
source_profile=example
Credentials should be inherited from the example profileโ€ฆ the AWS CLI appears to get this right so I think my ~/.aws stuff is kosher.

jcf 2020-11-27T14:37:06.024Z

I vaguely remember a problem with some Datomic tooling and use of assumed roles. The workaround was to juggle your AWS config about so you're not using profiles but this won't work here as I have to STS my way into the sub account. No direct access possible.

jcf 2020-11-27T14:41:41.024200Z

I've added the SSH ingress rule to the bastion security group, and I've attached the Datomic Admin policy to the role that gets assumed when you switch into the sub-account.

jcf 2020-11-27T14:42:46.024400Z

I don't know what the "log" is that the error refers to. I've seen that in cognitect-labs/aws-api too and didn't know what log was being referred to there either. ๐Ÿ™ˆ

daniel.spaniel 2020-11-27T16:39:46.024700Z

i found the problem .. we are doing this

{:db/ident       :accounting-category/company+number
                           :db/valueType   :db.type/tuple
                           :db/tupleAttrs  [:entity/company :accounting-category/number]
                           :db/cardinality :db.cardinality/one
                           :db/unique      :db.unique/value
                           }

daniel.spaniel 2020-11-27T16:40:00.024900Z

and this attribute entity/company is shared with other entities.

daniel.spaniel 2020-11-27T16:40:17.025100Z

seems like datomic trying to make this tuple for any entity with that attirbute and not just accounting-category entity

daniel.spaniel 2020-11-27T16:48:35.025300Z

is there a way to stop that and only make this constraint tuple when this exact entity is created / edited ?

steveb8n 2020-11-27T21:14:35.025500Z

@joshkh this lib does exactly what you want but not yet for cloud https://github.com/vvvvalvalval/datomock/issues/6

joshkh 2020-11-27T21:22:24.025800Z

thanks for sharing. i'm sticking to dev-local as being the "official" solution at the moment, and starting from a cloud db (whether remote or imported locally) is a must. no on-prem for me ๐Ÿ™‚