tsoracle brings Spanner-style timestamp oracles to Rust, plus gapless sequences

Strictly monotonic timestamps and gapless sequences in Rust

tsoracle is an embeddable Rust service that hands out strictly monotonic timestamps and gapless sequences across a distributed system — the same kind of timestamp oracle Spanner, CockroachDB, and FoundationDB use internally. One round-trip allocates a batch of IDs, with the high-water mark fsync'd and replicated through pluggable consensus (openraft or OmniPaxos) before any ID leaves the process. get_seq() adds dense, hole-free counters per named key, though it is non-idempotent and reports ambiguous failures as SeqUncertain.

The one difference is that a gapless advance can't be un-spent, so the call is non-idempotent — an ambiguous failure is surfaced as SeqUncertain, never silently retried.
  1. lmz

    The "gapless sequence" would need some very strong guarantees from the client / caller to actually make it gapless as the caller can have its own failure after advancing the sequence. I don't think this actually does 2 phase commit, does it?

  2. hansvm

    Something seems fishy here. What am I missing?

    > no torn state

    Doesn't there exist a failure mode where you allocate from a batch, fsync that you've done that allocation, the application fails to do anything with that counter, and you thereby introduce a gap in whichever "gapless" sequence you're trying to construct? The primitive exposed here might be able to be gapless, but the API doesn't look like it'll compose nicely into creating an application with the gapless property you're trying to enforce.

    That desync between application state and tsoracle state seems more likely when you consider other features like requesting a batch of timestamps (which is necessary to hit the stated performance numbers).

    > gapless, high-throughput, monotonic

    WAT? You don't get all three of these at once with any implementation. Looking at this implementation, you (as predicted) don't get it here either. It basically uses a partitioned allocation strategy -- allocate a window to each node, each node allocates from its window (seems at first blush like a reasonably good implementation of that strategy, not knocking it, at least not without reading further). That's not both gapless and monotonic though. Absolutely nothing enforces within-window synchronization from one node to the next. You do (eventually) get gaplessness if no node is ever eventually always idle, but only because you explicitly left a hole to fill as you allocated a bigger number before sometimes filling that hole with a smaller […]

  3. LoganDark

    Do we know that this benefits from the same domain specific optimization that an organically made implementation would? Have you performed real-world comparative benchmarks? Stuff like this doesn't just come out of the blue with AI. Not saying you did a bad job, just skeptical

More from this day

2026-11-15