Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/Tendis-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ jobs:
env:
TEST_DIR: build/bin
steps:
- name: Clean up pre-installed tools
run: |
df -h
sudo rm -rf /usr/local/lib/android
df -h
- uses: actions/checkout@v3
with:
fetch-depth: 2
Expand Down
117 changes: 114 additions & 3 deletions src/tendisplus/commands/command_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ void testLatencyMonitor(std::shared_ptr<ServerEntry> svr) {
EXPECT_TRUE(expect.ok());
found = std::regex_search(expect.value(), matches, pattern);
if (found) {
assert(matches.size() > 2);
assert(matches.size() >= 2);
std::string res = matches[1];
assert(res.size() > 10);
auto v = res.substr(res.size() - 10, res.size());
Expand All @@ -915,7 +915,7 @@ void testLatencyMonitor(std::shared_ptr<ServerEntry> svr) {
EXPECT_TRUE(expect.ok());
found = std::regex_search(expect.value(), matches, pattern);
if (found) {
assert(matches.size() > 2);
assert(matches.size() >= 2);
std::string res = matches[1];
assert(res.size() > 10);
auto v = res.substr(res.size() - 10, res.size());
Expand All @@ -930,7 +930,7 @@ void testLatencyMonitor(std::shared_ptr<ServerEntry> svr) {
EXPECT_TRUE(expect.ok());
found = std::regex_search(expect.value(), matches, pattern);
if (found) {
assert(matches.size() > 2);
assert(matches.size() >= 2);
std::string res = matches[1];
assert(res.size() > 10);
auto v = res.substr(res.size() - 10, res.size());
Expand Down Expand Up @@ -2918,6 +2918,117 @@ TEST(Command, rocksdbOptionsCommand) {
#endif
}

void testRocksCFOptionConfig(std::shared_ptr<ServerEntry> svr,
int df_status,
int bl_status) {
asio::io_context ioContext;
asio::ip::tcp::socket socket(ioContext);
NetSession sess(svr, std::move(socket), 1, false, nullptr, nullptr);
for (uint32_t i = 0; i < svr->getKVStoreCount(); i++) {
auto exptDb = svr->getSegmentMgr()->getDb(&sess, 0, mgl::LockMode::LOCK_IS);
EXPECT_TRUE(exptDb.ok());

auto store = exptDb.value().store;
EXPECT_EQ(store->getCFOption(ColumnFamilyNumber::ColumnFamily_Default,
"rocks.enable_blob_files"),
df_status);
EXPECT_EQ(store->getCFOption(ColumnFamilyNumber::ColumnFamily_Binlog,
"rocks.enable_blob_files"),
bl_status);
}
}

void testCFConfigSetAndGet(std::shared_ptr<ServerEntry> master) {
auto ctx = std::make_shared<asio::io_context>();
auto session = makeSession(master, ctx);
{
session->setArgs({"config", "set", "rocks.enable_blob_files", "1"});
auto expect = Command::runSessionCmd(session.get());
EXPECT_EQ(expect.ok(), true);
testRocksCFOptionConfig(master, 1, 1);
}

{
session->setArgs({"config", "set", "rocks.enable_blob_files", "0"});
auto expect = Command::runSessionCmd(session.get());
EXPECT_EQ(expect.ok(), true);
testRocksCFOptionConfig(master, 0, 0);
}

{
session->setArgs(
{"config", "set", "rocks.defaultcf.enable_blob_files", "1"});
auto expect = Command::runSessionCmd(session.get());
EXPECT_EQ(expect.ok(), true);
testRocksCFOptionConfig(master, 1, 0);
}

{
session->setArgs(
{"config", "set", "rocks.defaultcf.enable_blob_files", "0"});
auto expect = Command::runSessionCmd(session.get());
EXPECT_EQ(expect.ok(), true);
testRocksCFOptionConfig(master, 0, 0);
}
{
session->setArgs(
{"config", "set", "rocks.binlogcf.enable_blob_files", "1"});
auto expect = Command::runSessionCmd(session.get());
EXPECT_EQ(expect.ok(), true);
testRocksCFOptionConfig(master, 0, 1);
}

{
session->setArgs(
{"config", "set", "rocks.binlogcf.enable_blob_files", "0"});
auto expect = Command::runSessionCmd(session.get());
EXPECT_EQ(expect.ok(), true);
testRocksCFOptionConfig(master, 0, 0);
}
}
TEST(Command, rocksdbCfOptionsCommand) {
const auto guard = MakeGuard([]() { destroyEnv(); });
EXPECT_TRUE(setupEnv());
{
std::map<std::string, std::string> configMap = {
{"rocks.enable_blob_files", "1"}};
auto cfg = makeServerParam(8814, 0, "", true, configMap);
getGlobalServer() = makeServerEntry(cfg);
testRocksCFOptionConfig(getGlobalServer(), 1, 1);
testCFConfigSetAndGet(getGlobalServer());
#ifndef _WIN32
getGlobalServer()->stop();
EXPECT_EQ(getGlobalServer().use_count(), 1);
#endif
}

{
std::map<std::string, std::string> configMap = {
{"rocks.defaultcf.enable_blob_files", "1"}};
auto cfg = makeServerParam(8815, 0, "", true, configMap);
getGlobalServer() = makeServerEntry(cfg);
testRocksCFOptionConfig(getGlobalServer(), 1, 0);
testCFConfigSetAndGet(getGlobalServer());
#ifndef _WIN32
getGlobalServer()->stop();
EXPECT_EQ(getGlobalServer().use_count(), 1);
#endif
}

{
std::map<std::string, std::string> configMap = {
{"rocks.binlogcf.enable_blob_files", "1"}};
auto cfg = makeServerParam(8816, 0, "", true, configMap);
getGlobalServer() = makeServerEntry(cfg);
testRocksCFOptionConfig(getGlobalServer(), 0, 1);
testCFConfigSetAndGet(getGlobalServer());
#ifndef _WIN32
getGlobalServer()->stop();
EXPECT_EQ(getGlobalServer().use_count(), 1);
#endif
}
}

void testSort(bool clusterEnabled) {
const auto guard = MakeGuard([] { destroyEnv(); });

Expand Down
8 changes: 5 additions & 3 deletions src/tendisplus/storage/rocks/rocks_kvstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1442,12 +1442,12 @@ rocksdb::Options RocksKVStore::options(const std::string cf) {
}

rocksdb::Options RocksKVStore::defaultColumnOptions() {
return options();
return options(kDefaultCF);
}

// Binlog Column different from default
rocksdb::Options RocksKVStore::binlogColumnOptions() {
auto columOpts = options("binlogcf");
auto columOpts = options(kBinlogCF);
for (int i = 0; i < ROCKSDB_NUM_LEVELS; ++i) {
columOpts.compression_per_level[i] =
rocksGetCompressType(_cfg->rocksCompressType);
Expand Down Expand Up @@ -3302,8 +3302,10 @@ Status RocksKVStore::setOptionDynamic(const std::string& option,
auto cf = ColumnFamilyNumber::ColumnFamily_All;
if (isCfOption) {
if (specialCf == "") {
cf = ColumnFamilyNumber::ColumnFamily_All;
} else if (specialCf == kDefaultCF) {
cf = ColumnFamilyNumber::ColumnFamily_Default;
} else if (specialCf == "binlogcf") {
} else if (specialCf == kBinlogCF) {
cf = ColumnFamilyNumber::ColumnFamily_Binlog;
} else {
return {ErrorCodes::ERR_INTERNAL,
Expand Down
3 changes: 2 additions & 1 deletion src/tendisplus/storage/rocks/rocks_kvstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#include "tendisplus/storage/kvstore.h"

namespace tendisplus {

static constexpr const char* kDefaultCF = "defaultcf";
static constexpr const char* kBinlogCF = "binlogcf";
class RocksKVStore;
class RocksdbEnv;
class BackgroundErrorListener;
Expand Down