Skip to content

Commit dde06f4

Browse files
authored
Merge branch 'master' into zaidoon/0.22.6
2 parents 5dbdee9 + 333f73c commit dde06f4

24 files changed

+553
-247
lines changed

.github/workflows/audit.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Security Audit
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- "**/Cargo.toml"
9+
schedule:
10+
- cron: "0 2 * * *" # run at 2 AM UTC
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
security-audit:
17+
permissions:
18+
checks: write # for rustsec/audit-check to create check
19+
contents: read # for actions/checkout to fetch code
20+
issues: write # for rustsec/audit-check to create issues
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Audit Check
26+
# https://github.com/rustsec/audit-check/issues/2
27+
uses: rustsec/audit-check@master
28+
with:
29+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/rust.yml

+14-42
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,60 @@
11
name: RocksDB CI
22

33
on: [push, pull_request]
4-
env:
5-
RUST_VERSION: 1.75.0
64

75
jobs:
86
style:
97
name: Rustfmt
108
runs-on: ubuntu-latest
119
steps:
1210
- name: Checkout sources
13-
uses: actions/checkout@v2
11+
uses: actions/checkout@v4
1412

1513
- name: Install rust
16-
uses: actions-rs/toolchain@v1
14+
uses: dtolnay/rust-toolchain@stable
1715
with:
18-
toolchain: ${{ env.RUST_VERSION }}
1916
components: rustfmt
20-
profile: minimal
21-
override: true
2217

2318
- name: Run rustfmt
24-
uses: actions-rs/cargo@v1
25-
with:
26-
command: fmt
27-
args: --all -- --check
19+
run: cargo fmt --all -- --check
2820

2921
doc-check:
3022
name: Rustdoc-check
3123
runs-on: ubuntu-latest
3224
steps:
3325
- name: Checkout sources
34-
uses: actions/checkout@v2
26+
uses: actions/checkout@v4
3527

3628
- name: Install rust
37-
uses: actions-rs/toolchain@v1
29+
uses: dtolnay/rust-toolchain@stable
3830
with:
39-
toolchain: ${{ env.RUST_VERSION }}
4031
components: rust-docs
41-
profile: minimal
42-
override: true
4332

4433
- name: Run cargo rustdoc
45-
uses: actions-rs/cargo@v1
46-
with:
47-
command: rustdoc
48-
args: -- -D warnings
34+
run: cargo rustdoc -- -D warnings
4935

5036
clippy:
5137
name: Clippy
5238
runs-on: ubuntu-latest
5339
steps:
5440
- name: Checkout sources
55-
uses: actions/checkout@v2
41+
uses: actions/checkout@v4
5642

5743
- name: Install rust
58-
uses: actions-rs/toolchain@v1
44+
uses: dtolnay/rust-toolchain@stable
5945
with:
60-
toolchain: ${{ env.RUST_VERSION }}
6146
components: clippy
62-
profile: minimal
63-
override: true
6447

6548
- name: Run clippy
66-
uses: actions-rs/clippy-check@v1
67-
with:
68-
token: ${{ secrets.GITHUB_TOKEN }}
69-
args: --all-targets -- -D warnings
49+
run: cargo clippy --all --all-targets -- -Dwarnings
7050

7151
audit:
7252
name: Security audit
7353
runs-on: ubuntu-latest
7454
steps:
75-
- uses: actions/checkout@v2
76-
- uses: actions-rs/audit-check@v1
55+
- uses: actions/checkout@v4
56+
# https://github.com/rustsec/audit-check/issues/2
57+
- uses: rustsec/audit-check@master
7758
with:
7859
token: ${{ secrets.GITHUB_TOKEN }}
7960

@@ -92,15 +73,10 @@ jobs:
9273
os: windows-latest
9374
steps:
9475
- name: Checkout sources
95-
uses: actions/checkout@v2
76+
uses: actions/checkout@v4
9677

9778
- name: Install rust
98-
uses: actions-rs/toolchain@v1
99-
with:
100-
toolchain: ${{ env.RUST_VERSION }}
101-
target: ${{ matrix.target }}
102-
profile: minimal
103-
override: true
79+
uses: dtolnay/rust-toolchain@stable
10480

