This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-03
Channels
- # aleph (8)
- # announcements (3)
- # architecture (47)
- # babashka (22)
- # beginners (22)
- # chlorine-clover (2)
- # cider (15)
- # clj-yaml (6)
- # cljs-dev (3)
- # clojure (76)
- # clojure-austin (2)
- # clojure-europe (16)
- # clojure-france (10)
- # clojure-gamedev (11)
- # clojure-norway (28)
- # clojure-sweden (4)
- # clojurescript (32)
- # conjure (1)
- # datahike (2)
- # datomic (6)
- # events (9)
- # graalvm (8)
- # gratitude (5)
- # honeysql (8)
- # humbleui (2)
- # hyperfiddle (37)
- # jobs (1)
- # polylith (4)
- # re-frame (14)
- # releases (2)
- # rum (9)
- # sci (9)
- # scittle (8)
- # shadow-cljs (9)
- # spacemacs (4)
- # sql (10)
- # xtdb (24)
This seems like a basic question: how do I generate an UUID that is guaranteed to be a new document :xt/id?
I suspect there's no built-in way? So if I want to ensure new ids, I'll have to do it in a transaction function? Which then raises the question of how to return the generated id from the transaction? Given that multiple operations may be batched in a single transaction, how would I go about getting any returned values for the submitted transaction?
Oh, it's actually really important that you don't do anything non-deterministic, like generating UUIDs, within transaction functions. XT needs to be able to consistently replay the function and get the exact same result. Therefore you really need to generate the UUIDs externally and pass them in as parameters to the function.
I know this is overly paranoid, but collisions do happen. And separate from that, the question of how to return values from transactions, including transactions that include transaction function calls, still stands.
> but collisions do happen Sadly ID / UUID collisions can't be detected automatically, but at least you should have a history of conflicts to unpick things... I guess you could add a second UUID into the mix if you were really paranoid π
> the question of how to return values from transactions, including transactions that include transaction function calls in short you can't do this directly, due to the asynchronous processing - instead you have to store the return values under some known ID that you can then query for
You could use cuid2
for collision resistant IDs
https://github.com/hden/cuid2
Finally, how do I abort a transaction from within a transaction function call?
Oh, one more thing, does ::xt/match match only the attributes on the supplied document revision, i.e. if the stored document has attributes not specified in the document revision, will the transaction continue or abort?
The match is an exact match, so the set of keys and corresponding values must be the same. So in your case the transaction will abort
More robust compare-and-swap type semantics seems called for here, probably using Datalog query language. Is there a roadmap for this? I'm more than happy to contribute.
We don't have plans to extend the transaction primitives currently - but hopefully transaction functions give you all the leverage you need to design your ideal Datalog system on top. Note however that transaction processing is serialised so expensive Datalog queries within transaction functions will reduce the transaction throughput. If you do come up with any particularly neat patterns though it would be great to see/hear about them...and we do accept PRs π
I personally use SQUUIDs since they will be ordered by timestamp (and much nicer to search/store in a BST), then on the off chance collisions happen in the same millisecond, have a plan for retrying transactions
e.g. when creating entities, if you know a priori these entities are new and do not exist, you can use ::xt/match
to check if the eid you generated is currently nil in the document. in effect it lets you do "create if not exists"
Thanks! I figured out a retry loop with ::xt/match. And yes, SQUUIDs are way better for my use case.
Hi everyone, I'll be running a webinar on the topic of bitemporality next week (more generally, rather than specific to XTDB) - it would be great to see you there, but otherwise please make sure to sign-up anyway and then you can watch/skim the replay at 2x speed βΊοΈ https://attendee.gotowebinar.com/register/2960607012900067930?source=clojurian-slack
Hi, quick reminder that this webinar is happening in just over a couple of hours' time if you happen to find yourself available today π (or you want to catch the replay when that's out!) https://clojurians.slack.com/archives/CG3AM2F7V/p1691057919997759
Hey @U01SBSXRRH6 yes it was π the replay will be available soon! We'll be sure to email you once it's ready π
Heads up: 404 on https://docs.xtdb.com/clients/http/openapi/1.24.0. Dropping down a version works.
Hey @U02E9K53C9L thanks for the report - the CI failed for https://app.circleci.com/pipelines/github/xtdb/xtdb/3251/workflows/40764423-fbdb-4832-b5ae-55df7c3d8d3b/jobs/12940 - I'll try manually π€
I hit 're-run' on the failed workflow and it went through successfully...and your link looks fixed now :man-shrugging: CircleCI is a real mystery sometimes!
CircleCI had a temporary outage - it affected http://cljdoc.org jobs as well.
Hi, quick reminder that this webinar is happening in just over a couple of hours' time if you happen to find yourself available today π (or you want to catch the replay when that's out!) https://clojurians.slack.com/archives/CG3AM2F7V/p1691057919997759