Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logs and stats in DeleteScheduler #6927

Closed

Conversation

akankshamahajan15
Copy link
Contributor

Summary: Add logs and stats for files marked as trash and files deleted immediately in DeleteScheduler

Test Plan: make check -j64

Reviewers:

Subscribers:

Tasks: T67391953

Tags:

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akankshamahajan15 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akankshamahajan15 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@riversand963 riversand963 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @akankshamahajan15 for working on this. Left a few minor comments.

@@ -318,8 +330,9 @@ TEST_F(DeleteSchedulerTest, DisableRateLimiting) {

rate_bytes_per_sec_ = 0;
NewDeleteScheduler();
int num_files = 10;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:
constexpr int num_files = 10;

@@ -83,6 +83,8 @@ class DeleteScheduler {
static Status CleanupDirectory(Env* env, SstFileManagerImpl* sfm,
const std::string& path);

void SetStatisticsPtr(std::shared_ptr<Statistics> stats) { stats_ = stats; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the type of the argument can be const std::shared_ptr<Statistics>&.

@@ -135,6 +135,11 @@ class SstFileManagerImpl : public SstFileManager {
// once in the object's lifetime, and before the destructor
void Close();

void SetStatisticsPtr(std::shared_ptr<Statistics> stats) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const std::shared_ptr<Statistics>&.

@@ -65,24 +65,36 @@ Status DeleteScheduler::DeleteFile(const std::string& file_path,
s = fs_->DeleteFile(file_path, IOOptions(), nullptr);
if (s.ok()) {
sst_file_manager_->OnDeleteFile(file_path);
ROCKS_LOG_INFO(info_log_,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can print a message during db start, similar to the following:

SstFileManager instance: <addr in hex>

while (!closing_ && !cv_.TimedWait(start_time + total_penlty)) {}
ROCKS_LOG_INFO(
info_log_,
"Rate limiting is enabled with penalty %lu after deleting file %s",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use PRIi64, PRIu64 and ROCKSDB_PRIszt to print 64-bit signed integers, 64-bit unsigned, size_t-reps.

@facebook-github-bot
Copy link
Contributor

@akankshamahajan15 has updated the pull request. Re-import the pull request

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akankshamahajan15 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@akankshamahajan15
Copy link
Contributor Author

Addressed comments

@@ -39,6 +40,7 @@ DeleteScheduler::DeleteScheduler(Env* env, FileSystem* fs,
assert(sst_file_manager != nullptr);
assert(max_trash_db_ratio >= 0);
MaybeCreateBackgroundThread();
ROCKS_LOG_INFO(info_log_, "SstFileManager instance: %p", sst_file_manager);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the previous confusion. Maybe move this to DBImpl::Open()?

@@ -135,6 +135,11 @@ class SstFileManagerImpl : public SstFileManager {
// once in the object's lifetime, and before the destructor
void Close();

void SetStatisticsPtr(const std::shared_ptr<Statistics>& stats) override {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should call this function in when we open the db.

Comment on lines 431 to 434
ASSERT_EQ(
4, options.statistics.get()->getAndResetTickerCount(FILES_MARKED_TRASH));
ASSERT_EQ(0, options.statistics.get()->getAndResetTickerCount(
FILES_DELETED_IMMEDIATELY));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: options.statistics-> suffices.

Summary: Add logs and stats for files marked as trash and files deleted immediately in DeleteScheduler

Test Plan: make check -j64

Reviewers:

Subscribers:

Tasks: T67391953

Tags:
@facebook-github-bot
Copy link
Contributor

@akankshamahajan15 has updated the pull request. Re-import the pull request

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akankshamahajan15 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@riversand963 riversand963 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @akankshamahajan15 for the PR

@facebook-github-bot
Copy link
Contributor

@akankshamahajan15 merged this pull request in 2677bd5.

@siying
Copy link
Contributor

siying commented Jun 23, 2020

This seems to cause this TSAN failure:

WARNING: ThreadSanitizer: data race (pid=148549)
  Read of size 8 at 0x7b5c00026730 by thread T1:
    #0 rocksdb::DeleteScheduler::DeleteFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) file/delete_scheduler.cc:74 (db_test+0x00000097deef)
    #1 rocksdb::SstFileManagerImpl::ScheduleFileDeletion(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) file/sst_file_manager_impl.cc:433 (db_test+0x000000995e9f)
    #2 rocksdb::DeleteDBFile(rocksdb::ImmutableDBOptions const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool) file/file_util.cc:100 (db_test+0x0000009810f1)
    #3 rocksdb::DBImpl::DeleteObsoleteFileImpl(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rocksdb::FileType, unsigned long) db/db_impl/db_impl_files.cc:266 (db_test+0x00000072af6a)
    #4 rocksdb::DBImpl::PurgeObsoleteFiles(rocksdb::JobContext&, bool) db/db_impl/db_impl_files.cc:518 (db_test+0x0000007303b1)
    #5 rocksdb::DBImpl::BackgroundCallCompaction(rocksdb::DBImpl::PrepickedCompaction*, rocksdb::Env::Priority) db/db_impl/db_impl_compaction_flush.cc:2437 (db_test+0x00000070f82a)
    #6 rocksdb::DBImpl::BGWorkCompaction(void*) db/db_impl/db_impl_compaction_flush.cc:2159 (db_test+0x000000710372)
    #7 void std::__invoke_impl<void, void (*&)(void*), void*&>(std::__invoke_other, void (*&)(void*), void*&) /mnt/gvfs/third-party2/libgcc/6ace84e956873d53638c738b6f65f3f469cca74c/7.x/platform007/5620abc/include/c++/7.3.0/bits/invoke.h:60 (db_test+0x000000b8ad68)
    #8 std::__invoke_result<void (*&)(void*), void*&>::type std::__invoke<void (*&)(void*), void*&>(void (*&)(void*), void*&) /mnt/gvfs/third-party2/libgcc/6ace84e956873d53638c738b6f65f3f469cca74c/7.x/platform007/5620abc/include/c++/7.3.0/bits/invoke.h:95 (db_test+0x000000b8ad68)
    #9 void std::_Bind<void (*(void*))(void*)>::__call<void, , 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) /mnt/gvfs/third-party2/libgcc/6ace84e956873d53638c738b6f65f3f469cca74c/7.x/platform007/5620abc/include/c++/7.3.0/functional:467 (db_test+0x000000b8ad68)
    #10 void std::_Bind<void (*(void*))(void*)>::operator()<, void>() /mnt/gvfs/third-party2/libgcc/6ace84e956873d53638c738b6f65f3f469cca74c/7.x/platform007/5620abc/include/c++/7.3.0/functional:551 (db_test+0x000000b8ad68)
    #11 std::_Function_handler<void (), std::_Bind<void (*(void*))(void*)> >::_M_invoke(std::_Any_data const&) /mnt/gvfs/third-party2/libgcc/6ace84e956873d53638c738b6f65f3f469cca74c/7.x/platform007/5620abc/include/c++/7.3.0/bits/std_function.h:316 (db_test+0x000000b8ad68)
    #12 std::function<void ()>::operator()() const /mnt/gvfs/third-party2/libgcc/6ace84e956873d53638c738b6f65f3f469cca74c/7.x/platform007/5620abc/include/c++/7.3.0/bits/std_function.h:706 (db_test+0x0000005d7d23)
    #13 rocksdb::ThreadPoolImpl::Impl::BGThread(unsigned long) util/threadpool_imp.cc:264 (db_test+0x000000b8a940)
    #14 rocksdb::ThreadPoolImpl::Impl::BGThreadWrapper(void*) util/threadpool_imp.cc:305 (db_test+0x000000b8acbd)
    #15 void std::__invoke_impl<void, void (*)(void*), rocksdb::BGThreadMetadata*>(std::__invoke_other, void (*&&)(void*), rocksdb::BGThreadMetadata*&&) /mnt/gvfs/third-party2/libgcc/6ace84e956873d53638c738b6f65f3f469cca74c/7.x/platform007/5620abc/include/c++/7.3.0/bits/invoke.h:60 (db_test+0x000000b8adbf)
    #16 std::__invoke_result<void (*)(void*), rocksdb::BGThreadMetadata*>::type std::__invoke<void (*)(void*), rocksdb::BGThreadMetadata*>(void (*&&)(void*), rocksdb::BGThreadMetadata*&&) /mnt/gvfs/third-party2/libgcc/6ace84e956873d53638c738b6f65f3f469cca74c/7.x/platform007/5620abc/include/c++/7.3.0/bits/invoke.h:95 (db_test+0x000000b8adbf)
    #17 decltype (__invoke((_S_declval<0ul>)(), (_S_declval<1ul>)())) std::thread::_Invoker<std::tuple<void (*)(void*), rocksdb::BGThreadMetadata*> >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) /mnt/gvfs/third-party2/libgcc/6ace84e956873d53638c738b6f65f3f469cca74c/7.x/platform007/5620abc/include/c++/7.3.0/thread:234 (db_test+0x000000b8adbf)
    #18 std::thread::_Invoker<std::tuple<void (*)(void*), rocksdb::BGThreadMetadata*> >::operator()() /mnt/gvfs/third-party2/libgcc/6ace84e956873d53638c738b6f65f3f469cca74c/7.x/platform007/5620abc/include/c++/7.3.0/thread:243 (db_test+0x000000b8adbf)
    #19 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(void*), rocksdb::BGThreadMetadata*> > >::_M_run() /mnt/gvfs/third-party2/libgcc/6ace84e956873d53638c738b6f65f3f469cca74c/7.x/platform007/5620abc/include/c++/7.3.0/thread:186 (db_test+0x000000b8adbf)
    #20 execute_native_thread_routine <null> (libstdc++.so.6+0x0000000c86df)
  Previous write of size 8 at 0x7b5c00026730 by main thread:
    #0 std::__shared_ptr<rocksdb::Statistics, (__gnu_cxx::_Lock_policy)2>::operator=(std::__shared_ptr<rocksdb::Statistics, (__gnu_cxx::_Lock_policy)2> const&) /mnt/gvfs/third-party2/libgcc/6ace84e956873d53638c738b6f65f3f469cca74c/7.x/platform007/5620abc/include/c++/7.3.0/bits/shared_ptr_base.h:1036 (db_test+0x0000007441fc)
    #1 std::shared_ptr<rocksdb::Statistics>::operator=(std::shared_ptr<rocksdb::Statistics> const&) /mnt/gvfs/third-party2/libgcc/6ace84e956873d53638c738b6f65f3f469cca74c/7.x/platform007/5620abc/include/c++/7.3.0/bits/shared_ptr.h:93 (db_test+0x0000007441fc)
    #2 rocksdb::DeleteScheduler::SetStatisticsPtr(std::shared_ptr<rocksdb::Statistics> const&) file/delete_scheduler.h:87 (db_test+0x0000007441fc)
    #3 rocksdb::SstFileManagerImpl::SetStatisticsPtr(std::shared_ptr<rocksdb::Statistics> const&) file/sst_file_manager_impl.h:140 (db_test+0x0000007441fc)
    #4 rocksdb::DBImpl::Open(rocksdb::DBOptions const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<rocksdb::ColumnFamilyDescriptor, std::allocator<rocksdb::ColumnFamilyDescriptor> > const&, std::vector<rocksdb::ColumnFamilyHandle*, std::allocator<rocksdb::ColumnFamilyHandle*> >*, rocksdb::DB**, bool, bool) db/db_impl/db_impl_open.cc:1610 (db_test+0x0000007441fc)
    #5 rocksdb::DB::Open(rocksdb::DBOptions const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<rocksdb::ColumnFamilyDescriptor, std::allocator<rocksdb::ColumnFamilyDescriptor> > const&, std::vector<rocksdb::ColumnFamilyHandle*, std::allocator<rocksdb::ColumnFamilyHandle*> >*, rocksdb::DB**) db/db_impl/db_impl_open.cc:1362 (db_test+0x000000746bc8)
    #6 rocksdb::DB::Open(rocksdb::Options const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rocksdb::DB**) db/db_impl/db_impl_open.cc:1339 (db_test+0x000000746dd0)
    #7 rocksdb::DBTestBase::TryReopen(rocksdb::Options const&) db/db_test_util.cc:674 (db_test+0x0000005bf725)
    #8 rocksdb::DBTestBase::Reopen(rocksdb::Options const&) db/db_test_util.cc:628 (db_test+0x0000005bfb5f)
    #9 rocksdb::DBTestRandomized_Randomized_Test::TestBody() db/db_test.cc:3238 (db_test+0x000000558a70)
    #10 void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) third-party/gtest-1.8.1/fused-src/gtest/gtest-all.cc:3899 (db_test+0x000000d9caa8)
    #11 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) third-party/gtest-1.8.1/fused-src/gtest/gtest-all.cc:3935 (db_test+0x000000d9caa8)
    #12 testing::Test::Run() third-party/gtest-1.8.1/fused-src/gtest/gtest-all.cc:3973 (db_test+0x000000d90439)
    #13 testing::TestInfo::Run() third-party/gtest-1.8.1/fused-src/gtest/gtest-all.cc:4149 (db_test+0x000000d905e6)
    #14 testing::TestCase::Run() third-party/gtest-1.8.1/fused-src/gtest/gtest-all.cc:4267 (db_test+0x000000d907d9)
    #15 testing::internal::UnitTestImpl::RunAllTests() third-party/gtest-1.8.1/fused-src/gtest/gtest-all.cc:6633 (db_test+0x000000d90c9a)
    #16 bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) third-party/gtest-1.8.1/fused-src/gtest/gtest-all.cc:3899 (db_test+0x000000d9d1c4)
    #17 bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) third-party/gtest-1.8.1/fused-src/gtest/gtest-all.cc:3935 (db_test+0x000000d9d1c4)
    #18 testing::UnitTest::Run() third-party/gtest-1.8.1/fused-src/gtest/gtest-all.cc:6242 (db_test+0x000000d91146)
    #19 RUN_ALL_TESTS() third-party/gtest-1.8.1/fused-src/gtest/gtest.h:22104 (db_test+0x00000049492d)
    #20 main db/db_test.cc:6673 (db_test+0x00000049492d)

@akankshamahajan15 can you fix it?

@akankshamahajan15
Copy link
Contributor Author

Yes. I will fix this. Thanks.

levichen94 pushed a commit to bytedance/terarkdb that referenced this pull request Jun 18, 2021
Summary:
Add logs and stats for files marked as trash and files deleted immediately in DeleteScheduler
Pull Request resolved: facebook/rocksdb#6927

Test Plan: make check -j64

Reviewed By: riversand963

Differential Revision: D21869068

Pulled By: akankshamahajan15

fbshipit-source-id: e9f673c4fa8049ce648b23c75d742f2f9c6c57a1
Signed-off-by: Changlong Chen <levisonchen@live.cn>
mm304321141 pushed a commit to bytedance/terarkdb that referenced this pull request Jun 23, 2021
Summary:
Add logs and stats for files marked as trash and files deleted immediately in DeleteScheduler
Pull Request resolved: facebook/rocksdb#6927

Test Plan: make check -j64

Reviewed By: riversand963

Differential Revision: D21869068

Pulled By: akankshamahajan15

fbshipit-source-id: e9f673c4fa8049ce648b23c75d742f2f9c6c57a1
Signed-off-by: Changlong Chen <levisonchen@live.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants