Skip to content

Conversation

patrick-ogrady
Copy link
Contributor

@patrick-ogrady patrick-ogrady commented Jul 31, 2025

If we restarted archive::immutable after unclean shutdown (and before we wrote anything), it could panic because it defaulted to an empty checkpoint if the freezer file existed (rather than just a None checkpoint).

This PR introduces a regression test and adds a fix.

@patrick-ogrady patrick-ogrady added the bug Something isn't working label Jul 31, 2025
Some(freezer) => *freezer.freezer(),
None => {
metadata.put(freezer_key.clone(), Record::Freezer(Checkpoint::default()));
*metadata.get(&freezer_key).unwrap().freezer()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we load an empty table, we shouldn't initialize the checkpoint to be the default. That makes no sense.

///
/// This can be used to restore the [Freezer] to a consistent
/// state after shutdown.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Copy, Default)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove (unsafe) defualt impl here (only use checkpoints we get)

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 an issue with unclean shutdown and restart behavior in the storage archive system by removing the Default derive from the Checkpoint struct and updating initialization logic to handle cases where no previous checkpoint exists.

  • Removes Default trait from Checkpoint to prevent automatic initialization with default values
  • Updates checkpoint initialization logic to explicitly handle the absence of stored checkpoints
  • Adds test coverage for unclean shutdown scenarios

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
storage/src/freezer/storage.rs Removes Default derive from Checkpoint and replaces Default::default() with explicit field initialization
storage/src/archive/immutable/storage.rs Simplifies checkpoint retrieval logic to return Option<Checkpoint> instead of always returning a value
storage/src/archive/immutable/mod.rs Adds comprehensive test for unclean shutdown and restart scenarios

@patrick-ogrady patrick-ogrady merged commit 486b21a into main Jul 31, 2025
34 checks passed
@patrick-ogrady patrick-ogrady deleted the archive-immutable-unclean branch July 31, 2025 19:00
Copy link

codecov bot commented Jul 31, 2025

Codecov Report

❌ Patch coverage is 98.14815% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.38%. Comparing base (868a146) to head (0968870).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
storage/src/freezer/storage.rs 90.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #1336      +/-   ##
==========================================
+ Coverage   91.37%   91.38%   +0.01%     
==========================================
  Files         251      252       +1     
  Lines       63583    63617      +34     
==========================================
+ Hits        58097    58139      +42     
+ Misses       5486     5478       -8     
Files with missing lines Coverage Δ
storage/src/archive/immutable/mod.rs 100.00% <100.00%> (ø)
storage/src/archive/immutable/storage.rs 93.88% <100.00%> (-0.11%) ⬇️
storage/src/freezer/storage.rs 92.97% <90.00%> (+1.59%) ⬆️

... and 1 file with indirect coverage changes


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 868a146...0968870. Read the comment docs.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants