3 ms·
Something that wasn't clear to me from the README: how does this handle duplicate IDs? If I have a table with a string primary key and I insert a row in one no
by simonw 3y ago
Something that wasn't clear to me from the README: how does this handle duplicate IDs?
If I have a table with a string primary key and I insert a row in one node with ID "hello" and do the same thing (but with different column data) on another node, what happens?
- nlh 3y agoI'm not 100% sure of this but from the README section on race conditions: "the last writer will always win. This means there is NO serializability guarantee of a transaction spanning multiple tables. This is a design choice, in order to avoid any sort of global locking, and performance." So it sounds like in your example, whichever node writes last with a given primary key will be the data you'll end up with.
- dilyevsky 3y agoBased on their description of how it works with jetstream i think last insert will fail because it will see the row already exists in jetstream Within a single table they have tx serializability, just not with multiple tables
- deleted 3y ago[deleted]
- governmentdude 3y agoIn what context would you use a single string as the ID that would be subject to collisions (instead of including a user id as part of the ID)?
- simonw 3y agoPeople do all sorts of weird things with databases, and if you want to run existing software against a database (as opposed to greenfield development deliberately targeting Marmot) you need to understand what will happen in different cases.
- meepmorp 3y ago> if you want to run existing software against a database (as opposed to greenfield development deliberately targeting Marmot) you need to understand what will happen in different cases. A great point, but from the readme in the Marmot repo: > It does not require any changes to your existing SQLite application logic for reading/writing. I suspect you’re probably still right, but that’s not what the author claims.
- spenczar5 3y agoA better example might be a field that must be unique, like a URL slug. Suppose you have a database of products and the product table has a field used for URLs, like “/tshirt” and “/sweater”. You need those to be unique within the table. The question remains - how does Marmot enforce a uniqueness constraint? If you don’t like the product example, fine, but it is easy to think of others. It would be unfortunate if marmot is incapable of supporting uniqueness.
- MobiusHorizons 3y agoAs I understand it, transactions are still serialized for any given table, just not across tables. Wouldn’t that solve this uniqueness constraint issue?
- maxpert 3y agoGlad you asked the question. I never recommend use auto-incrementing IDs in production always generate one (e.g. Twitter Snowflake). With ID generators you get rid of collisions.