Skip to content

Commit

Permalink
Fix TSAN error for the rpc.database_txn_tracker test (#2013)
Browse files Browse the repository at this point in the history
  • Loading branch information
wezrule authored and Russel Waters committed May 22, 2019
1 parent 3517e16 commit 87d0b04
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nano/rpc_test/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6226,7 +6226,7 @@ TEST (rpc, database_txn_tracker)
std::promise<void> keep_txn_alive_promise;
std::promise<void> txn_created_promise;
// clang-format off
std::thread ([&store = node->store, &keep_txn_alive_promise, &txn_created_promise]() {
std::thread thread ([&store = node->store, &keep_txn_alive_promise, &txn_created_promise]() {
// Use rpc_process_container as a placeholder as this thread is only instantiated by the daemon so won't be used
nano::thread_role::set (nano::thread_role::name::rpc_process_container);

Expand All @@ -6237,8 +6237,7 @@ TEST (rpc, database_txn_tracker)
std::this_thread::sleep_for (1s);
txn_created_promise.set_value ();
keep_txn_alive_promise.get_future ().wait ();
})
.detach ();
});
// clang-format on

txn_created_promise.get_future ().wait ();
Expand Down Expand Up @@ -6277,6 +6276,7 @@ TEST (rpc, database_txn_tracker)
// Due to results being different for different compilers/build options we cannot reliably check the contents.
// The best we can do is just check that there are entries.
ASSERT_TRUE (!std::get<3> (json_l.front ()).empty ());
thread.join ();
}

// This is mainly to check for threading issues with TSAN
Expand Down

0 comments on commit 87d0b04

Please sign in to comment.