From 0f35db55d86ea8699ea936c9e2a4e34c82458d6b Mon Sep 17 00:00:00 2001 From: Hui Xiao Date: Wed, 20 Nov 2024 12:22:52 -0800 Subject: [PATCH] Print file number when TEST_VerifyNoObsoleteFilesCached fails (#13145) Summary: **Context/Summary:** https://github.com/facebook/rocksdb/pull/13117 added check for obsolete SST files that are not cleaned up timely. It caused a infrequent stress test failure `assertion="live_and_quar_files.find(file_number) != live_and_quar_files.end()"` that I haven't repro-ed yet. This PR prints the file number so we can find out what happens to that file through info logs when encountering the same failure. Pull Request resolved: https://github.com/facebook/rocksdb/pull/13145 Test Plan: Manually fail the assertion and observe the stderr printing ``` [ RUN ] DBBasicTest.UniqueSession File 12 is not live nor quarantined db_basic_test: db/db_impl/db_impl_debug.cc:384: rocksdb::DBImpl::TEST_VerifyNoObsoleteFilesCached(bool) const::: Assertion `false' failed. ``` Reviewed By: pdillinger Differential Revision: D66134154 Pulled By: hx235 fbshipit-source-id: 353164c373d3d674cee676b24468dfc79a1d4563 --- db/db_impl/db_impl_debug.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/db/db_impl/db_impl_debug.cc b/db/db_impl/db_impl_debug.cc index 912f910389..f8b2c6a757 100644 --- a/db/db_impl/db_impl_debug.cc +++ b/db/db_impl/db_impl_debug.cc @@ -6,8 +6,8 @@ // Copyright (c) 2011 The LevelDB Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. - #ifndef NDEBUG +#include #include "db/blob/blob_file_cache.h" #include "db/column_family.h" @@ -379,7 +379,11 @@ void DBImpl::TEST_VerifyNoObsoleteFilesCached( uint64_t file_number; GetUnaligned(reinterpret_cast(key.data()), &file_number); // Assert file is in live/quarantined set - assert(live_and_quar_files.find(file_number) != live_and_quar_files.end()); + if (live_and_quar_files.find(file_number) == live_and_quar_files.end()) { + std::cerr << "File " << file_number << " is not live nor quarantined" + << std::endl; + assert(false); + } }; table_cache_->ApplyToAllEntries(fn, {}); }