This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-13
Channels
- # babashka (5)
- # beginners (55)
- # calva (24)
- # cider (11)
- # cljsrn (14)
- # clojure (55)
- # clojure-europe (9)
- # clojure-houston (1)
- # clojure-italy (1)
- # clojure-nl (7)
- # clojure-uk (38)
- # clojurescript (4)
- # code-reviews (12)
- # cursive (3)
- # datomic (86)
- # figwheel-main (14)
- # helix (10)
- # hoplon (4)
- # interceptors (1)
- # jobs (2)
- # jobs-discuss (13)
- # kaocha (5)
- # leiningen (5)
- # local-first-clojure (1)
- # luminus (2)
- # malli (27)
- # membrane (1)
- # off-topic (43)
- # pedestal (5)
- # re-frame (32)
- # reagent (22)
- # reitit (24)
- # remote-jobs (2)
- # shadow-cljs (1)
- # spacemacs (1)
- # sql (1)
- # tools-deps (32)
- # xtdb (51)
Hi, there. I have the following predicament We have a production cloud setup with over 3B datoms, and I need to "update" the whole base without interfering, or at least causing little impact as possible, to the undergoing operation. I need to transform something like:
{:ns.some-field "foo"
:ns.time{:zone "America/Sao Paulo"
:utc #inst"2020-01"}}
into:
{:ns.some-field "foo"
:ns.utc-time :utc #inst"2020-01"}
I was considering to deploy a transaction function to do that, but I wasn't so sure about not interfering with my transactor. Any advice is welcome
1. make normal operation use old and new style; 2. backfill the old style; 3. make normal operation use only new style; 4. retract the old style (optional)
if you can insert an abstraction layer between the application and the database, you could probably produce your new style on-the-fly from the old style. If so, you can cut or simplify some of these steps
Now we're trying to figure out what would be the best approach to accomplish the backfill
we tried to walk through the indexes, retrieve the old style, the transact it back, doing what we needed via :db/cas
so about 500 datoms per tx? the rule of thumb is ~1000, that may help. you can also not pipeline if you are worried about working too fast
you read the transaction log and transform it before transacting each transaction to a new db
the advantage is only that you avoid having a single db with old+new style sum of datoms
you could also perform most of it offline (writing into a dev database if you are on-prem), then backup+restore to get it into production
if you can afford it, it’s probably better to just go the way you are going now, honestly
your call, but bumping it up for a few days will probably be cheaper than the engineer time to get a decant running smoothly
finally have #datomic deployed in production. HUGE shout-out to @favila for a tremendous amount of help along the way!! thanks so much to @marshall for getting us hooked up with the license 🙂
It seems like a useful addition 🙂 I'd like to express "all entities in a card many attribute must be unique by a particular other attribute."
could you add that invariant to the attribute itself and ensure it with an attribute predicate?
Perhaps. It's not clear that enough context is passed to the predicate to be able to check something like that.
(looking at https://docs.datomic.com/cloud/schema/schema-reference.html#attribute-predicates)
Yeah, looks possible with an entity predicate. It'd be "built in" if composite tuples supported reverse lookups though 🙂
Suppose you have a composite tuple :foo+bar consisting of refs :foo and :bar from the same entity
if :_foo+bar
worked and brought you to 123, from where could you follow it, and what would the :vaet index look like?
I think I see what you're getting at but I was after something different. I see how my question was poorly worded. I'm after something like this:
[{:db/ident :user/addresses
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}
{:db/ident :address/type
:db/valueType :db.type/keyword
:db/cardinality :db.cardinality/one}
{:db/ident :address/user+type
:db/valueType :db.type/tuple
:db/tupleAttrs [:user/_addresses :address/type]
:db/cardinality :db.cardinality/one
:db/unique :db.unique/identity}]
Having multiple of the same type in this card many coll would result in undefined behavior for us. The card many must by "distinct-by" the :address/type.