Skip to content

Commit

Permalink
Bump rocksdb to 7.8.3 (rust-rocksdb#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksuss authored Dec 20, 2022
1 parent f5bf5ca commit b5b9e56
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 111 deletions.
25 changes: 5 additions & 20 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,10 @@ jobs:
- name: Install dependencies
if: runner.os == 'Windows'
run: choco install llvm -y
- name: Run librocksdb-sys tests
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=librocksdb-sys/Cargo.toml
- name: Run rocksdb tests (single-threaded cf)
uses: actions-rs/cargo@v1
with:
command: test
- name: Run rocksdb tests (multi-threaded cf)
uses: actions-rs/cargo@v1
env:
RUSTFLAGS: -Awarnings # Suppress "variable does not need to be mutable" warnings
with:
command: test
args: --features multi-threaded-cf
- name: Run rocksdb tests
run: |
cargo test --all
cargo test --all --features multi-threaded-cf
- name: Run rocksdb tests (jemalloc)
if: runner.os != 'Windows'
uses: actions-rs/cargo@v1
with:
command: test
args: --features jemalloc
run: cargo test --all --features jemalloc
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]

* Bump rocksdb to 7.8.3 (aleksuss)

## 0.19.0 (2022-08-05)

* Add support for building with `io_uring` on Linux (parazyd)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ serde1 = ["serde"]

[dependencies]
libc = "0.2"
librocksdb-sys = { path = "librocksdb-sys", version = "0.8.0" }
librocksdb-sys = { path = "librocksdb-sys", version = "0.9.0" }
serde = { version = "1", features = [ "derive" ], optional = true }

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions librocksdb-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "librocksdb-sys"
version = "0.8.0+7.4.4"
version = "0.9.0+7.8.3"
edition = "2018"
authors = ["Karl Hobley <[email protected]>", "Arkadiy Paronyan <[email protected]>"]
license = "MIT/Apache-2.0/BSD-3-Clause"
Expand Down Expand Up @@ -37,6 +37,6 @@ uuid = { version = "1.0", features = ["v4"] }

