Skip to content

Commit

Permalink
Fix deletion of uncommited WAL segments on recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
cswinter committed Aug 19, 2024
1 parent 9ac7b15 commit 59b45dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/disk_store/meta_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl MetaStore {
pub fn serialize(&self) -> Vec<u8> {
let mut builder = ::capnp::message::Builder::new_default();
let mut dbmeta = builder.init_root::<dbmeta_capnp::d_b_meta::Builder>();
dbmeta.set_next_wal_id(self.next_wal_id);
dbmeta.set_next_wal_id(self.earliest_uncommited_wal_id);

let total_partitions = self.partitions.values().map(|x| x.len()).sum::<usize>();
assert!(total_partitions < std::u32::MAX as usize);
Expand Down
6 changes: 3 additions & 3 deletions src/disk_store/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ impl Storage {
};

let mut wal_segments = Vec::new();
let next_wal_id = meta_store.next_wal_id;
log::info!("Recovering from wal checkpoint {}", next_wal_id);
let earliest_uncommited_wal_id = meta_store.earliest_uncommited_wal_id;
log::info!("Recovering from wal checkpoint {}", earliest_uncommited_wal_id);
let wal_files = writer.list(wal_dir).unwrap();
log::info!("Found {} wal segments", wal_files.len());
for wal_file in wal_files {
Expand All @@ -155,7 +155,7 @@ impl Storage {
wal_segment.data.tables.values().map(|t| t.len).sum::<u64>(),
wal_segment.data.tables.len(),
);
if wal_segment.id < next_wal_id {
if wal_segment.id < earliest_uncommited_wal_id {
if readonly {
log::info!("Skipping wal segment {}", wal_file.display());
} else {
Expand Down

0 comments on commit 59b45dc

Please sign in to comment.