Skip to content

Commit 63a13b7

Browse files
committed
fix: ai review bug 修复
1 parent c90028d commit 63a13b7

5 files changed

Lines changed: 16 additions & 10 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,5 @@ pkg
7373
# include codis fe javascript lib files
7474
!codis/cmd/fe/assets/**
7575

76-
tests/tmp
76+
tests/tmp
77+
.claude

src/pika_server.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,9 @@ void PikaServer::AutoCompactRange() {
12411241
struct timeval now;
12421242
gettimeofday(&now, nullptr);
12431243
int interval = g_pika_conf->incremental_compact_interval();
1244+
if (interval <= 0) {
1245+
return;
1246+
}
12441247
if (last_incremental_compact_time_.tv_sec == 0 ||
12451248
now.tv_sec - last_incremental_compact_time_.tv_sec >= interval) {
12461249
gettimeofday(&last_incremental_compact_time_, nullptr);

src/storage/src/redis.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <chrono>
77
#include <sstream>
88
#include <ctime>
9-
#include <thread>
109

1110
#include "rocksdb/env.h"
1211

@@ -272,9 +271,9 @@ void SelectColumnFamilyHandles(const DataType& option_type, const ColumnFamilyTy
272271
Status Redis::LongestNotCompactionSstCompact(const DataType& option_type, std::vector<Status>* compact_result_vec,
273272
const ColumnFamilyType& type) {
274273
bool no_compact = false;
275-
bool to_comapct = true;
276-
if (!in_compact_flag_.compare_exchange_weak(no_compact, to_comapct, std::memory_order_relaxed,
277-
std::memory_order_relaxed)) {
274+
bool to_compact = true;
275+
if (!in_compact_flag_.compare_exchange_strong(no_compact, to_compact, std::memory_order_relaxed,
276+
std::memory_order_relaxed)) {
278277
return Status::Busy("compact running");
279278
}
280279

@@ -465,8 +464,8 @@ Status Redis::IncrementalCompact(const DataType& option_type, std::vector<Status
465464
// 1. 并发控制
466465
bool no_compact = false;
467466
bool to_compact = true;
468-
if (!in_compact_flag_.compare_exchange_weak(no_compact, to_compact, std::memory_order_relaxed,
469-
std::memory_order_relaxed)) {
467+
if (!in_compact_flag_.compare_exchange_strong(no_compact, to_compact, std::memory_order_relaxed,
468+
std::memory_order_relaxed)) {
470469
return Status::Busy("compact running");
471470
}
472471
DEFER { in_compact_flag_.store(false); };
@@ -551,6 +550,9 @@ Status Redis::IncrementalCompact(const DataType& option_type, std::vector<Status
551550
if (!s.ok()) {
552551
LOG(WARNING) << "IncrementalCompact failed for file " << oldest_file
553552
<< ": " << s.ToString();
553+
if (compact_result_vec) {
554+
compact_result_vec->push_back(s);
555+
}
554556
break;
555557
}
556558

@@ -568,7 +570,7 @@ Status Redis::IncrementalCompact(const DataType& option_type, std::vector<Status
568570
processed++;
569571
}
570572

571-
if (compact_result_vec) {
573+
if (compact_result_vec && (compact_result_vec->empty() || compact_result_vec->back().ok())) {
572574
compact_result_vec->push_back(Status::OK());
573575
}
574576
}

src/storage/src/redis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ class Redis {
525525
rocksdb::WriteOptions default_write_options_;
526526
rocksdb::ReadOptions default_read_options_;
527527
rocksdb::CompactRangeOptions default_compact_range_options_;
528-
std::atomic<bool> in_compact_flag_;
528+
std::atomic<bool> in_compact_flag_{false};
529529
OBDSstListener listener_; // listening created sst file while compacting in OBD-compact
530530

531531
// For Scan

src/storage/src/storage.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ Status Storage::StartBGThread() {
16971697

16981698
Status Storage::AddBGTask(const BGTask& bg_task) {
16991699
bg_tasks_mutex_.lock();
1700-
if (bg_task.type == DataType::kAll) {
1700+
if (bg_task.operation == kCleanAll) {
17011701
// if current task it is global compact,
17021702
// clear the bg_tasks_queue_;
17031703
std::queue<BGTask> empty_queue;

0 commit comments

Comments
 (0)