File tree Expand file tree Collapse file tree 3 files changed +6
-16
lines changed
Expand file tree Collapse file tree 3 files changed +6
-16
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 ();
Original file line number Diff line number Diff line change @@ -18,14 +18,8 @@ class VersionStorageInfo;
1818class 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.
2923class 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};
You can’t perform that action at this time.
0 commit comments