10581
- name: Remove msys64 # Workaround to resolve link error with C:\msys64\mingw64\bin\libclang.dll
10682
if: runner.os == 'Windows'
@@ -109,10 +85,6 @@ jobs:
10985
- name: Install dependencies
11086
if: runner.os == 'Windows'
11187
run: choco install llvm -y
112-
113-
- name: Install dependencies (Linux)
114-
if: runner.os == 'Linux'
115-
run: sudo apt-get install libjemalloc-dev
11688

11789
- name: Run rocksdb tests
11890
run: |

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

33
## [Unreleased]
4+
* Document that `default` column family doesn't inherit open options of db (
5+
0xdeafbeef)
46

57
## 0.22.4 (2024-02-20)
68

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ zstd = ["rust-librocksdb-sys/zstd"]
2929
zlib = ["rust-librocksdb-sys/zlib"]
3030
bzip2 = ["rust-librocksdb-sys/bzip2"]
3131
rtti = ["rust-librocksdb-sys/rtti"]
32+
mt_static = ["rust-librocksdb-sys/mt_static"]
3233
multi-threaded-cf = []
3334
serde1 = ["serde"]
3435
malloc-usable-size = ["rust-librocksdb-sys/malloc-usable-size"]
3536

3637
[dependencies]
3738
libc = "0.2"
38-
rust-librocksdb-sys = { path = "librocksdb-sys", version = "0.18.0" }
39+
rust-librocksdb-sys = { path = "librocksdb-sys", version = "0.22.0" }
3940
serde = { version = "1", features = ["derive"], optional = true }
4041

4142
[dev-dependencies]

README.md

+38-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ compression submodules:
3737
git submodule update --init --recursive
3838
```
3939

40-
## Compression Support
40+
## Features
41+
42+
### Compression Support
4143

4244
By default, support for [Snappy](https://github.com/google/snappy),
4345
[LZ4](https://github.com/lz4/lz4), [Zstd](https://github.com/facebook/zstd),
@@ -53,11 +55,45 @@ default-features = false
5355
features = ["lz4"]
5456
```
5557

56-
## Multithreaded ColumnFamily alternation
58+
### Multithreaded ColumnFamily alternation
5759

