Fix CI builds (#582)

master
Oleksandr Anyshchenko 3 years ago committed by GitHub
parent 86d983987e
commit 6ed14c3e34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Cargo.toml
  2. 7
      librocksdb-sys/rocksdb_lib_sources.txt
  3. 10
      src/backup.rs
  4. 16
      src/db.rs
  5. 60
      src/db_options.rs
  6. 3
      src/lib.rs
  7. 5
      src/perf.rs
  8. 2
      tests/fail/checkpoint_outlive_db.stderr
  9. 4
      tests/fail/iterator_outlive_db.stderr
  10. 8
      tests/fail/open_with_multiple_refs_as_single_threaded.stderr
  11. 4
      tests/fail/snapshot_outlive_db.stderr
  12. 14
      tests/test_db.rs
  13. 2
      tests/test_merge_operator.rs
  14. 22
      tests/test_raw_iterator.rs

@ -37,6 +37,6 @@ serde = { version = "1", features = [ "derive" ], optional = true }
[dev-dependencies] [dev-dependencies]
trybuild = "1.0" trybuild = "1.0"
tempfile = "3.1" tempfile = "3.1"
pretty_assertions = "0.7" pretty_assertions = "1.0"
bincode = "1.3" bincode = "1.3"
serde = { version = "1", features = [ "derive" ] } serde = { version = "1", features = [ "derive" ] }

@ -136,12 +136,6 @@ options/options.cc
options/options_helper.cc options/options_helper.cc
options/options_parser.cc options/options_parser.cc
port/port_posix.cc port/port_posix.cc
port/win/env_default.cc
port/win/env_win.cc
port/win/io_win.cc
port/win/port_win.cc
port/win/win_logger.cc
port/win/win_thread.cc
port/stack_trace.cc port/stack_trace.cc
table/adaptive/adaptive_table_factory.cc table/adaptive/adaptive_table_factory.cc
table/block_based/binary_search_index_reader.cc table/block_based/binary_search_index_reader.cc
@ -205,7 +199,6 @@ util/comparator.cc
util/compression_context_cache.cc util/compression_context_cache.cc
util/concurrent_task_limiter_impl.cc util/concurrent_task_limiter_impl.cc
util/crc32c.cc util/crc32c.cc
util/crc32c_arm64.cc
util/dynamic_bloom.cc util/dynamic_bloom.cc
util/hash.cc util/hash.cc
util/murmurhash.cc util/murmurhash.cc

@ -277,9 +277,8 @@ impl Default for BackupEngineOptions {
fn default() -> Self { fn default() -> Self {
unsafe { unsafe {
let opts = ffi::rocksdb_options_create(); let opts = ffi::rocksdb_options_create();
if opts.is_null() { assert!(!opts.is_null(), "Could not create RocksDB backup options");
panic!("Could not create RocksDB backup options");
}
Self { inner: opts } Self { inner: opts }
} }
} }
@ -289,9 +288,8 @@ impl Default for RestoreOptions {
fn default() -> Self { fn default() -> Self {
unsafe { unsafe {
let opts = ffi::rocksdb_restore_options_create(); let opts = ffi::rocksdb_restore_options_create();
if opts.is_null() { assert!(!opts.is_null(), "Could not create RocksDB restore options");
panic!("Could not create RocksDB restore options");
}
Self { inner: opts } Self { inner: opts }
} }
} }

@ -1330,9 +1330,9 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
ffi::rocksdb_compact_range( ffi::rocksdb_compact_range(
self.inner, self.inner,
opt_bytes_to_ptr(start), opt_bytes_to_ptr(start),
start.map_or(0, |s| s.len()) as size_t, start.map_or(0, <[u8]>::len) as size_t,
opt_bytes_to_ptr(end), opt_bytes_to_ptr(end),
end.map_or(0, |e| e.len()) as size_t, end.map_or(0, <[u8]>::len) as size_t,
); );
} }
} }
@ -1352,9 +1352,9 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
self.inner, self.inner,
opts.inner, opts.inner,
opt_bytes_to_ptr(start), opt_bytes_to_ptr(start),
start.map_or(0, |s| s.len()) as size_t, start.map_or(0, <[u8]>::len) as size_t,
opt_bytes_to_ptr(end), opt_bytes_to_ptr(end),
end.map_or(0, |e| e.len()) as size_t, end.map_or(0, <[u8]>::len) as size_t,
); );
} }
} }
@ -1375,9 +1375,9 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
self.inner, self.inner,
cf.inner(), cf.inner(),
opt_bytes_to_ptr(start), opt_bytes_to_ptr(start),
start.map_or(0, |s| s.len()) as size_t, start.map_or(0, <[u8]>::len) as size_t,
opt_bytes_to_ptr(end), opt_bytes_to_ptr(end),
end.map_or(0, |e| e.len()) as size_t, end.map_or(0, <[u8]>::len) as size_t,
); );
} }
} }
@ -1399,9 +1399,9 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
cf.inner(), cf.inner(),
opts.inner, opts.inner,
opt_bytes_to_ptr(start), opt_bytes_to_ptr(start),
start.map_or(0, |s| s.len()) as size_t, start.map_or(0, <[u8]>::len) as size_t,
opt_bytes_to_ptr(end), opt_bytes_to_ptr(end),
end.map_or(0, |e| e.len()) as size_t, end.map_or(0, <[u8]>::len) as size_t,
); );
} }
} }

