Skip to content

fix: sync on checksum - #105

Closed
Dodecahedr0x wants to merge 3 commits into
devfrom
dode/sync-on-checksum
Closed

fix: sync on checksum#105
Dodecahedr0x wants to merge 3 commits into
devfrom
dode/sync-on-checksum

Conversation

@Dodecahedr0x

@Dodecahedr0x Dodecahedr0x commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

What changed

PersistedStore::flush only forces the LMDB index to disk on sync flushes. The env runs with NO_SYNC, so index.flush() is a full fsync (F_FULLFSYNC on macOS) whose latency grows with the dirty set; running it on every slot boundary stalled block production under write-heavy load. Async flushes now flush only the storage mmap; the index fsync and checksum update happen together at checksum boundaries.

Closes #102

Impact

Removes the per-slot fsync stall that froze block production (and cascaded into AlreadyProcessed rejections for every retried transaction) during large bursts. Durability semantics move to checksum boundaries: a crash between sync flushes can lose recent index writes, which store validation already detects on startup, same as for the storage mmap.

Reviewer notes

The invariant to check is that the checksum is only stored after the index fsync succeeds, so a persisted checksum always covers a durable index. This sits on top of #103, which touches the same file.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Review Change Stack

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dode/sync-on-checksum

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread accountsdb/src/store/mod.rs Outdated
Comment on lines +150 to +156
///
/// Only a `sync` flush forces the LMDB index to disk: the env runs with
/// `NO_SYNC`, so `index.flush()` is a full fsync whose latency grows with
/// the dirty set. Doing that on every slot boundary stalls block
/// production under write-heavy load; durability is instead established
/// at checksum boundaries, and a torn async flush is caught by
/// [`Self::validate`] on startup.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

doc: remove the heavy defensive explanation

@Dodecahedr0x
Dodecahedr0x changed the base branch from dode/prepare-empty-writable to dev August 31, 2026 08:14
@Dodecahedr0x
Dodecahedr0x force-pushed the dode/sync-on-checksum branch from a5c5a19 to 4ca9787 Compare August 31, 2026 08:17
@bmuddha
bmuddha deleted the dode/sync-on-checksum branch September 1, 2026 10:17
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.

Per-slot LMDB fsync stalls block production under write-heavy load

2 participants