Commit 4838a968 authored by zhangjinpeng1987's avatar zhangjinpeng1987 Committed by Huachao Huang

sync wal before close (#189)

parent f57f6731
......@@ -82,6 +82,7 @@ pub struct DB {
path: String,
opts: DBOptions,
_cf_opts: Vec<ColumnFamilyOptions>,
readonly: bool,
}
impl Debug for DB {
......@@ -433,6 +434,11 @@ impl DB {
.map(|x| x.inner as *const crocksdb_ffi::Options)
.collect();
let readonly = if error_if_log_file_exist.is_some() {
true
} else {
false
};
let db = {
let db_options = opts.inner;
let db_path = cpath.as_ptr();
......@@ -484,6 +490,7 @@ impl DB {
path: path.to_owned(),
opts: opts,
_cf_opts: options,
readonly: readonly,
})
}
......@@ -1518,6 +1525,10 @@ impl Drop for WriteBatch {
impl Drop for DB {
fn drop(&mut self) {
// SyncWAL before call close.
if !self.readonly {
self.sync_wal().unwrap();
}
unsafe {
self.cfs.clear();
crocksdb_ffi::crocksdb_close(self.inner);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment