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

ASAN error with database transaction tracker json serialization #2538

Merged
merged 1 commit into from
Feb 5, 2020
Merged
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
9 changes: 7 additions & 2 deletions nano/node/lmdb/lmdb_txn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,14 @@ void nano::mdb_txn_tracker::serialize_json (boost::property_tree::ptree & json,
{
// Copying is cheap compared to generating the stack trace strings, so reduce time holding the mutex
std::vector<mdb_txn_stats> copy_stats;
std::vector<bool> are_writes;
{
nano::lock_guard<std::mutex> guard (mutex);
copy_stats = stats;
are_writes.reserve (stats.size ());
std::transform (stats.cbegin (), stats.cend (), std::back_inserter (are_writes), [](auto & mdb_txn_stat) {
return mdb_txn_stat.is_write ();
});
}

// Get the time difference now as creating stacktraces (Debug/Windows for instance) can take a while so results won't be as accurate
Expand All @@ -149,13 +154,13 @@ void nano::mdb_txn_tracker::serialize_json (boost::property_tree::ptree & json,
auto const & stat = copy_stats[i];
auto time_held_open = times_since_start[i];

if ((stat.is_write () && time_held_open >= min_write_time) || (!stat.is_write () && time_held_open >= min_read_time))
if ((are_writes[i] && time_held_open >= min_write_time) || (!are_writes[i] && time_held_open >= min_read_time))
{
nano::jsonconfig mdb_lock_config;

mdb_lock_config.put ("thread", stat.thread_name);
mdb_lock_config.put ("time_held_open", time_held_open.count ());
mdb_lock_config.put ("write", stat.is_write ());
mdb_lock_config.put ("write", !!are_writes[i]);

boost::property_tree::ptree stacktrace_config;
for (auto frame : *stat.stacktrace)
Expand Down