Skip to content

feat: number writes with store revisions - #272

Merged
skyoo2003 merged 1 commit into
mainfrom
feat/revision-model
Oct 1, 2026
Merged

skyoo2003 merged 1 commit into
mainfrom
feat/revision-model

Conversation

@skyoo2003

@skyoo2003 skyoo2003 commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Every write that changes the keyspace now gets a revision, so callers can tell which write produced the state they see. Data directories move to format 2. Format 1 directories are upgraded in place.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactor
  • CI/CD

Changes

  • Store.Revision and Store.WriteRevision report the store's revision. A transaction is one revision however many keys it touches; a transaction that changes nothing does not advance it.
  • Entry gains CreateRevision and ModRevision. Recreating a deleted or expired key counts as a new creation.
  • The append log records revisions on set, del, and flush, and a new rev record heads every snapshot and log rewrite, so a store reopens at the revision it stopped at rather than one past whatever survived compaction. Records without revisions (format 1) load at revision 1.
  • In a cluster, a write's revision is the Raft index of the entry that carried it, so every node agrees. ApplyReplicated takes that index and ignores the leader's speculative revisions; ReplaceWith restores the snapshot's revision, including zero for an empty snapshot. SetReplicator and the FSM now return the committed revision.
  • internal/datadir: format version 2, which also reads format 1 and restamps it.
  • Docs: clustering notes on in-place upgrades and rolling upgrades; compatibility page updated for the new API.

Changelog

  • changie new fragment added — one sentence, two at most, 280 characters max
  • Not user-visible, no fragment needed

Testing

  • go test ./... passes
  • New tests added (if applicable)

New tests in pkg/kvs/revision_test.go cover revision counting, restart persistence, legacy logs, replicated revisions, and snapshot restore (including an empty snapshot). internal/cluster and internal/datadir tests cover the Raft-index revision and the format 1 to 2 upgrade.

Related Issues

None

@github-actions github-actions Bot added documentation Improvements or additions to documentation go Pull requests that update Go code labels Oct 1, 2026
@skyoo2003
skyoo2003 merged commit b470020 into main Oct 1, 2026
8 checks passed
@skyoo2003
skyoo2003 deleted the feat/revision-model branch October 1, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant