Skip to content

Commit d95ed3b

Browse files
authored
[SYS-6306] Add sequence number logging to RocksDb-Cloud (#289)
Summary: Added a thread local boolean that lets us turn on advanced logging to debug sequence number issues we've been observing. Test Plan: Internal testing Reviewers:
1 parent 832da87 commit d95ed3b

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

db/db_impl/db_impl.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6559,4 +6559,10 @@ ColumnFamilyData* DBImpl::GetAnyCFWithAutoFlushDisabled() const {
65596559
return nullptr;
65606560
}
65616561

6562+
namespace {
6563+
thread_local bool threadLogging{false};
6564+
}
6565+
void SetThreadLogging(bool v) { threadLogging = v; }
6566+
bool GetThreadLogging() { return threadLogging; }
6567+
65626568
} // namespace ROCKSDB_NAMESPACE

db/memtable.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,15 @@ static bool SaveValue(void* arg, const char* entry) {
974974
ValueType type;
975975
SequenceNumber seq;
976976
UnPackSequenceAndType(tag, &seq, &type);
977+
978+
if (GetThreadLogging()) {
979+
ROCKS_LOG_INFO(
980+
s->logger,
981+
"In SaveValue, memtable %p, found key at sequence number: %" PRIu64
982+
", type: %d",
983+
s->mem, seq, int(type));
984+
}
985+
977986
// If the value is not in the snapshot, skip it
978987
if (!s->CheckCallback(seq)) {
979988
return true; // to continue to the next seq

include/rocksdb/db.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,4 +1957,7 @@ Status RepairDB(const std::string& dbname, const DBOptions& db_options,
19571957
Status RepairDB(const std::string& dbname, const Options& options);
19581958
#endif
19591959

1960+
void SetThreadLogging(bool v);
1961+
bool GetThreadLogging();
1962+
19601963
} // namespace ROCKSDB_NAMESPACE

table/block_based/block_based_table_reader.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,6 +2178,15 @@ Status BlockBasedTable::Get(const ReadOptions& read_options, const Slice& key,
21782178
s = pik_status;
21792179
}
21802180

2181+
if (GetThreadLogging()) {
2182+
ROCKS_LOG_INFO(rep_->ioptions.logger,
2183+
"In BlockBasedTable::Get, file %" PRIu64
2184+
", found key at sequence number: %" PRIu64
2185+
", type: %d",
2186+
rep_->sst_number_for_tracing(), parsed_key.sequence,
2187+
int(parsed_key.type));
2188+
}
2189+
21812190
if (!get_context->SaveValue(
21822191
parsed_key, biter.value(), &matched,
21832192
biter.IsValuePinned() ? &biter : nullptr)) {

0 commit comments

Comments
 (0)