|
|
@ -9,7 +9,7 @@ |
|
|
|
)] |
|
|
|
)] |
|
|
|
|
|
|
|
|
|
|
|
use crate::storage::error::{CorruptionError, StorageError}; |
|
|
|
use crate::storage::error::{CorruptionError, StorageError}; |
|
|
|
use libc::{self, c_void, free}; |
|
|
|
use libc::{self, c_void}; |
|
|
|
use oxrocksdb_sys::*; |
|
|
|
use oxrocksdb_sys::*; |
|
|
|
use rand::random; |
|
|
|
use rand::random; |
|
|
|
use std::borrow::Borrow; |
|
|
|
use std::borrow::Borrow; |
|
|
@ -625,7 +625,7 @@ impl Db { |
|
|
|
ffi_result!(rocksdb_transaction_commit_with_status(transaction)); |
|
|
|
ffi_result!(rocksdb_transaction_commit_with_status(transaction)); |
|
|
|
rocksdb_transaction_destroy(transaction); |
|
|
|
rocksdb_transaction_destroy(transaction); |
|
|
|
rocksdb_readoptions_destroy(read_options); |
|
|
|
rocksdb_readoptions_destroy(read_options); |
|
|
|
free(snapshot as *mut c_void); |
|
|
|
rocksdb_free(snapshot as *mut c_void); |
|
|
|
r.map_err(StorageError::from)?; // We make sure to also run destructors if the commit fails
|
|
|
|
r.map_err(StorageError::from)?; // We make sure to also run destructors if the commit fails
|
|
|
|
} |
|
|
|
} |
|
|
|
return Ok(result); |
|
|
|
return Ok(result); |
|
|
@ -636,7 +636,7 @@ impl Db { |
|
|
|
ffi_result!(rocksdb_transaction_rollback_with_status(transaction)); |
|
|
|
ffi_result!(rocksdb_transaction_rollback_with_status(transaction)); |
|
|
|
rocksdb_transaction_destroy(transaction); |
|
|
|
rocksdb_transaction_destroy(transaction); |
|
|
|
rocksdb_readoptions_destroy(read_options); |
|
|
|
rocksdb_readoptions_destroy(read_options); |
|
|
|
free(snapshot as *mut c_void); |
|
|
|
rocksdb_free(snapshot as *mut c_void); |
|
|
|
r.map_err(StorageError::from)?; // We make sure to also run destructors if the commit fails
|
|
|
|
r.map_err(StorageError::from)?; // We make sure to also run destructors if the commit fails
|
|
|
|
} |
|
|
|
} |
|
|
|
// We look for the root error
|
|
|
|
// We look for the root error
|
|
|
@ -738,13 +738,14 @@ impl Db { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn flush(&self, column_family: &ColumnFamily) -> Result<(), StorageError> { |
|
|
|
pub fn flush(&self) -> Result<(), StorageError> { |
|
|
|
if let DbKind::ReadWrite(db) = &self.inner { |
|
|
|
if let DbKind::ReadWrite(db) = &self.inner { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ffi_result!(rocksdb_transactiondb_flush_cf_with_status( |
|
|
|
ffi_result!(rocksdb_transactiondb_flush_cfs_with_status( |
|
|
|
db.db, |
|
|
|
db.db, |
|
|
|
db.flush_options, |
|
|
|
db.flush_options, |
|
|
|
column_family.0, |
|
|
|
db.cf_handles.as_ptr().cast_mut(), |
|
|
|
|
|
|
|
db.cf_handles.len().try_into().unwrap() |
|
|
|
)) |
|
|
|
)) |
|
|
|
}?; |
|
|
|
}?; |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
@ -1190,7 +1191,7 @@ pub struct Buffer { |
|
|
|
impl Drop for Buffer { |
|
|
|
impl Drop for Buffer { |
|
|
|
fn drop(&mut self) { |
|
|
|
fn drop(&mut self) { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
free(self.base.cast()); |
|
|
|
rocksdb_free(self.base.cast()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1325,7 +1326,7 @@ impl Drop for ErrorStatus { |
|
|
|
fn drop(&mut self) { |
|
|
|
fn drop(&mut self) { |
|
|
|
if !self.0.string.is_null() { |
|
|
|
if !self.0.string.is_null() { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
free(self.0.string as *mut c_void); |
|
|
|
rocksdb_free(self.0.string as *mut c_void); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|