Fork me on GitHub
#datomic
<
2017-08-07
>
hmaurer10:08:41

Does d/squuid start from some seed value? and if yes, what? It seems to always generate the same uuid in my tests

jcf11:08:51

@hmaurer how many UUIDs are you generating in your tests?

jcf11:08:48

The most significant bits in a sequential UUID are a rounded timestamp so the UUID should change at least once per second regardless of any other randomness.

jcf11:08:07

> Constructs a semi-sequential UUID. Useful for creating UUIDs that don't fragment indexes. Returns a UUID whose most significant 32 bits are currentTimeMillis rounded to seconds. http://docs.datomic.com/clojure/#datomic.api/squuid

jcf11:08:31

I'm not sure exactly what Datomic does inside squuid but based on that alone I'd expect the UUID to change every second or so.

jcf11:08:55

Can you share some code, @hmaurer? So I can try to reproduce at my end. I've never seen a duplicate sequential UUID, but that's not to say it can't happen.

hmaurer11:08:58

@jcf ah nevermind, it was a mistake on my end. Sorry!

jcf11:08:19

@hmaurer no worries! Glad you've got it fixed.

souenzzo12:08:40

@hmaurer in some cases you can use this https://clojuredocs.org/clojure.core/with-redefs (Overwrite squuid with a function that always returns the same uuid)

sparkofreason16:08:42

Does anybody have suggested code or patterns for dealing with multi-tenancy, particularly on the transaction side, for instance, ensuring that the logged in customer only transacts to eid's in their partition. We have some code that does this, just curious how it compares with best practices etc.

hmaurer16:08:47

@dave.dixon do you need to run transactions across tenants? if not, you could use a database per tenant

hmaurer16:08:57

(I am new to Datomic so take everything I say with a grain of salt)

sparkofreason16:08:02

@hmaurer Cognitect recommends keeping the number of databases per transactor small, as there is overhead associated with each DB, thus the approach to put one customer per partition.

hmaurer16:08:01

TIL, thanks

hmaurer16:08:25

I think @favila is developing a multi-tenant system; he might have some insights

favila16:08:39

huh, we run multiple dbs on one transactor

favila16:08:59

we would never consider putting multiple customers on the same db

hmaurer16:08:50

@favila out of curiosity, I assume you never have to run cross-tenant transactions?

favila16:08:04

you mean like XA two-phase commit stuff? never

hmaurer16:08:02

yeah, like in the context of what I assume is your application, it would be transferring a medical record from one system to another atomically

hmaurer16:08:50

but it makes sense that you’re not doing that; I was just curious

favila16:08:19

there's no need for atomic operations across dbs

jfntn22:08:43

Is generating an or expr the right way to test whether an attribute matches one of multiple values ?

favila22:08:44

the fastest way is usually [(contains? some-set ?the-v)]

favila22:08:51

[(ground [:a :b] [?option ...]] [?e :some-attr ?option] is ok for smaller sets

favila22:08:15

should be roughly equivalent to or

sparkofreason23:08:41

@favila Can you give some idea of the number of DBs you're running on a single transactor?