Skip to content

Commit

Permalink
PageStorage: avoid redundantly print stale snapshot log (pingcap#8608)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lloyd-Pottiger authored and JaySon-Huang committed Dec 27, 2023
1 parent b270e26 commit 1ec1737
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions dbms/src/Storages/Page/V3/PageDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,7 @@ typename PageDirectory<Trait>::PageEntries PageDirectory<Trait>::gcInMemEntries(
{
// Cleanup released snapshots
std::lock_guard lock(snapshots_mutex);
std::unordered_set<String> tracing_id_set;
for (auto iter = snapshots.begin(); iter != snapshots.end(); /* empty */)
{
if (auto snap = iter->lock(); snap == nullptr)
Expand All @@ -2063,13 +2064,17 @@ typename PageDirectory<Trait>::PageEntries PageDirectory<Trait>::gcInMemEntries(

if (alive_time_seconds > 10 * 60) // TODO: Make `10 * 60` as a configuration
{
LOG_WARNING(
log,
"Meet a stale snapshot [thread id={}] [tracing id={}] [seq={}] [alive time(s)={}]",
snap->create_thread,
snap->tracing_id,
snap->sequence,
alive_time_seconds);
if (!tracing_id_set.contains(snap->tracing_id))
{
LOG_WARNING(
log,
"Meet a stale snapshot [thread id={}] [tracing id={}] [seq={}] [alive time(s)={}]",
snap->create_thread,
snap->tracing_id,
snap->sequence,
alive_time_seconds);
tracing_id_set.emplace(snap->tracing_id);
}
stale_snapshot_nums++;
}

Expand Down Expand Up @@ -2158,8 +2163,10 @@ typename PageDirectory<Trait>::PageEntries PageDirectory<Trait>::gcInMemEntries(
}
}

LOG_DEBUG(
auto log_level = stale_snapshot_nums > 0 ? Poco::Message::PRIO_INFORMATION : Poco::Message::PRIO_DEBUG;
LOG_IMPL(
log,
log_level,
"After MVCC gc in memory [lowest_seq={}] "
"clean [invalid_snapshot_nums={}] [invalid_page_nums={}] "
"[total_deref_counter={}] [all_del_entries={}]. "
Expand Down

0 comments on commit 1ec1737

Please sign in to comment.