@ -407,9 +407,8 @@ impl Drop for Options {
impl Clone for Options { impl Clone for Options {
fn clone(&self) -> Self { fn clone(&self) -> Self {
let inner = unsafe { ffi::rocksdb_options_create_copy(self.inner) }; let inner = unsafe { ffi::rocksdb_options_create_copy(self.inner) };
if inner.is_null() { assert!(!inner.is_null(), "Could not copy RocksDB options");
panic!("Could not copy RocksDB options");
}
Self { Self {
inner, inner,
outlive: self.outlive.clone(), outlive: self.outlive.clone(),
@ -710,9 +709,11 @@ impl BlockBasedOptions {
impl Default for BlockBasedOptions { impl Default for BlockBasedOptions {
fn default() -> Self { fn default() -> Self {
let block_opts = unsafe { ffi::rocksdb_block_based_options_create() }; let block_opts = unsafe { ffi::rocksdb_block_based_options_create() };
if block_opts.is_null() { assert!(
panic!("Could not create RocksDB block based options"); !block_opts.is_null(),
} "Could not create RocksDB block based options"
);
Self { Self {
inner: block_opts, inner: block_opts,
outlive: BlockBasedOptionsMustOutliveDB::default(), outlive: BlockBasedOptionsMustOutliveDB::default(),
@ -782,9 +783,8 @@ impl CuckooTableOptions {
impl Default for CuckooTableOptions { impl Default for CuckooTableOptions {
fn default() -> Self { fn default() -> Self {
let opts = unsafe { ffi::rocksdb_cuckoo_options_create() }; let opts = unsafe { ffi::rocksdb_cuckoo_options_create() };
if opts.is_null() { assert!(!opts.is_null(), "Could not create RocksDB cuckoo options");
panic!("Could not create RocksDB cuckoo options");
}
Self { inner: opts } Self { inner: opts }
} }
} }
@ -2951,9 +2951,8 @@ impl Default for Options {
fn default() -> Self { fn default() -> Self {
unsafe { unsafe {
let opts = ffi::rocksdb_options_create(); let opts = ffi::rocksdb_options_create();
if opts.is_null() { assert!(!opts.is_null(), "Could not create RocksDB options");
panic!("Could not create RocksDB options");
}
Self { Self {
inner: opts, inner: opts,
outlive: OptionsMustOutliveDB::default(), outlive: OptionsMustOutliveDB::default(),
@ -2989,9 +2988,11 @@ impl FlushOptions {
impl Default for FlushOptions { impl Default for FlushOptions {
fn default() -> Self { fn default() -> Self {
let flush_opts = unsafe { ffi::rocksdb_flushoptions_create() }; let flush_opts = unsafe { ffi::rocksdb_flushoptions_create() };
if flush_opts.is_null() { assert!(
panic!("Could not create RocksDB flush options"); !flush_opts.is_null(),
} "Could not create RocksDB flush options"
);
Self { inner: flush_opts } Self { inner: flush_opts }
} }
} }
@ -3077,9 +3078,11 @@ impl WriteOptions {
impl Default for WriteOptions { impl Default for WriteOptions {
fn default() -> Self { fn default() -> Self {
let write_opts = unsafe { ffi::rocksdb_writeoptions_create() }; let write_opts = unsafe { ffi::rocksdb_writeoptions_create() };
if write_opts.is_null() { assert!(
panic!("Could not create RocksDB write options"); !write_opts.is_null(),
} "Could not create RocksDB write options"
);
Self { inner: write_opts } Self { inner: write_opts }
} }
} }
@ -3456,9 +3459,11 @@ pub struct FifoCompactOptions {
impl Default for FifoCompactOptions { impl Default for FifoCompactOptions {
fn default() -> Self { fn default() -> Self {
let opts = unsafe { ffi::rocksdb_fifo_compaction_options_create() }; let opts = unsafe { ffi::rocksdb_fifo_compaction_options_create() };
if opts.is_null() { assert!(
panic!("Could not create RocksDB Fifo Compaction Options"); !opts.is_null(),
} "Could not create RocksDB Fifo Compaction Options"
);
Self { inner: opts } Self { inner: opts }
} }
} }
@ -3499,9 +3504,11 @@ pub struct UniversalCompactOptions {
impl Default for UniversalCompactOptions { impl Default for UniversalCompactOptions {
fn default() -> Self { fn default() -> Self {
let opts = unsafe { ffi::rocksdb_universal_compaction_options_create() }; let opts = unsafe { ffi::rocksdb_universal_compaction_options_create() };
if opts.is_null() { assert!(
panic!("Could not create RocksDB Universal Compaction Options"); !opts.is_null(),
} "Could not create RocksDB Universal Compaction Options"
);
Self { inner: opts } Self { inner: opts }
} }
} }
@ -3622,9 +3629,8 @@ pub struct CompactOptions {
impl Default for CompactOptions { impl Default for CompactOptions {
fn default() -> Self { fn default() -> Self {
let opts = unsafe { ffi::rocksdb_compactoptions_create() }; let opts = unsafe { ffi::rocksdb_compactoptions_create() };
if opts.is_null() { assert!(!opts.is_null(), "Could not create RocksDB Compact Options");
panic!("Could not create RocksDB Compact Options");
}
Self { inner: opts } Self { inner: opts }
} }
} }

@ -61,18 +61,15 @@
// Next lints produce too much noise/false positives. // Next lints produce too much noise/false positives.
clippy::module_name_repetitions, clippy::similar_names, clippy::must_use_candidate, clippy::module_name_repetitions, clippy::similar_names, clippy::must_use_candidate,
// '... may panic' lints. // '... may panic' lints.
clippy::indexing_slicing,
// Too much work to fix. // Too much work to fix.
clippy::missing_errors_doc, clippy::missing_errors_doc,
// False positive: WebSocket // False positive: WebSocket
clippy::doc_markdown, clippy::doc_markdown,
clippy::missing_safety_doc, clippy::missing_safety_doc,
clippy::needless_pass_by_value, clippy::needless_pass_by_value,
clippy::option_if_let_else,
clippy::ptr_as_ptr, clippy::ptr_as_ptr,
clippy::missing_panics_doc, clippy::missing_panics_doc,
clippy::from_over_into, clippy::from_over_into,
clippy::upper_case_acronyms,
)] )]
#[macro_use] #[macro_use]

@ -127,9 +127,8 @@ pub struct PerfContext {
impl Default for PerfContext { impl Default for PerfContext {
fn default() -> Self { fn default() -> Self {
let ctx = unsafe { ffi::rocksdb_perfcontext_create() }; let ctx = unsafe { ffi::rocksdb_perfcontext_create() };
if ctx.is_null() { assert!(!ctx.is_null(), "Could not create Perf Context");
panic!("Could not create Perf Context");
}
Self { inner: ctx } Self { inner: ctx }
} }
} }

@ -1,5 +1,5 @@
error[E0597]: `db` does not live long enough error[E0597]: `db` does not live long enough
--> $DIR/checkpoint_outlive_db.rs:6:25 --> tests/fail/checkpoint_outlive_db.rs:6:25
| |
4 | let _checkpoint = { 4 | let _checkpoint = {
| ----------- borrow later stored here | ----------- borrow later stored here

@ -1,10 +1,10 @@
error[E0597]: `db` does not live long enough error[E0597]: `db` does not live long enough
--> $DIR/iterator_outlive_db.rs:6:9 --> tests/fail/iterator_outlive_db.rs:6:9
| |
4 | let _iter = { 4 | let _iter = {
| ----- borrow later stored here | ----- borrow later stored here
5 | let db = DB::open_default("foo").unwrap(); 5 | let db = DB::open_default("foo").unwrap();
6 | db.iterator(IteratorMode::Start) 6 | db.iterator(IteratorMode::Start)
| ^^ borrowed value does not live long enough | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
7 | }; 7 | };
| - `db` dropped here while still borrowed | - `db` dropped here while still borrowed

@ -1,17 +1,17 @@
error[E0596]: cannot borrow `*db_ref1` as mutable, as it is behind a `&` reference error[E0596]: cannot borrow `*db_ref1` as mutable, as it is behind a `&` reference
--> $DIR/open_with_multiple_refs_as_single_threaded.rs:8:5 --> tests/fail/open_with_multiple_refs_as_single_threaded.rs:8:5
| |
5 | let db_ref1 = &db; 5 | let db_ref1 = &db;
| --- help: consider changing this to be a mutable reference: `&mut db` | --- help: consider changing this to be a mutable reference: `&mut db`
... ...
8 | db_ref1.create_cf("cf1", &opts).unwrap(); 8 | db_ref1.create_cf("cf1", &opts).unwrap();
| ^^^^^^^ `db_ref1` is a `&` reference, so the data it refers to cannot be borrowed as mutable | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `db_ref1` is a `&` reference, so the data it refers to cannot be borrowed as mutable
error[E0596]: cannot borrow `*db_ref2` as mutable, as it is behind a `&` reference error[E0596]: cannot borrow `*db_ref2` as mutable, as it is behind a `&` reference
--> $DIR/open_with_multiple_refs_as_single_threaded.rs:9:5 --> tests/fail/open_with_multiple_refs_as_single_threaded.rs:9:5
| |
6 | let db_ref2 = &db; 6 | let db_ref2 = &db;
| --- help: consider changing this to be a mutable reference: `&mut db` | --- help: consider changing this to be a mutable reference: `&mut db`
... ...
9 | db_ref2.create_cf("cf2", &opts).unwrap(); 9 | db_ref2.create_cf("cf2", &opts).unwrap();
| ^^^^^^^ `db_ref2` is a `&` reference, so the data it refers to cannot be borrowed as mutable | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `db_ref2` is a `&` reference, so the data it refers to cannot be borrowed as mutable

@ -1,10 +1,10 @@
error[E0597]: `db` does not live long enough error[E0597]: `db` does not live long enough
--> $DIR/snapshot_outlive_db.rs:6:9 --> tests/fail/snapshot_outlive_db.rs:6:9
| |
4 | let _snapshot = { 4 | let _snapshot = {
| --------- borrow later stored here | --------- borrow later stored here
5 | let db = DB::open_default("foo").unwrap(); 5 | let db = DB::open_default("foo").unwrap();
6 | db.snapshot() 6 | db.snapshot()
| ^^ borrowed value does not live long enough | ^^^^^^^^^^^^^ borrowed value does not live long enough
7 | }; 7 | };
| - `db` dropped here while still borrowed | - `db` dropped here while still borrowed

@ -979,11 +979,8 @@ fn key_may_exist() {
{ {
let db = DB::open_default(&path).unwrap(); let db = DB::open_default(&path).unwrap();
assert_eq!(false, db.key_may_exist("nonexistent")); assert!(!db.key_may_exist("nonexistent"));
assert_eq!( assert!(!db.key_may_exist_opt("nonexistent", &ReadOptions::default()));
false,
db.key_may_exist_opt("nonexistent", &ReadOptions::default())
);
} }
} }
@ -998,11 +995,8 @@ fn key_may_exist_cf() {
let db = DB::open_cf(&opts, &path, &["cf"]).unwrap(); let db = DB::open_cf(&opts, &path, &["cf"]).unwrap();
let cf = db.cf_handle("cf").unwrap(); let cf = db.cf_handle("cf").unwrap();
assert_eq!(false, db.key_may_exist_cf(&cf, "nonexistent")); assert!(!db.key_may_exist_cf(&cf, "nonexistent"));
assert_eq!( assert!(!db.key_may_exist_cf_opt(&cf, "nonexistent", &ReadOptions::default()));
false,
db.key_may_exist_cf_opt(&cf, "nonexistent", &ReadOptions::default())
);
} }
} }

@ -115,7 +115,7 @@ fn test_counting_full_merge(
operands: &MergeOperands, operands: &MergeOperands,
) -> Option<Vec<u8>> { ) -> Option<Vec<u8>> {
let mut counts = existing_val let mut counts = existing_val
.map(|v| ValueCounts::from_slice(v)) .map(ValueCounts::from_slice)
.flatten() .flatten()
.unwrap_or_default(); .unwrap_or_default();

@ -32,13 +32,13 @@ pub fn test_forwards_iteration() {
let mut iter = db.raw_iterator(); let mut iter = db.raw_iterator();
iter.seek_to_first(); iter.seek_to_first();
assert_eq!(iter.valid(), true); assert!(iter.valid());
assert_eq!(iter.key(), Some(b"k1".as_ref())); assert_eq!(iter.key(), Some(b"k1".as_ref()));
assert_eq!(iter.value(), Some(b"v1".as_ref())); assert_eq!(iter.value(), Some(b"v1".as_ref()));
iter.next(); iter.next();
assert_eq!(iter.valid(), true); assert!(iter.valid());
assert_eq!(iter.key(), Some(b"k2".as_ref())); assert_eq!(iter.key(), Some(b"k2".as_ref()));
assert_eq!(iter.value(), Some(b"v2".as_ref())); assert_eq!(iter.value(), Some(b"v2".as_ref()));
@ -46,7 +46,7 @@ pub fn test_forwards_iteration() {
iter.next(); // k4 iter.next(); // k4
iter.next(); // invalid! iter.next(); // invalid!
assert_eq!(iter.valid(), false); assert!(!iter.valid());
assert_eq!(iter.key(), None); assert_eq!(iter.key(), None);
assert_eq!(iter.value(), None); assert_eq!(iter.value(), None);
} }
@ -65,13 +65,13 @@ pub fn test_seek_last() {
let mut iter = db.raw_iterator(); let mut iter = db.raw_iterator();
iter.seek_to_last(); iter.seek_to_last();
assert_eq!(iter.valid(), true); assert!(iter.valid());
assert_eq!(iter.key(), Some(b"k4".as_ref())); assert_eq!(iter.key(), Some(b"k4".as_ref()));
assert_eq!(iter.value(), Some(b"v4".as_ref())); assert_eq!(iter.value(), Some(b"v4".as_ref()));
iter.prev(); iter.prev();
assert_eq!(iter.valid(), true); assert!(iter.valid());
assert_eq!(iter.key(), Some(b"k3".as_ref())); assert_eq!(iter.key(), Some(b"k3".as_ref()));
assert_eq!(iter.value(), Some(b"v3".as_ref())); assert_eq!(iter.value(), Some(b"v3".as_ref()));
@ -79,7 +79,7 @@ pub fn test_seek_last() {
iter.prev(); // k1 iter.prev(); // k1
iter.prev(); // invalid! iter.prev(); // invalid!
assert_eq!(iter.valid(), false); assert!(!iter.valid());
assert_eq!(iter.key(), None); assert_eq!(iter.key(), None);
assert_eq!(iter.value(), None); assert_eq!(iter.value(), None);
} }
@ -97,14 +97,14 @@ pub fn test_seek() {
let mut iter = db.raw_iterator(); let mut iter = db.raw_iterator();
iter.seek(b"k2"); iter.seek(b"k2");
assert_eq!(iter.valid(), true); assert!(iter.valid());
assert_eq!(iter.key(), Some(b"k2".as_ref())); assert_eq!(iter.key(), Some(b"k2".as_ref()));
assert_eq!(iter.value(), Some(b"v2".as_ref())); assert_eq!(iter.value(), Some(b"v2".as_ref()));
// Check it gets the next key when the key doesn't exist // Check it gets the next key when the key doesn't exist
iter.seek(b"k3"); iter.seek(b"k3");
assert_eq!(iter.valid(), true); assert!(iter.valid());
assert_eq!(iter.key(), Some(b"k4".as_ref())); assert_eq!(iter.key(), Some(b"k4".as_ref()));
assert_eq!(iter.value(), Some(b"v4".as_ref())); assert_eq!(iter.value(), Some(b"v4".as_ref()));
} }
@ -122,7 +122,7 @@ pub fn test_seek_to_nonexistant() {
let mut iter = db.raw_iterator(); let mut iter = db.raw_iterator();
iter.seek(b"k2"); iter.seek(b"k2");
assert_eq!(iter.valid(), true); assert!(iter.valid());
assert_eq!(iter.key(), Some(b"k3".as_ref())); assert_eq!(iter.key(), Some(b"k3".as_ref()));
assert_eq!(iter.value(), Some(b"v3".as_ref())); assert_eq!(iter.value(), Some(b"v3".as_ref()));
} }
@ -140,14 +140,14 @@ pub fn test_seek_for_prev() {
let mut iter = db.raw_iterator(); let mut iter = db.raw_iterator();
iter.seek(b"k2"); iter.seek(b"k2");
assert_eq!(iter.valid(), true); assert!(iter.valid());
assert_eq!(iter.key(), Some(b"k2".as_ref())); assert_eq!(iter.key(), Some(b"k2".as_ref()));
assert_eq!(iter.value(), Some(b"v2".as_ref())); assert_eq!(iter.value(), Some(b"v2".as_ref()));
// Check it gets the previous key when the key doesn't exist // Check it gets the previous key when the key doesn't exist
iter.seek_for_prev(b"k3"); iter.seek_for_prev(b"k3");
assert_eq!(iter.valid(), true); assert!(iter.valid());
assert_eq!(iter.key(), Some(b"k2".as_ref())); assert_eq!(iter.key(), Some(b"k2".as_ref()));
assert_eq!(iter.value(), Some(b"v2".as_ref())); assert_eq!(iter.value(), Some(b"v2".as_ref()));
} }

Loading…
Cancel
Save