Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create empty sidecars file if no sidecars before #64

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions crates/storage/provider/src/providers/static_file/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,31 @@ impl StaticFileProvider {
.unwrap_or_default()
.block_number;

if segment == StaticFileSegment::Sidecars &&
highest_static_file_block == 0 &&
checkpoint_block_number != 0
{
let range_start = find_fixed_range(checkpoint_block_number).start();

// create static file of newest block
let mut writer = StaticFileProviderRW::new(
segment,
range_start,
Arc::downgrade(&self.0),
self.metrics.clone(),
)?;

// append empty sidecars
for block_number in range_start..=checkpoint_block_number {
let hash = provider.block_hash(block_number)?.unwrap_or_default();
writer.append_sidecars(Default::default(), block_number, hash)?;
}
writer.commit()?;
self.writers.insert(segment, writer);

return Ok(None)
}

// If the checkpoint is ahead, then we lost static file data. May be data corruption.
if checkpoint_block_number > highest_static_file_block {
info!(
Expand Down
Loading