Add a ticker to track number of trash files deleted in background thread (#11540)

Summary:
This ticker combined with `rocksdb.files.marked.trash` can help give a better picture of how DeleteScheduler is keeping up.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/11540

Test Plan:
```
./delete_scheduler_test
```

Reviewed By: ajkr

Differential Revision: D46746401

Pulled By: jowlyzhang

fbshipit-source-id: f3daa622aa3ddefe7d673e0cc257a47699d506df
oxigraph-main
Yu Zhang 2 years ago committed by Facebook GitHub Bot
parent bc04ec85db
commit b421a8c21b
  1. 1
      file/delete_scheduler.cc
  2. 13
      file/delete_scheduler_test.cc
  3. 5
      include/rocksdb/statistics.h
  4. 1
      monitoring/statistics.cc
  5. 1
      unreleased_history/new_features/ticker_for_deleted_trash_files.md

@ -256,6 +256,7 @@ void DeleteScheduler::BackgroundEmptyTrash() {
total_deleted_bytes += deleted_bytes; total_deleted_bytes += deleted_bytes;
mu_.Lock(); mu_.Lock();
if (is_complete) { if (is_complete) {
RecordTick(stats_.get(), FILES_DELETED_FROM_TRASH_QUEUE);
queue_.pop(); queue_.pop();
} }

@ -185,6 +185,8 @@ TEST_F(DeleteSchedulerTest, BasicRateLimiting) {
ASSERT_EQ(CountTrashFiles(), 0); ASSERT_EQ(CountTrashFiles(), 0);
ASSERT_EQ(num_files, stats_->getAndResetTickerCount(FILES_MARKED_TRASH)); ASSERT_EQ(num_files, stats_->getAndResetTickerCount(FILES_MARKED_TRASH));
ASSERT_EQ(num_files,
stats_->getAndResetTickerCount(FILES_DELETED_FROM_TRASH_QUEUE));
ASSERT_EQ(0, stats_->getAndResetTickerCount(FILES_DELETED_IMMEDIATELY)); ASSERT_EQ(0, stats_->getAndResetTickerCount(FILES_DELETED_IMMEDIATELY));
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
@ -224,6 +226,8 @@ TEST_F(DeleteSchedulerTest, MultiDirectoryDeletionsScheduled) {
} }
ASSERT_EQ(kNumFiles, stats_->getAndResetTickerCount(FILES_MARKED_TRASH)); ASSERT_EQ(kNumFiles, stats_->getAndResetTickerCount(FILES_MARKED_TRASH));
ASSERT_EQ(kNumFiles,
stats_->getAndResetTickerCount(FILES_DELETED_FROM_TRASH_QUEUE));
ASSERT_EQ(0, stats_->getAndResetTickerCount(FILES_DELETED_IMMEDIATELY)); ASSERT_EQ(0, stats_->getAndResetTickerCount(FILES_DELETED_IMMEDIATELY));
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
@ -308,8 +312,11 @@ TEST_F(DeleteSchedulerTest, RateLimitingMultiThreaded) {
ASSERT_EQ(CountNormalFiles(), 0); ASSERT_EQ(CountNormalFiles(), 0);
ASSERT_EQ(CountTrashFiles(), 0); ASSERT_EQ(CountTrashFiles(), 0);
ASSERT_EQ(num_files * thread_cnt, int total_num_files = num_files * thread_cnt;
ASSERT_EQ(total_num_files,
stats_->getAndResetTickerCount(FILES_MARKED_TRASH)); stats_->getAndResetTickerCount(FILES_MARKED_TRASH));
ASSERT_EQ(total_num_files,
stats_->getAndResetTickerCount(FILES_DELETED_FROM_TRASH_QUEUE));
ASSERT_EQ(0, stats_->getAndResetTickerCount(FILES_DELETED_IMMEDIATELY)); ASSERT_EQ(0, stats_->getAndResetTickerCount(FILES_DELETED_IMMEDIATELY));
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
@ -342,6 +349,7 @@ TEST_F(DeleteSchedulerTest, DisableRateLimiting) {
ASSERT_EQ(bg_delete_file, 0); ASSERT_EQ(bg_delete_file, 0);
ASSERT_EQ(0, stats_->getAndResetTickerCount(FILES_MARKED_TRASH)); ASSERT_EQ(0, stats_->getAndResetTickerCount(FILES_MARKED_TRASH));
ASSERT_EQ(0, stats_->getAndResetTickerCount(FILES_DELETED_FROM_TRASH_QUEUE));
ASSERT_EQ(num_files, ASSERT_EQ(num_files,
stats_->getAndResetTickerCount(FILES_DELETED_IMMEDIATELY)); stats_->getAndResetTickerCount(FILES_DELETED_IMMEDIATELY));
@ -381,6 +389,7 @@ TEST_F(DeleteSchedulerTest, ConflictNames) {
auto bg_errors = delete_scheduler_->GetBackgroundErrors(); auto bg_errors = delete_scheduler_->GetBackgroundErrors();
ASSERT_EQ(bg_errors.size(), 0); ASSERT_EQ(bg_errors.size(), 0);
ASSERT_EQ(10, stats_->getAndResetTickerCount(FILES_MARKED_TRASH)); ASSERT_EQ(10, stats_->getAndResetTickerCount(FILES_MARKED_TRASH));
ASSERT_EQ(10, stats_->getAndResetTickerCount(FILES_DELETED_FROM_TRASH_QUEUE));
ASSERT_EQ(0, stats_->getAndResetTickerCount(FILES_DELETED_IMMEDIATELY)); ASSERT_EQ(0, stats_->getAndResetTickerCount(FILES_DELETED_IMMEDIATELY));
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
@ -465,6 +474,8 @@ TEST_F(DeleteSchedulerTest, StartBGEmptyTrashMultipleTimes) {
auto bg_errors = delete_scheduler_->GetBackgroundErrors(); auto bg_errors = delete_scheduler_->GetBackgroundErrors();
ASSERT_EQ(bg_errors.size(), 0); ASSERT_EQ(bg_errors.size(), 0);
ASSERT_EQ(kTestFileNum, stats_->getAndResetTickerCount(FILES_MARKED_TRASH)); ASSERT_EQ(kTestFileNum, stats_->getAndResetTickerCount(FILES_MARKED_TRASH));
ASSERT_EQ(kTestFileNum,
stats_->getAndResetTickerCount(FILES_DELETED_FROM_TRASH_QUEUE));
ASSERT_EQ(0, stats_->getAndResetTickerCount(FILES_DELETED_IMMEDIATELY)); ASSERT_EQ(0, stats_->getAndResetTickerCount(FILES_DELETED_IMMEDIATELY));
} }

@ -353,7 +353,10 @@ enum Tickers : uint32_t {
// # of files marked as trash by sst file manager and will be deleted // # of files marked as trash by sst file manager and will be deleted
// later by background thread. // later by background thread.
FILES_MARKED_TRASH, FILES_MARKED_TRASH,
// # of files deleted immediately by sst file manger through delete scheduler. // # of trash files deleted by the background thread from the trash queue.
FILES_DELETED_FROM_TRASH_QUEUE,
// # of files deleted immediately by sst file manager through delete
// scheduler.
FILES_DELETED_IMMEDIATELY, FILES_DELETED_IMMEDIATELY,
// The counters for error handler, not that, bg_io_error is the subset of // The counters for error handler, not that, bg_io_error is the subset of

@ -175,6 +175,7 @@ const std::vector<std::pair<Tickers, std::string>> TickersNameMap = {
{BLOCK_CACHE_COMPRESSION_DICT_ADD_REDUNDANT, {BLOCK_CACHE_COMPRESSION_DICT_ADD_REDUNDANT,
"rocksdb.block.cache.compression.dict.add.redundant"}, "rocksdb.block.cache.compression.dict.add.redundant"},
{FILES_MARKED_TRASH, "rocksdb.files.marked.trash"}, {FILES_MARKED_TRASH, "rocksdb.files.marked.trash"},
{FILES_DELETED_FROM_TRASH_QUEUE, "rocksdb.files.marked.trash.deleted"},
{FILES_DELETED_IMMEDIATELY, "rocksdb.files.deleted.immediately"}, {FILES_DELETED_IMMEDIATELY, "rocksdb.files.deleted.immediately"},
{ERROR_HANDLER_BG_ERROR_COUNT, "rocksdb.error.handler.bg.error.count"}, {ERROR_HANDLER_BG_ERROR_COUNT, "rocksdb.error.handler.bg.error.count"},
{ERROR_HANDLER_BG_ERROR_COUNT_MISSPELLED, {ERROR_HANDLER_BG_ERROR_COUNT_MISSPELLED,

@ -0,0 +1 @@
*Add a new ticker `rocksdb.files.marked.trash.deleted` to track the number of trash files deleted by background thread from the trash queue.
Loading…
Cancel
Save