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

DNM Add detailed log about read index cache #8981

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dbms/src/Storages/KVStore/Read/ReadIndexDataNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void ReadIndexDataNode::runOneRound(const TiFlashRaftProxyHelper & helper, const
e.second->update(history_success_tasks->second);
}

LOG_TRACE(
LOG_DEBUG(
DB::Logger::get(),
"[Learner Read] Read Index in Batch(use histroy), max_ts={} region_id={} waiting_tasks={} "
"running_tasks={} histroy_ts={}",
Expand Down Expand Up @@ -123,7 +123,7 @@ void ReadIndexDataNode::runOneRound(const TiFlashRaftProxyHelper & helper, const
}
}

LOG_TRACE(
LOG_DEBUG(
DB::Logger::get(),
"[Learner Read] Read Index in Batch(new request), max_ts={} region_id={} waiting_tasks={} "
"running_tasks={} should_build_running_task={} build_success={}",
Expand Down Expand Up @@ -253,6 +253,7 @@ void ReadIndexDataNode::doAddHistoryTasks(Timestamp ts, kvrpcpb::ReadIndexRespon
}
}
{
LOG_DEBUG(DB::Logger::get(), "[Learner Read] Add histroy tasks ts={} region_id={}", ts, region_id);
history_success_tasks.emplace(ts, std::move(resp)); // move resp
}
}
Expand Down
16 changes: 14 additions & 2 deletions dbms/src/Storages/RegionQueryInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,26 @@ struct MvccQueryInfo

// A cache for Region -> read index result between retries
using ReadIndexRes = std::unordered_map<RegionID, UInt64>;
ReadIndexRes read_index_res_cache;

DM::ScanContextPtr scan_context;

private:
ReadIndexRes read_index_res_cache;

public:
explicit MvccQueryInfo(bool resolve_locks_ = false, UInt64 start_ts_ = 0, DM::ScanContextPtr scan_ctx = nullptr);

void addReadIndexResToCache(RegionID region_id, UInt64 read_index) { read_index_res_cache[region_id] = read_index; }
void addReadIndexResToCache(RegionID region_id, UInt64 read_index)
{
LOG_DEBUG(
DB::Logger::get(),
"addReadIndexResToCache region_id={} read_index={} start_ts={}",
region_id,
read_index,
start_ts);
read_index_res_cache[region_id] = read_index;
}

UInt64 getReadIndexRes(RegionID region_id) const
{
if (auto it = read_index_res_cache.find(region_id); it != read_index_res_cache.end())
Expand Down