Fork me on GitHub
#xtdb
<
2023-03-21
>
msuess12:03:44

If I have multiple xtdb nodes using the same postgres database, how is it determined which node writes the changes to the doc(s) to the database? Ie. if I have five nodes, will each of them process the transaction and update the document (5 times)?

refset14:03:57

Hey @U0K1KAJTB it's all deterministic, so work is repeated by each node

refset14:03:10

> if I have five nodes, will each of them process the transaction and update the document (5 times)? essentially yes, except transaction functions will eventually stop being evaluated, as the resulting tx-ops 'replace' the underlying argument document

msuess13:03:18

I am asking this because I was running two nodes, one of which had a buggy tx fn that crashed. When I submitted a tx to the bug-free node I looked like it was successful. The buggy node did not have that change, obviously. Then I stopped the bug-free node, deleted its index and started it again, the change that was once successful was gone. Is this intended behaviour?

refset14:03:46

> a buggy tx fn that crashed is this with 1.23.1? which exception did you see?

msuess15:03:03

The tx fn was calling out to a function in a local namespace. I deliberately threw an exception inside that function to see how it would behave. I was using 1.23.1.

👍 2
msuess15:03:34

so the tx fn itself was just myns.core/explode

refset15:03:12

> I deliberately threw an exception any exception in particular?

msuess16:03:16

(throw (ex-info "boom" {:fail true}))

😄 2
refset18:03:10

> Is this intended behaviour? on reflection yes I believe so - after the first successful evaluation of the transaction function the node(s) will write the results back to the document store so that any subsequent nodes don't have to re-evaluate the functions (this is important for eviction) so at that point whether or not they have the buggy code is irrelevant .... until someone submits another transaction with an invocation, then the cycle will repeat (assuming the buggy node keeps being buggy)

curtosis14:03:59

Using (say) the JDBC storage model, what would the runtime requirements be on the xtdb node? Thinking here about running in a sort-of-serverless mode where it gets spun up as needed and not a full-up always-on instance? Especially for things that are read-only uses; we could constrain updates to a more controlled process gated through a single job-specific instance. Anyone using this deployment model?

refset15:03:37

Hey @U050N4M9Z spinning-up-as-needed won't be instant, and undoubtedly it gets slower as your database grows. https://docs.xtdb.com/administration/checkpointing/ is definitely helps but there is ultimately still a limit on how much that can reduce the cold start time (i.e. GBs = minutes, even with S3 in the same region). Are you using AWS? The choice of JDBC vs Kafka doesn't really affect the practicalities of node startup time.

curtosis15:03:40

For this client, yes, AWS is the preferred environment. Is that minutes with checkpointing? That probably pushes it out too far, though it might be interesting to explore something like SnapStart.

refset15:03:39

> Is that minutes with checkpointing? Yes, it comes down to S3 transfer times.

👍 2
refset15:03:46

Another option that we've not explored heavily before is using EFS/EBS

refset15:03:18

You can mount remote fs storage quite quickly

curtosis15:03:05

That’d be fastER, for sure. Might even be close to SnapStart, since that still has to restore a snapshot from (hidden) EBS.

👍 2
refset15:03:08

Cool, well, I'd be happy to help somehow and certainly very curious to hear how that goes if you do try it 🙂

👍 2
refset15:03:27

Hi folks, I'll be running a virtual meetup in just under an hour's time if anyone's free and curious - see details: https://discuss.xtdb.com/t/todays-virtual-meetup-transaction-functions-constraints/161

xt 10
clj 6
thanks3 6
brianwitte20:03:09

thanks again, sir. great stuff

🙏 2
hadils19:03:14

Hi! I would like to implement auto-increment xt/id in XTDB. Any suggestions?

refset21:03:47

Hey @UGNMGFJG3 you could use a transaction function for this (see the 'counter' example in the docs for inspiration), but before blindly recommending that...how come you want to use an auto-incrementing ID and not a UUID?

hadils22:03:09

For order numbers I want to use something the people find easy to read.

👍 2
refset12:03:11

That seems like a fair use case. I don't know what the ideal tradeoff would be or what the state-of-the-art is for helping end users work with UUIDs :thinking_face:

tatut15:03:30

do you need like a “tracking reference” that people need to type/paste in? or why does readability matter… sequences always require coordination which slows things down, but you can always create fresh uuids without needing coordination

hadils16:03:36

It appears on their billing statement so I would an easy to read identifier.

tatut17:03:45

You could also have a uuid doc id and another attribute that generates successive ids, but perhaps thats just kicking the can down the road

jmerrifield17:03:39

I have a few identifiers that I wanted to be human-readable so I've been generating a random sequence of alphanumeric characters with a uniqueness check, just did some rough calculations to make sure my random string is long enough to make collisions very very unlikely with the amount of traffic I expect. Might work for you?

hadils18:03:38

I can use ULID.

👍 2