Skip to content

Log sequence tracking RFC - #18

Merged
hachikuji merged 3 commits into
mainfrom
sequence-tracking-rfc
Jan 6, 2026
Merged

Log sequence tracking RFC#18
hachikuji merged 3 commits into
mainfrom
sequence-tracking-rfc

Conversation

@hachikuji

Copy link
Copy Markdown
Contributor

The initial log RFC is vague about sequence number tracking. This patch suggests a block-based approach implemented on top of SlateDb.

Comment thread log/rfcs/0001-storage.md

If SlateDB supports multi-writer in the future, each writer would maintain its own sequence counter. This design assumes each key would still have a single writer—interleaving appends from multiple writers to the same key would break monotonic ordering within that key's log.

#### Block-Based Sequence Allocation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why we don't use the sequence number maintained by Slate itself? I believe we want to expose that anyway (see slatedb/slatedb#1138 (comment) - it's pretty deep in there but the proposal is good)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah! just saw your comment at the bottom. yeah that makes sense to me as an interim thing, we might want to just prioritize the slate ticket thought

@agavra agavra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though I think we should consider prioritizing the SlateDB change to expose the internal seqnum

@hachikuji

Copy link
Copy Markdown
Contributor Author

@agavra To be honest, I'm on the fence about exposing the sequence number in SlateDb. I guess my concern is how it ties down the implementation for the future. Perhaps as long as it works within a multi-writer context, it's fine. And maybe we have to do it anyway for some use cases. I'll read the thread and try to get a better read on it.

@apurvam apurvam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I agree with almog's comment about prioritizing generalizing and reusing the slateDB sequence number if it is already playing a similar role. That would be in the spirit of the substrate.

@criccomini

Copy link
Copy Markdown

LGTM, though I think we should consider prioritizing the SlateDB change to expose the internal seqnum

I have been wanting to do this for a long time but never got around to it. If you guys want to PR it, that'd be 🔥 .

@hachikuji

Copy link
Copy Markdown
Contributor Author

I looked at the suggestion in the comment here: slatedb/slatedb#1138 (comment). The API looks reasonable to me (I'll see if I can pick it up since I've been looking for some slatedb work), but it wouldn't solve our problem here. We need the sequence number to be embedded in the key, which means we need to know what the sequence number will be before writing. Getting keys to align with writes seems a little slippery to me. There is also a benefit to decoupling the two. The nice thing about the LSM representation is that it would be possible to overwrite a bad record. That wouldn't be possible anymore if we were tied to the internal sequence number.

@agavra

agavra commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

We need the sequence number to be embedded in the key, which means we need to know what the sequence number will be before writing.

🤦 yes... that makes sense to me. Though FWIW this could be a use case for decoupling the WAL and WAL compactors in Rohan's terminology. You know the seqnum when its inserted into the WAL, we could then transform that into a full key when it's written to L0 using the sequence number.

Anyway, I'm OK decoupling the two. I imagine it will make things easier in the long run.

@hachikuji
hachikuji merged commit ccf101e into main Jan 6, 2026
1 check passed
@hachikuji
hachikuji deleted the sequence-tracking-rfc branch January 6, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants