// Set delete rate limit in bytes per second
void SetRateBytesPerSecond(int64_t bytes_per_sec) {
rate_bytes_per_sec_.store(bytes_per_sec);
+ MaybeCreateBackgroundThread();
}
// Mark file as trash directory and schedule it's deletion. If force_bg is
static Status CleanupDirectory(Env* env, SstFileManagerImpl* sfm,
const std::string& path);
+ void SetStatisticsPtr(const std::shared_ptr<Statistics>& stats) {
+ InstrumentedMutexLock l(&mu_);
+ stats_ = stats;
+ }
+
private:
Status MarkAsTrash(const std::string& file_path, std::string* path_in_trash);
void BackgroundEmptyTrash();
+ void MaybeCreateBackgroundThread();
+
Env* env_;
FileSystem* fs_;
std::atomic<uint64_t> total_trash_size_;
// Maximum number of bytes that should be deleted per second
std::atomic<int64_t> rate_bytes_per_sec_;
- // Mutex to protect queue_, pending_files_, bg_errors_, closing_
+ // Mutex to protect queue_, pending_files_, bg_errors_, closing_, stats_
InstrumentedMutex mu_;
struct FileAndDir {
// immediately
std::atomic<double> max_trash_db_ratio_;
static const uint64_t kMicrosInSecond = 1000 * 1000LL;
+ std::shared_ptr<Statistics> stats_;
};
} // namespace ROCKSDB_NAMESPACE