5860
RocksDB allows column families to be created and dropped
5961
from multiple threads concurrently, but this crate doesn't allow it by default
6062
for compatibility. If you need to modify column families concurrently, enable
6163
the crate feature `multi-threaded-cf`, which makes this binding's
6264
data structures use `RwLock` by default. Alternatively, you can directly create
6365
`DBWithThreadMode<MultiThreaded>` without enabling the crate feature.
66+
67+
### Switch between /MT or /MD run time library (Only for Windows)
68+
69+
The feature `mt_static` will request the library to be built with [/MT](https://learn.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-170)
70+
flag, which results in library using the static version of the run-time library.
71+
*This can be useful in case there's a conflict in the dependecy tree between different
72+
run-time versions.*
73+
74+
### Jemalloc
75+
76+
The feature `jemalloc` will enable the
77+
`unprefixed_malloc_on_supported_platforms` feature of `tikv-jemalloc-sys`,
78+
hooking the actual malloc and free, so jemalloc is used to allocate memory. On
79+
Supported platforms such as Linux, Rocksdb will also be properly informed that
80+
Jemalloc is enabled so that it can apply internal optimizations gated behind
81+
Jemalloc being enabled. On [unsupported
82+
platforms](https://github.com/zaidoon1/rust-rocksdb/blob/master/librocksdb-sys/build.rs#L4-L7),
83+
Rocksdb won't be properly
84+
informed that Jemalloc is being used so some internal optimizations are skipped
85+
BUT you will still get the benefits of Jemalloc memory allocation. Note that by
86+
default, Rust uses libc malloc on Linux which is known to have more memory
87+
fragmentation than Jemalloc especially with Rocksdb. See [github
88+
issue](https://github.com/facebook/rocksdb/issues/12364) for more information.
89+
In general, I highly suggest enabling Jemalloc unless there is a specific reason
90+
not to (your system doesn't support it, etc.)
91+
92+
### Malloc Usable Size
93+
94+
The feature `malloc-usable-size` will inform Rocksdb that malloc_usable_size is
95+
supported by the platform and is necessary if you want to use the
96+
`optimize_filters_for_memory` rocksdb feature as this feature is gated behind
97+
malloc_usable_size being available. See
98+
[rocksdb](https://github.com/facebook/rocksdb/blob/v9.0.0/include/rocksdb/table.h#L401-L434)
99+
for more information on the feature.

librocksdb-sys/Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rust-librocksdb-sys"
3-
version = "0.18.0+8.11.3"
3+
version = "0.22.0+9.2.1"
44
edition = "2021"
55
rust-version = "1.75.0"
66
authors = [
@@ -29,8 +29,9 @@ exclude = [
2929

3030
[features]
3131
default = ["static"]
32-
jemalloc = ["tikv-jemalloc-sys", "pkg-config"]
32+
jemalloc = ["tikv-jemalloc-sys"]
3333
static = ["libz-sys?/static", "bzip2-sys?/static"]
34+
mt_static = []
3435
io-uring = ["pkg-config"]
3536
snappy = []
3637
lz4 = ["lz4-sys"]
@@ -51,7 +52,7 @@ libz-sys = { version = "1.1", default-features = false, optional = true }
5152
bzip2-sys = { version = "0.1", default-features = false, optional = true }
5253

5354
[dev-dependencies]
54-
const-cstr = "0.3"
55+
const-str = "0.5"
5556
uuid = { version = "1", features = ["v4"] }
5657

5758
[build-dependencies]

librocksdb-sys/build.rs

+20-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
use std::path::Path;
22
use std::{env, fs, path::PathBuf, process::Command};
33

4+
// On these platforms jemalloc-sys will use a prefixed jemalloc which cannot be linked together
5+
// with RocksDB.
6+
// See https://github.com/tikv/jemallocator/blob/tikv-jemalloc-sys-0.5.3/jemalloc-sys/src/env.rs#L25
7+
const NO_JEMALLOC_TARGETS: &[&str] = &["android", "dragonfly", "musl", "darwin"];
8+
49
fn link(name: &str, bundled: bool) {
510
use std::env::var;
611
let target = var("TARGET").unwrap();
@@ -218,18 +223,11 @@ fn build_rocksdb() {
218223

219224
config.define("ROCKSDB_SUPPORT_THREAD_LOCAL", None);
220225

221-
#[cfg(feature = "jemalloc")]
222-
{
223-
if target.contains("linux") {
224-
pkg_config::probe_library("jemalloc")
225-
.expect("The jemalloc feature was requested but jemalloc is not installed");
226-
config.define("ROCKSDB_JEMALLOC", Some("1"));
227-
config.define("JEMALLOC_NO_DEMANGLE", Some("1"));
228-
} else {
229-
// this doesn't actually enable jemalloc, but mac/windows needs more
230-
// work to make it work (statically link tikv-jemalloc). For now,
231-
// I'll keep this as is.
232-
config.define("WITH_JEMALLOC", "ON");
226+
if cfg!(feature = "jemalloc") && NO_JEMALLOC_TARGETS.iter().all(|i| !target.contains(i)) {
227+
config.define("ROCKSDB_JEMALLOC", Some("1"));
228+
config.define("JEMALLOC_NO_DEMANGLE", Some("1"));
229+
if let Some(jemalloc_root) = env::var_os("DEP_JEMALLOC_ROOT") {
230+
config.include(Path::new(&jemalloc_root).join("include"));
233231
}
234232
}
235233

@@ -246,6 +244,9 @@ fn build_rocksdb() {
246244
}
247245

248246
if target.contains("msvc") {
247+
if cfg!(feature = "mt_static") {
248+
config.static_crt(true);
249+
}
249250
config.flag("-EHsc");
250251
config.flag("-std:c++17");
251252
} else {
@@ -261,7 +262,10 @@ fn build_rocksdb() {
261262
config.flag("-Wno-strict-aliasing");
262263
config.flag("-Wno-invalid-offsetof");
263264
}
264-
265+
if target.contains("riscv64gc") {
266+
// link libatomic required to build for riscv64gc
267+
println!("cargo:rustc-link-lib=atomic");
268+
}
265269
for file in lib_sources {
266270
config.file(format!("rocksdb/{file}"));
267271
}
@@ -285,6 +289,9 @@ fn build_snappy() {
285289

286290
if target.contains("msvc") {
287291
config.flag("-EHsc");
292+
if cfg!(feature = "mt_static") {
293+
config.static_crt(true);
294+
}
288295
} else {
289296
// Snappy requires C++11.
290297
// See: https://github.com/google/snappy/blob/master/CMakeLists.txt#L32-L38

librocksdb-sys/build_version.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88

99
// The build script may replace these values with real values based
1010
// on whether or not GIT is available and the platform settings
11-
static const std::string rocksdb_build_git_sha = "c2467b141e840fdba5b3a1810763043e56449fb9";
12-
static const std::string rocksdb_build_git_tag = "rocksdb_build_git_tag:v8.11.3";
11+
static const std::string rocksdb_build_git_sha = "08f93221f50700f19f11555fb46abfe708a716d1";
12+
static const std::string rocksdb_build_git_tag = "rocksdb_build_git_tag:v9.2.1";
1313
#define HAS_GIT_CHANGES 0
1414
#if HAS_GIT_CHANGES == 0
1515
// If HAS_GIT_CHANGES is 0, the GIT date is used.
1616
// Use the time the branch/tag was last modified
17-
static const std::string rocksdb_build_date = "rocksdb_build_date:2024-02-27 16:24:11";
17+
static const std::string rocksdb_build_date = "rocksdb_build_date:2024-05-08 16:03:15";
1818
#else
1919
// If HAS_GIT_CHANGES is > 0, the branch/tag has modifications.
2020
// Use the time the build was created.
21-
static const std::string rocksdb_build_date = "rocksdb_build_date:2024-02-27 16:24:11";
21+
static const std::string rocksdb_build_date = "rocksdb_build_date:2024-05-08 16:03:15";
2222
#endif
2323

2424
std::unordered_map<std::string, ROCKSDB_NAMESPACE::RegistrarFunc> ROCKSDB_NAMESPACE::ObjectRegistry::builtins_ = {};

librocksdb-sys/rocksdb

Submodule rocksdb updated 734 files

librocksdb-sys/rocksdb_lib_sources.txt

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ cache/secondary_cache_adapter.cc
1212
cache/sharded_cache.cc
1313
cache/tiered_secondary_cache.cc
1414
db/arena_wrapped_db_iter.cc
15+
db/attribute_group_iterator_impl.cc
1516
db/blob/blob_contents.cc
1617
db/blob/blob_fetcher.cc
1718
db/blob/blob_file_addition.cc
@@ -28,6 +29,7 @@ db/blob/blob_source.cc
2829
db/blob/prefetch_buffer_collection.cc
2930
db/builder.cc
3031
db/c.cc
32+
db/coalescing_iterator.cc
3133
db/column_family.cc
3234
db/compaction/compaction.cc
3335
db/compaction/compaction_iterator.cc
@@ -49,6 +51,7 @@ db/db_impl/db_impl_compaction_flush.cc
4951
db/db_impl/db_impl_debug.cc
5052
db/db_impl/db_impl_experimental.cc
5153
db/db_impl/db_impl_files.cc
54+
db/db_impl/db_impl_follower.cc
5255
db/db_impl/db_impl_open.cc
5356
db/db_impl/db_impl_readonly.cc
5457
db/db_impl/db_impl_secondary.cc
@@ -105,6 +108,7 @@ env/env_chroot.cc
105108
env/env_encryption.cc
106109
env/env_posix.cc
107110
env/file_system.cc
111+
env/fs_on_demand.cc
108112
env/fs_posix.cc
109113
env/fs_remap.cc
110114
env/file_system_tracer.cc
@@ -311,6 +315,7 @@ utilities/transactions/write_prepared_txn_db.cc
311315
utilities/transactions/write_unprepared_txn.cc
312316
utilities/transactions/write_unprepared_txn_db.cc
313317
utilities/ttl/db_ttl_impl.cc
318+
utilities/types_util.cc
314319
utilities/wal_filter.cc
315320
utilities/write_batch_with_index/write_batch_with_index.cc
316321
utilities/write_batch_with_index/write_batch_with_index_internal.cc

0 commit comments

Comments
 (0)