Skip to content

Commit 5e9a2a9

Browse files
authored
feat(thirdparty): Use facebook/rocksdb and pegasus-kv/encfs as rocksdb thirdparty (#1678)
After the reimplementation of encryption feature on RocksDB as a plugin, now we can use the facebook official RocksDB plus the pegasus-kv/encfs plugin. It would be more flexiable rather than modify the core code of RocksDB.
1 parent aa9d31a commit 5e9a2a9

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

src/utils/env.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ DSN_DEFINE_bool(pegasus.server,
4040

4141
DSN_DEFINE_string(pegasus.server,
4242
server_key_for_testing,
43-
"server_key_for_testing",
43+
"0123456789ABCDEF0123456789ABCDEF",
4444
"The encrypted server key to use in the filesystem. NOTE: only for testing.");
4545

4646
DSN_DEFINE_string(pegasus.server,
@@ -62,8 +62,9 @@ rocksdb::Env *NewEncryptedEnv()
6262
{
6363
// Create an encryption provider.
6464
std::shared_ptr<rocksdb::EncryptionProvider> provider;
65-
auto provider_id =
66-
fmt::format("AES:{},{}", FLAGS_server_key_for_testing, FLAGS_encryption_method);
65+
auto provider_id = fmt::format("id=AES;hex_instance_key={};method={}",
66+
FLAGS_server_key_for_testing,
67+
FLAGS_encryption_method);
6768
auto s = rocksdb::EncryptionProvider::CreateFromString(
6869
rocksdb::ConfigOptions(), provider_id, &provider);
6970
CHECK(s.ok(), "Failed to create encryption provider: {}", s.ToString());

thirdparty/CMakeLists.txt

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,7 @@ ExternalProject_Add(jemalloc
372372

373373
option(ROCKSDB_PORTABLE "Minimum CPU arch to support, or 0 = current CPU, 1 = baseline CPU" 0)
374374

375-
# This is the commit "Update the status badge to pegasus-kv/rocksdb's own (#18) " on
376-
# branch v8.5.3-pegasus-encrypt of https://github.com/pegasus-kv/rocksdb.git.
377-
# The v8.5.3-pegasus-encrypt branch is based on the v8.5.3 tag of facebook/rocksdb and add
378-
# the encryption feature.
379-
ExternalProject_Add(rocksdb
380-
URL https://github.com/pegasus-kv/rocksdb/archive/e72106597e6b7924485cadc2433b66029f1aaf17.zip
381-
URL_MD5 6f6daef703586ce788643bbb8a984fff
382-
DEPENDS jemalloc
383-
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${TP_OUTPUT}
375+
set(ROCKSDB_OPTIONS
384376
-DFAIL_ON_WARNINGS=OFF
385377
-DWITH_BENCHMARK_TOOLS=OFF
386378
-DWITH_TOOLS=OFF
@@ -391,14 +383,29 @@ ExternalProject_Add(rocksdb
391383
-DWITH_TESTS=OFF
392384
-DWITH_GFLAGS=OFF
393385
-DUSE_RTTI=ON
394-
-DWITH_OPENSSL=ON # enable encryption
395386
-DCMAKE_BUILD_TYPE=Release
396387
-DWITH_JEMALLOC=${USE_JEMALLOC}
397388
-DJEMALLOC_ROOT_DIR=${TP_OUTPUT}
398389
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
399390
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
400-
-DPORTABLE=${ROCKSDB_PORTABLE}
401-
)
391+
-DPORTABLE=${ROCKSDB_PORTABLE})
392+
# Link error on MacOS, disable building encfs plugin.
393+
# See https://github.com/pegasus-kv/encfs/issues/4
394+
if (NOT APPLE)
395+
set(ROCKSDB_OPTIONS
396+
${ROCKSDB_OPTIONS}
397+
-DROCKSDB_PLUGINS=encfs)
398+
endif ()
399+
ExternalProject_Add(rocksdb
400+
URL ${OSS_URL_PREFIX}/rocksdb-v8.5.3.tar.gz
401+
https://github.com/facebook/rocksdb/archive/refs/tags/v8.5.3.tar.gz
402+
URL_MD5 f03eac50ec958a21a7cb56183afb8fe4
403+
PATCH_COMMAND ""
404+
COMMAND rm -rf ${TP_DIR}/build/Source/rocksdb/plugin/encfs
405+
COMMAND git clone -b main --depth=1 https://github.com/pegasus-kv/encfs.git ${TP_DIR}/build/Source/rocksdb/plugin/encfs
406+
DEPENDS googletest jemalloc
407+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${TP_OUTPUT}
408+
${ROCKSDB_OPTIONS})
402409

403410
ExternalProject_Add(http-parser
404411
URL ${OSS_URL_PREFIX}/http-parser-2.9.4.zip

0 commit comments

Comments
 (0)