fix: fsync parent directory before returning that new segment file was created
parent
d5b439732d
commit
1ba0f193a9
|
@ -99,6 +99,11 @@ pub enum Error {
|
||||||
source: std::io::Error,
|
source: std::io::Error,
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
OpenSegmentDirectory {
|
||||||
|
source: std::io::Error,
|
||||||
|
path: PathBuf,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A specialized `Result` for WAL-related errors
|
/// A specialized `Result` for WAL-related errors
|
||||||
|
@ -394,8 +399,13 @@ struct OpenSegmentFile {
|
||||||
impl OpenSegmentFile {
|
impl OpenSegmentFile {
|
||||||
async fn new_in_directory(dir: impl Into<PathBuf>) -> Result<Self> {
|
async fn new_in_directory(dir: impl Into<PathBuf>) -> Result<Self> {
|
||||||
let dir = dir.into();
|
let dir = dir.into();
|
||||||
|
let dir_for_closure = dir.clone();
|
||||||
let (tx, rx) = mpsc::channel(10);
|
let (tx, rx) = mpsc::channel(10);
|
||||||
let task = tokio::task::spawn_blocking(|| Self::task_main(rx, dir));
|
let task = tokio::task::spawn_blocking(move || Self::task_main(rx, dir_for_closure));
|
||||||
|
std::fs::File::open(&dir)
|
||||||
|
.context(OpenSegmentDirectorySnafu { path: dir })?
|
||||||
|
.sync_all()
|
||||||
|
.expect("fsync failure");
|
||||||
Ok(Self { tx, task })
|
Ok(Self { tx, task })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue