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

Fix exception of search_log_for_key. #5733

Merged
merged 4 commits into from
Aug 30, 2022
Merged
Changes from 3 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
50 changes: 36 additions & 14 deletions dbms/src/Debug/dbgFuncMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,24 @@ namespace DB
{
inline size_t getReadTSOForLog(const String & line)
{
auto sub_line = line.substr(line.find("read_tso="));
std::regex rx(R"((0|[1-9][0-9]*))");
std::smatch m;
if (regex_search(sub_line, m, rx))
return std::stoul(m[1]);
else
return 0;
try
{
std::regex rx(R"((0|[1-9][0-9]*))");
std::smatch m;
auto pos = line.find("read_tso=");
if (pos != std::string::npos && regex_search(line.cbegin() + pos, line.cend(), m, rx))
{
return std::stoul(m[1]);
}
else
{
return 0;
}
}
catch (std::exception & e)
{
throw Exception(fmt::format("Parse 'read tso' failed, exception: {}, line {}", e.what(), line));
}
}

// Usage example:
Expand Down Expand Up @@ -90,13 +101,24 @@ void dbgFuncSearchLogForKey(Context & context, const ASTs & args, DBGInvoker::Pr
}
}
// try parse the first number following the key
auto sub_line = target_line.substr(target_line.find(key));
std::regex rx(R"([+-]?([0-9]+([.][0-9]*)?|[.][0-9]+))");
std::smatch m;
if (regex_search(sub_line, m, rx))
output(m[1]);
else
output("Invalid");
try
{
std::regex rx(R"([+-]?([0-9]+([.][0-9]*)?|[.][0-9]+))");
std::smatch m;
auto pos = target_line.find(key);
if (pos != std::string::npos && regex_search(target_line.cbegin() + pos, target_line.cend(), m, rx))
{
output(m[1]);
}
else
{
output("Invalid");
}
}
catch (std::exception & e)
{
throw Exception(fmt::format("Parse 'RSFilter exclude rate' failed, exception: {}, target_line {}", e.what(), target_line));
}
}

void dbgFuncTriggerGlobalPageStorageGC(Context & context, const ASTs & /*args*/, DBGInvoker::Printer /*output*/)
Expand Down