r/databasedevelopment • • Oct 16 '26

Why I replaced RAMCloud-style version counters with random UUIDs (and what that doesn’t solve)

I am the RamCourt author. RamCourt grew out of my years working on RAMCloud at Stateless. RamCourt is an early-stage Rust key-value store: single node so far, with mandatory version-checks and expiry implemented, and replication and recovery not built yet. The part I most want feedback on is the last section: how to order a recreated key against its tombstone when the client-visible version is random, and whether the internal sequence should be per key or table-wide. Happy to be told where I’m wrong. Discussion thread here: https://github.com/OferMania/ramcourt-draft/discussions/7

4 Upvotes

12 comments sorted by

2

u/Fabulous-Meaning-966 Oct 22 '26

This seems to be a conversation between LLMs?

1

u/Much-Illustrator-650 Oct 24 '26

Nope. Wrote and drafted the post and replies myself, but I did use AI to help with wording. I verified any AI claims myself. I can’t speak about anyone else in the thread however. Also, the RAMCloud experience behind it is mine, from several years at Stateless.

1

u/Fabulous-Meaning-966 Oct 25 '26

Your own expertise is clear then, but that of your AI-using interlocutor is not. Maybe you should compare their answers to what you get from a frontier model at high effort?

1

u/Significant_Tune9219 Oct 17 '26

A random client-visible version cannot order a recreate against a tombstone, because nothing about a UUID says it happened later. You still need a monotonic sequence the client does not get to choose, and it should be per key. That sequence is the only thing that can say this put is after that delete of the same key. A table-wide sequence answers a different question, the order of the replication log, and using it for the tombstone check means one hot key serializes the whole table. Let the UUID be the idempotency token the client sends, and compare the tombstone on the per-key counter. A recreate has to read that counter and pick a higher one. It cannot invent the order itself.

1

u/Much-Illustrator-650 Oct 19 '26

Thanks, this is the sharpest critique so far. Agreed that a UUID can’t order anything, which is why the post keeps a separate server-assigned internal sequence for recovery ordering. Where I’m still stuck is the per-key choice: a recreate can only read the counter and pick a higher one if the deleted key’s counter still exists, so per-key means retaining state for deleted keys until no older copy can resurface, while a shared counter avoids that at the cost of one shared increment. And if replication ends up as a Raft log, recreate-after-delete is just log order, which turns the question into how large a group is. Your idempotency point is one I hadn’t covered: today a lost response followed by a retry gets a 409, and the client can’t tell whether its write applied. I’ll look at a client-id plus sequence token. How do you decide when a tombstone’s counter is safe to drop?

1

u/Significant_Tune9219 Oct 20 '26

Drop it once you can name every replica that might still present an older write for that key, and each of them has either applied something newer or is gone from the membership. If you cannot name that set, the counter is not safe to drop, which is why a lot of stores just keep the tombstone. A shared counter does not shrink that window. It only means the retained state is one number per deleted key instead of a hole in a global sequence. With a Raft group the bound is the smallest log index every current member has applied, plus any learner you still accept writes from. Past that index, a recreate cannot resurface an older put, so the per-key counter can go.

1

u/Much-Illustrator-650 Oct 24 '26

Thanks, this is the rule I was missing. I’d also had one thing backwards: I thought a table-wide counter avoided retaining per-key state, but you're right that a deleted key still needs its tombstone until that bound either way. One question: for a replica that’s been away past compaction point, do you treat it as gone from membership and force snapshot when it returns, or keep tombstones until it comes back?

1

u/Significant_Tune9219 Oct 25 '26

Treat it as gone from membership the moment you compact past its log, and do not accept its old writes when it returns. A replica that was away past the compaction point can still hold a put whose tombstone you already dropped, so letting it catch up by replaying the log is how that older write comes back. Force a snapshot of current state, then let it rejoin as a new member. Keeping every tombstone until the slowest replica returns means one machine that is off for a month sets the retention for the whole group. The membership change has to happen before the compaction, not after you notice the replica is back.

1

u/Much-Illustrator-650 Oct 25 '26

Makes sense: evict first, compact after, and a returning replica gets a snapshot and joins as new. I’ll put that in the design notes. The open question for me is picking the horizon, meaning how long a replica can be gone before eviction.

1

u/Significant_Tune9219 Oct 28 '26

I'd derive the horizon from log retention rather than picking a time out of the air. It has to be shorter than however long you keep the log, with margin, otherwise you evict a replica only after the records it would need to catch up are already gone. Then alert when a replica is at, say, half the horizon so someone fixes it before it forces a full resync.

1

u/Much-Illustrator-650 Oct 29 '26

Yeah that makes sense.