xtdb

refset 2025-12-01T20:37:56.381419Z

Hey folks, v2.1.0 was released earlier today - I posted an initial write-up of the multi-database support: https://xtdb.com/blog/attach-database

🙌 5
🎉 3
chucklehead 2025-12-02T18:06:32.244049Z

I was hoping to come to office hours today, but my job had other plans...for the snapshot tokens, based on: > -- usable right away on the current connection > -- but also on a separate XTDB instance sometime later > -- (assuming there's an overlapping set of secondary databases attached) • is it right to assume the snapshot token is dependent on the ATTACHed databases for a given node? at txn start time? • for overlapping databases, given a scenario like: ◦ Node 1 serving A with B and C attached ◦ Node 2 serving C with B and D attached ◦ Node 3 serving D with C and E attached ◦ does it mean tokens from node 1 would be usable on 1 and 2, tokens from 2 would be usable on 1, 2, and 3, tokens from 3 would be usable on 2 and 3? • given above, can't assume string equality of tokens across nodes? • how do you get the token for current tx or for some historical state? i.e. is it possible to do things like INSERT|UPDATE ... RETURNING SNAPSHOT_TOKEN or SELECT *, SNAPSHOT_TOKEN FROM ... for a particular system/valid time?

refset 2025-12-02T19:59:24.852319Z

ah, well I'll make time again for drop-ins on Thursday 🙂 and great questions - I'll respond now over on Discord for visibility by non-Clojure folk, but will paste the answer here also

refset 2025-12-02T20:28:22.437709Z

is it right to assume the snapshot token is dependent on the ATTACHed databases for a given node? at txn start time? yes, that's right. and yes the token will (implicitly) change every time one of the attached databases changes (i.e. a transaction is observed by the node that affects one of those databases) - it only gets calculated whenever you run SHOW I think I need to fix the post a little as I've probably mispoken about the overlapping case 🤔 Strictly speaking the tokens are only intended to be used across nodes sharing the same primary database, and the understanding of which secondary databases are attached at any given time should be ~identical (barring some replication delays). Information about which secondary databases are attached is stored in the primary database (as a kind of catalog metadata). > can't assume string equality of tokens across nodes? ...so therefore string equality should apply. Where I think I have generated confusion: Given two distinct XTDB instances which don't share a primary (i.e. they are otherwise essentially different databases) but do both share attachment to one or more secondaries - in the event that you attempt to use a token from one instance with the other, it might produce a meaningful result, but it would generally be considered undefined behaviour. > how do you get the token for current tx or for some historical state? For historical querying you should use the SETTING DEFAULT SYSTEM_TIME ... abilities. A snapshot in XT is effectively always the state of the node 'now' - it's about the current configuration/epoch rather than the resolving of history values. The as-of querying is semantically giving you what other databases call a snapshot, but it's a bit overloaded for our needs. (but let's continue over on Discord)