Skip to content

Commit

Permalink
Postpone cloning the db_path
Browse files Browse the repository at this point in the history
Want access to it after the last init_wal for better errors
  • Loading branch information
rkuris committed Apr 27, 2023
1 parent 456e383 commit b599f27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion firewood/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ impl DB {
};

// recover from WAL
disk_requester.init_wal("wal", db_path);
disk_requester.init_wal("wal", &db_path);

// set up the storage layout

Expand Down
11 changes: 7 additions & 4 deletions firewood/src/storage/buffer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Disk buffer for staging in memory pages and flushing them to disk.
use std::fmt::Debug;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::rc::Rc;
use std::sync::Arc;
use std::{cell::RefCell, collections::HashMap};
Expand Down Expand Up @@ -466,9 +466,12 @@ impl DiskBufferRequester {
}

/// Initialize the WAL.
pub fn init_wal(&self, waldir: &str, rootpath: PathBuf) {
pub fn init_wal(&self, waldir: &str, rootpath: &Path) {
self.sender
.blocking_send(BufferCmd::InitWAL(rootpath, waldir.to_string()))
.blocking_send(BufferCmd::InitWAL(
rootpath.to_path_buf(),
waldir.to_string(),
))
.map_err(StoreError::Send)
.ok();
}
Expand Down Expand Up @@ -526,7 +529,7 @@ mod tests {
let state_path = file::touch_dir("state", &root_db_path).unwrap();
assert!(reset);
// create a new wal directory on top of root_db_fd
disk_requester.init_wal("wal", root_db_path);
disk_requester.init_wal("wal", &root_db_path);

// create a new state cache which tracks on disk state.
let state_cache = Rc::new(
Expand Down

0 comments on commit b599f27

Please sign in to comment.