Skip to content

Commit ea56da0

Browse files
authored
fix: fix pkpatternmatchdel bug (#2717)
* fix pkpatternmatchdel error * support load max-total-wal-size from conf file
1 parent 4165526 commit ea56da0

5 files changed

Lines changed: 14 additions & 2 deletions

File tree

conf/pika.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,11 @@ max-write-buffer-num : 2
317317
# whether the key exists. Setting this value too high may hurt performance.
318318
min-write-buffer-number-to-merge : 1
319319

320+
# The total size of wal files, when reaches this limit, rocksdb will force the flush of column-families
321+
# whose memtables are backed by the oldest live WAL file. Also used to control the rocksdb open time when
322+
# process restart.
323+
max-total-wal-size : 1073741824
324+
320325
# rocksdb level0_stop_writes_trigger
321326
level0-stop-writes-trigger : 36
322327

src/pika_admin.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3043,6 +3043,7 @@ void PKPatternMatchDelCmd::DoInitial() {
30433043
pattern_ = argv_[1];
30443044
}
30453045

3046+
//TODO: may lead to inconsistent between rediscache and db, because currently it only cleans db
30463047
void PKPatternMatchDelCmd::Do() {
30473048
int ret = 0;
30483049
rocksdb::Status s = db_->storage()->PKPatternMatchDel(type_, pattern_, &ret);

src/pika_command.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void InitCmdTable(CmdTable* cmd_table) {
130130
cmd_table->insert(std::pair<std::string, std::unique_ptr<Cmd>>(kCmdNamePadding, std::move(paddingptr)));
131131

132132
std::unique_ptr<Cmd> pkpatternmatchdelptr =
133-
std::make_unique<PKPatternMatchDelCmd>(kCmdNamePKPatternMatchDel, 3, kCmdFlagsWrite | kCmdFlagsAdmin);
133+
std::make_unique<PKPatternMatchDelCmd>(kCmdNamePKPatternMatchDel, 2, kCmdFlagsWrite | kCmdFlagsAdmin);
134134
cmd_table->insert(
135135
std::pair<std::string, std::unique_ptr<Cmd>>(kCmdNamePKPatternMatchDel, std::move(pkpatternmatchdelptr)));
136136
std::unique_ptr<Cmd> dummyptr = std::make_unique<DummyCmd>(kCmdDummy, 0, kCmdFlagsWrite);

src/pika_conf.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ int PikaConf::Load() {
339339
max_write_buffer_size_ = PIKA_CACHE_SIZE_DEFAULT; // 10Gb
340340
}
341341

342+
// max-total-wal-size
343+
GetConfInt64("max-total-wal-size", &max_total_wal_size_);
344+
if (max_total_wal_size_ < 0) {
345+
max_total_wal_size_ = 0;
346+
}
347+
342348
// rate-limiter-mode
343349
rate_limiter_mode_ = 1;
344350
GetConfInt("rate-limiter-mode", &rate_limiter_mode_);

src/storage/src/redis_strings.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,7 @@ rocksdb::Status Redis::PKPatternMatchDel(const std::string& pattern, int32_t* re
15971597
meta_value = iter->value().ToString();
15981598
ParsedStringsValue parsed_strings_value(&meta_value);
15991599
if (!parsed_strings_value.IsStale() &&
1600-
(StringMatch(pattern.data(), pattern.size(), key.data(), key.size(), 0) != 0)) {
1600+
(StringMatch(pattern.data(), pattern.size(), parsed_meta_key.Key().data(), parsed_meta_key.Key().size(), 0) != 0)) {
16011601
batch.Delete(key);
16021602
}
16031603
} else if (meta_type == DataType::kLists) {

0 commit comments

Comments
 (0)