Skip to content

Commit 21be567

Browse files
authored
Clean up useless variable (#419)
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
1 parent 9568367 commit 21be567

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

db/version_set.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4145,7 +4145,8 @@ VersionSet::~VersionSet() {
41454145
}
41464146
obsolete_files_.clear();
41474147
io_status_.PermitUncheckedError();
4148-
// Shutdown the dedicated background deletion scheduler first
4148+
// Shutdown the dedicated background deletion scheduler and wait for it to
4149+
// finish
41494150
if (deletion_scheduler_) {
41504151
deletion_scheduler_->Shutdown();
41514152
}

db/version_set_deletion_scheduler.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ VersionSetDeletionScheduler::VersionSetDeletionScheduler(Logger* info_log)
2121
deletion_queue_(),
2222
bg_thread_(nullptr),
2323
shutting_down_(false),
24-
pending_deletion_count_(0),
2524
info_log_(info_log) {
2625
// Start the background thread
2726
bg_thread_.reset(new port::Thread(
@@ -39,11 +38,11 @@ void VersionSetDeletionScheduler::ScheduleDeletion(
3938
MutexLock lock(&version_delete_mutex_);
4039

4140
if (shutting_down_) {
41+
delete storage_info; // Delete synchronously if shutting down
4242
return;
4343
}
4444

4545
deletion_queue_.push(storage_info);
46-
pending_deletion_count_++;
4746

4847
// Notify the background thread that work is available
4948
cv_.Signal();
@@ -76,10 +75,9 @@ void VersionSetDeletionScheduler::BackgroundDeletionThread() {
7675
}
7776

7877
// Process all pending deletion operations
79-
while (!deletion_queue_.empty() && !shutting_down_) {
78+
while (!deletion_queue_.empty()) {
8079
VersionStorageInfo* storage_info = deletion_queue_.front();
8180
deletion_queue_.pop();
82-
pending_deletion_count_--;
8381

8482
// Unlock mutex while executing the deletion operation
8583
version_delete_mutex_.Unlock();

db/version_set_deletion_scheduler.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,8 @@ class VersionStorageInfo;
1818
class Logger;
1919

2020
// VersionSetDeletionScheduler provides a dedicated background thread for
21-
// handling VersionStorageInfo deletion operations that were previously executed
22-
// via env_->Schedule() in the LOW priority thread pool.
23-
//
24-
// This dedicated thread helps to:
25-
// 1. Isolate version storage deletion operations from other background work
26-
// 2. Avoid potential interference with other low-priority operations
27-
// 3. Provide better control over deletion timing and parallelism
28-
//
21+
// handling VersionStorageInfo deletion operations that would be time-consuming
22+
// when having a lot of SST files.
2923
class VersionSetDeletionScheduler {
3024
public:
3125
explicit VersionSetDeletionScheduler(Logger* info_log);
@@ -58,9 +52,6 @@ class VersionSetDeletionScheduler {
5852
// Flag to indicate shutdown
5953
bool shutting_down_;
6054

61-
// Number of pending deletion operations
62-
int pending_deletion_count_;
63-
6455
// Logger for debug/info messages
6556
Logger* info_log_;
6657
};

0 commit comments

Comments
 (0)