Skip to content

Conversation

roberto-bayardo
Copy link
Collaborator

@roberto-bayardo roberto-bayardo commented Aug 30, 2025

(1) We were incorrectly assuming journal rewind() and mmr.pop() were "sticky" operations, but in fact they aren't sticky until sync is called. This PR makes pop() sticky, and calls sync() where appropriate after rewinding.

(2) The journaled MMR's sync() operation was returning immediately when size == 0, which was preventing the syncing of a rewind to offset 0. Removed the size == 0 check, and added a regression test for this scenario.

Rewind documentation is updated to clearly state its properties.

@roberto-bayardo roberto-bayardo marked this pull request as ready for review August 30, 2025 17:07
@roberto-bayardo roberto-bayardo requested review from Copilot and patrick-ogrady and removed request for patrick-ogrady August 30, 2025 17:07
Copilot

This comment was marked as outdated.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes critical bugs related to journal rewind operations not being persistent until synced to disk. The changes ensure that rewind operations are properly persisted by calling sync() after rewinding, and removes a premature early return in the MMR sync method that prevented syncing when size is 0.

  • Makes journal rewind operations persistent by calling sync() after rewind operations across the codebase
  • Removes early return in MMR sync() when size == 0 to allow proper syncing of rewinds to offset 0
  • Adds comprehensive documentation warnings about rewind operations not being guaranteed to survive restarts until sync is called

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
storage/src/store/mod.rs Adds sync() call after locations journal rewind
storage/src/mmr/journaled.rs Removes early return in sync() method and adds sync() calls after rewind operations
storage/src/journal/variable.rs Adds documentation warnings about rewind persistence requirements
storage/src/journal/fixed.rs Updates documentation to clarify rewind persistence behavior
storage/src/freezer/storage.rs Adds sync() call after journal rewind operation
storage/src/adb/keyless.rs Adds multiple sync() calls after rewind operations
storage/src/adb/immutable/mod.rs Adds sync() calls after locations rewind operations
storage/src/adb/any/variable/mod.rs Adds sync() calls after locations rewind operations
storage/src/adb/any/fixed/sync.rs Adds sync() call after journal rewind operation
storage/src/adb/any/fixed/mod.rs Adds sync() call after log rewind operation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

self.journal.rewind(new_size).await?;
self.journal.sync().await?;
Copy link
Contributor

Choose a reason for hiding this comment

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

I was going to comment that we may not want to call sync "per pop" but it looks like it already takes a number to walk back, so looks good 👍

@patrick-ogrady patrick-ogrady merged commit a7848b5 into main Aug 30, 2025
37 checks passed
@patrick-ogrady patrick-ogrady deleted the fix-rewind-bugs branch August 30, 2025 21:57
Copy link

codecov bot commented Aug 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.06%. Comparing base (9dd9e2d) to head (e04ac7f).
⚠️ Report is 1 commits behind head on main.

@@           Coverage Diff           @@
##             main    #1521   +/-   ##
=======================================
  Coverage   92.06%   92.06%           
=======================================
  Files         283      283           
  Lines       73159    73182   +23     
=======================================
+ Hits        67355    67378   +23     
  Misses       5804     5804           
Files with missing lines Coverage Δ
storage/src/adb/any/fixed/mod.rs 98.10% <100.00%> (+<0.01%) ⬆️
storage/src/adb/any/fixed/sync.rs 98.77% <100.00%> (+<0.01%) ⬆️
storage/src/adb/any/variable/mod.rs 95.39% <100.00%> (+0.01%) ⬆️
storage/src/adb/immutable/mod.rs 95.44% <100.00%> (+0.01%) ⬆️
storage/src/adb/keyless.rs 93.87% <100.00%> (+0.06%) ⬆️
storage/src/freezer/storage.rs 92.44% <100.00%> (+0.01%) ⬆️
storage/src/journal/fixed.rs 97.60% <ø> (ø)
storage/src/journal/variable.rs 94.66% <ø> (ø)
storage/src/mmr/journaled.rs 98.85% <100.00%> (+0.01%) ⬆️
storage/src/store/mod.rs 95.13% <100.00%> (+<0.01%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9dd9e2d...e04ac7f. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@patrick-ogrady patrick-ogrady linked an issue Sep 2, 2025 that may be closed by this pull request
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.

[storage/adb] Optimize Commit Latency

2 participants