[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
bindgen = { version = "0.60", default-features = false, features = ["runtime"] }
bindgen = { version = "0.63", default-features = false, features = ["runtime"] }
glob = "0.3"
pkg-config = { version = "0.3", optional = true }
8 changes: 4 additions & 4 deletions librocksdb-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ fn build_rocksdb() {
}

for file in lib_sources {
config.file(&format!("rocksdb/{file}"));
config.file(format!("rocksdb/{file}"));
}

config.file("build_version.cc");
Expand Down Expand Up @@ -289,7 +289,7 @@ fn build_snappy() {

fn try_to_find_and_link_lib(lib_name: &str) -> bool {
println!("cargo:rerun-if-env-changed={}_COMPILE", lib_name);
if let Ok(v) = env::var(&format!("{}_COMPILE", lib_name)) {
if let Ok(v) = env::var(format!("{}_COMPILE", lib_name)) {
if v.to_lowercase() == "true" || v == "1" {
return false;
}
Expand All @@ -298,9 +298,9 @@ fn try_to_find_and_link_lib(lib_name: &str) -> bool {
println!("cargo:rerun-if-env-changed={}_LIB_DIR", lib_name);
println!("cargo:rerun-if-env-changed={}_STATIC", lib_name);

if let Ok(lib_dir) = env::var(&format!("{}_LIB_DIR", lib_name)) {
if let Ok(lib_dir) = env::var(format!("{}_LIB_DIR", lib_name)) {
println!("cargo:rustc-link-search=native={}", lib_dir);
let mode = match env::var_os(&format!("{}_STATIC", lib_name)) {
let mode = match env::var_os(format!("{}_STATIC", lib_name)) {
Some(_) => "static",
None => "dylib",
};
Expand Down
8 changes: 4 additions & 4 deletions librocksdb-sys/build_version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

// The build script may replace these values with real values based
// on whether or not GIT is available and the platform settings
static const std::string rocksdb_build_git_sha = "e656fa3d196c5b4c8a77255db1e6cd36a7ded348";
static const std::string rocksdb_build_git_tag = "rocksdb_build_git_tag:v7.4.4";
static const std::string rocksdb_build_git_sha = "bf2c335184de16a3cc1787fa97ef9f22f7114238";
static const std::string rocksdb_build_git_tag = "rocksdb_build_git_tag:v7.8.3";
#define HAS_GIT_CHANGES 0
#if HAS_GIT_CHANGES == 0
// If HAS_GIT_CHANGES is 0, the GIT date is used.
// Use the time the branch/tag was last modified
static const std::string rocksdb_build_date = "rocksdb_build_date:2022-07-19 08:49:59";
static const std::string rocksdb_build_date = "rocksdb_build_date:2022-11-29 06:51:03";
#else
// If HAS_GIT_CHANGES is > 0, the branch/tag has modifications.
// Use the time the build was created.
static const std::string rocksdb_build_date = "rocksdb_build_date:2022-07-19 08:49:59";
static const std::string rocksdb_build_date = "rocksdb_build_date:2022-11-29 06:51:03";
#endif

#ifndef ROCKSDB_LITE
Expand Down
2 changes: 1 addition & 1 deletion librocksdb-sys/rocksdb
Submodule rocksdb updated 613 files
11 changes: 10 additions & 1 deletion librocksdb-sys/rocksdb_lib_sources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ cache/cache.cc
cache/cache_entry_roles.cc
cache/cache_key.cc
cache/cache_reservation_manager.cc
cache/charged_cache.cc
cache/clock_cache.cc
cache/fast_lru_cache.cc
cache/lru_cache.cc
cache/compressed_secondary_cache.cc
cache/sharded_cache.cc
db/arena_wrapped_db_iter.cc
db/blob/blob_contents.cc
db/blob/blob_fetcher.cc
db/blob/blob_file_addition.cc
db/blob/blob_file_builder.cc
Expand All @@ -31,7 +33,11 @@ db/compaction/compaction_picker.cc
db/compaction/compaction_picker_fifo.cc
db/compaction/compaction_picker_level.cc
db/compaction/compaction_picker_universal.cc
db/compaction/compaction_service_job.cc
db/compaction/compaction_state.cc
db/compaction/compaction_outputs.cc
db/compaction/sst_partitioner.cc
db/compaction/subcompaction_state.cc
db/convenience.cc
db/db_filesnapshot.cc
db/db_impl/compacted_db_impl.cc
Expand Down Expand Up @@ -66,10 +72,11 @@ db/memtable_list.cc
db/merge_helper.cc
db/merge_operator.cc
db/output_validator.cc
db/periodic_work_scheduler.cc
db/periodic_task_scheduler.cc
db/range_del_aggregator.cc
db/range_tombstone_fragmenter.cc
db/repair.cc
db/seqno_to_time_mapping.cc
db/snapshot_impl.cc
db/table_cache.cc
db/table_properties_collector.cc
Expand All @@ -82,6 +89,7 @@ db/version_set.cc
db/wal_edit.cc
db/wal_manager.cc
db/wide/wide_column_serialization.cc
db/wide/wide_columns.cc
db/write_batch.cc
db/write_batch_base.cc
db/write_controller.cc
Expand Down Expand Up @@ -224,6 +232,7 @@ util/ribbon_config.cc
util/slice.cc
util/file_checksum_helper.cc
util/status.cc
util/stderr_logger.cc
util/string_util.cc
util/thread_local.cc
util/threadpool_imp.cc
Expand Down
4 changes: 2 additions & 2 deletions src/compaction_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ where
use self::Decision::{Change, Keep, Remove};

let cb = &mut *(raw_cb as *mut F);
let key = slice::from_raw_parts(raw_key as *const u8, key_length as usize);
let oldval = slice::from_raw_parts(existing_value as *const u8, value_length as usize);
let key = slice::from_raw_parts(raw_key as *const u8, key_length);
let oldval = slice::from_raw_parts(existing_value as *const u8, value_length);
let result = cb.filter(level as u32, key, oldval);
match result {
Keep => 0,
Expand Down
4 changes: 2 additions & 2 deletions src/comparator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ pub unsafe extern "C" fn compare_callback(
b_len: size_t,
) -> c_int {
let cb: &mut ComparatorCallback = &mut *(raw_cb as *mut ComparatorCallback);
let a: &[u8] = slice::from_raw_parts(a_raw as *const u8, a_len as usize);
let b: &[u8] = slice::from_raw_parts(b_raw as *const u8, b_len as usize);
let a: &[u8] = slice::from_raw_parts(a_raw as *const u8, a_len);
let b: &[u8] = slice::from_raw_parts(b_raw as *const u8, b_len);
match (cb.f)(a, b) {
Ordering::Less => -1,
Ordering::Equal => 0,
Expand Down
22 changes: 7 additions & 15 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1874,11 +1874,7 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
opts: &IngestExternalFileOptions,
paths: Vec<P>,
) -> Result<(), Error> {
let paths_v: Vec<CString> = paths
.iter()
.map(|path| to_cpath(&path))
.collect::<Result<Vec<_>, _>>()?;

let paths_v: Vec<CString> = paths.iter().map(to_cpath).collect::<Result<Vec<_>, _>>()?;
let cpaths: Vec<_> = paths_v.iter().map(|path| path.as_ptr()).collect();

self.ingest_external_file_raw(opts, &paths_v, &cpaths)
Expand All @@ -1902,11 +1898,7 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
opts: &IngestExternalFileOptions,
paths: Vec<P>,
) -> Result<(), Error> {
let paths_v: Vec<CString> = paths
.iter()
.map(|path| to_cpath(&path))
.collect::<Result<Vec<_>, _>>()?;

let paths_v: Vec<CString> = paths.iter().map(to_cpath).collect::<Result<Vec<_>, _>>()?;
let cpaths: Vec<_> = paths_v.iter().map(|path| path.as_ptr()).collect();

self.ingest_external_file_raw_cf(cf, opts, &paths_v, &cpaths)
Expand Down Expand Up @@ -1966,7 +1958,7 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
from_cstr(ffi::rocksdb_livefiles_column_family_name(files, i));
let name = from_cstr(ffi::rocksdb_livefiles_name(files, i));
let size = ffi::rocksdb_livefiles_size(files, i);
let level = ffi::rocksdb_livefiles_level(files, i) as i32;
let level = ffi::rocksdb_livefiles_level(files, i);

// get smallest key inside file
let smallest_key = ffi::rocksdb_livefiles_smallestkey(files, i, &mut key_size);
Expand Down Expand Up @@ -2083,7 +2075,7 @@ impl<I: DBInner> DBCommon<SingleThreaded, I> {
if let Some(cf) = self.cfs.cfs.remove(name) {
self.drop_column_family(cf.inner, cf)
} else {
Err(Error::new(format!("Invalid column family: {}", name)))
Err(Error::new(format!("Invalid column family: {name}")))
}
}

Expand All @@ -2110,7 +2102,7 @@ impl<I: DBInner> DBCommon<MultiThreaded, I> {
if let Some(cf) = self.cfs.cfs.write().unwrap().remove(name) {
self.drop_column_family(cf.inner, cf)
} else {
Err(Error::new(format!("Invalid column family: {}", name)))
Err(Error::new(format!("Invalid column family: {name}")))
}
}

Expand Down Expand Up @@ -2164,11 +2156,11 @@ fn convert_options(opts: &[(&str, &str)]) -> Result<Vec<(CString, CString)>, Err
.map(|(name, value)| {
let cname = match CString::new(name.as_bytes()) {
Ok(cname) => cname,
Err(e) => return Err(Error::new(format!("Invalid option name `{}`", e))),
Err(e) => return Err(Error::new(format!("Invalid option name `{e}`"))),
};
let cvalue = match CString::new(value.as_bytes()) {
Ok(cvalue) => cvalue,
Err(e) => return Err(Error::new(format!("Invalid option value: `{}`", e))),
Err(e) => return Err(Error::new(format!("Invalid option value: `{e}`"))),
};
Ok((cname, cvalue))
})
Expand Down
4 changes: 2 additions & 2 deletions src/db_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl<'a, D: DBAccess> DBRawIteratorWithThreadMode<'a, D> {
let mut key_len: size_t = 0;
let key_len_ptr: *mut size_t = &mut key_len;
let key_ptr = ffi::rocksdb_iter_key(self.inner.as_ptr(), key_len_ptr);
slice::from_raw_parts(key_ptr as *const c_uchar, key_len as usize)
slice::from_raw_parts(key_ptr as *const c_uchar, key_len)
}
}

Expand All @@ -348,7 +348,7 @@ impl<'a, D: DBAccess> DBRawIteratorWithThreadMode<'a, D> {
let mut val_len: size_t = 0;
let val_len_ptr: *mut size_t = &mut val_len;
let val_ptr = ffi::rocksdb_iter_value(self.inner.as_ptr(), val_len_ptr);
slice::from_raw_parts(val_ptr as *const c_uchar, val_len as usize)
slice::from_raw_parts(val_ptr as *const c_uchar, val_len)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/db_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl Drop for EnvWrapper {

impl Env {
/// Returns default env
pub fn default() -> Result<Self, Error> {
pub fn new() -> Result<Self, Error> {
let env = unsafe { ffi::rocksdb_create_default_env() };
if env.is_null() {
Err(Error::new("Could not create mem env".to_owned()))
Expand Down
2 changes: 1 addition & 1 deletion src/db_pinnable_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ unsafe impl<'a> Sync for DBPinnableSlice<'a> {}
impl<'a> AsRef<[u8]> for DBPinnableSlice<'a> {
fn as_ref(&self) -> &[u8] {
// Implement this via Deref so as not to repeat ourselves
&**self
self
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/merge_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub unsafe extern "C" fn delete_callback(
if !value.is_null() {
drop(Box::from_raw(slice::from_raw_parts_mut(
value as *mut u8,
value_length as usize,
value_length,
)));
}
}
Expand All @@ -114,13 +114,13 @@ pub unsafe extern "C" fn full_merge_callback<F: MergeFn, PF: MergeFn>(
) -> *mut c_char {
let cb = &mut *(raw_cb as *mut MergeOperatorCallback<F, PF>);
let operands = &MergeOperands::new(operands_list, operands_list_len, num_operands);
let key = slice::from_raw_parts(raw_key as *const u8, key_len as usize);
let key = slice::from_raw_parts(raw_key as *const u8, key_len);
let oldval = if existing_value.is_null() {
None
} else {
Some(slice::from_raw_parts(
existing_value as *const u8,
existing_value_len as usize,
existing_value_len,
))
};
(cb.full_merge_fn)(key, oldval, operands).map_or_else(
Expand Down Expand Up @@ -149,7 +149,7 @@ pub unsafe extern "C" fn partial_merge_callback<F: MergeFn, PF: MergeFn>(
) -> *mut c_char {
let cb = &mut *(raw_cb as *mut MergeOperatorCallback<F, PF>);
let operands = &MergeOperands::new(operands_list, operands_list_len, num_operands);
let key = slice::from_raw_parts(raw_key as *const u8, key_len as usize);
let key = slice::from_raw_parts(raw_key as *const u8, key_len);
(cb.partial_merge_fn)(key, None, operands).map_or_else(
|| {
*new_value_length = 0;
Expand Down Expand Up @@ -209,7 +209,7 @@ impl MergeOperands {
let spacing = mem::size_of::<*const *const u8>();
let spacing_len = mem::size_of::<*const size_t>();
let len_ptr = (base_len + (spacing_len * index)) as *const size_t;
let len = *len_ptr as usize;
let len = *len_ptr;
let ptr = base + (spacing * index);
Some(slice::from_raw_parts(
*(ptr as *const *const u8) as *const u8,
Expand Down
2 changes: 1 addition & 1 deletion src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ pub const OPTIONS_STATISTICS: &CStr = property!("options-statistics");
///
/// Expects `name` not to contain any interior NUL bytes.
unsafe fn level_property(name: &str, level: usize) -> CString {
let bytes = format!("rocksdb.{}{}\0", name, level).into_bytes();
let bytes = format!("rocksdb.{name}{level}\0").into_bytes();
// SAFETY: We’re appending terminating NUL and all our call sites pass
// a string without interior NUL bytes.
CString::from_vec_with_nul_unchecked(bytes)
Expand Down
4 changes: 2 additions & 2 deletions src/slice_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub unsafe extern "C" fn transform_callback(
dst_length: *mut size_t,
) -> *mut c_char {
let cb = &mut *(raw_cb as *mut TransformCallback);
let key = slice::from_raw_parts(raw_key as *const u8, key_len as usize);
let key = slice::from_raw_parts(raw_key as *const u8, key_len);
let prefix = (cb.transform_fn)(key);
*dst_length = prefix.len() as size_t;
prefix.as_ptr() as *mut c_char
Expand All @@ -110,6 +110,6 @@ pub unsafe extern "C" fn in_domain_callback(
key_len: size_t,
) -> c_uchar {
let cb = &mut *(raw_cb as *mut TransformCallback);
let key = slice::from_raw_parts(raw_key as *const u8, key_len as usize);
let key = slice::from_raw_parts(raw_key as *const u8, key_len);
c_uchar::from(cb.in_domain_fn.map_or(true, |in_domain| in_domain(key)))
}
2 changes: 1 addition & 1 deletion src/transactions/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<'db, DB> Transaction<'db, DB> {
None
} else {
let mut vec = vec![0; name_len];
std::ptr::copy_nonoverlapping(name as *mut u8, vec.as_mut_ptr(), name_len as usize);
std::ptr::copy_nonoverlapping(name as *mut u8, vec.as_mut_ptr(), name_len);
ffi::rocksdb_free(name as *mut c_void);
Some(vec)
}
Expand Down
Loading

0 comments on commit b5b9e56

Please sign in to comment.