From a64125096584fb4095a3b9683088f613ee802871 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Mon, 3 Jul 2017 17:08:31 -0500 Subject: [PATCH] Avoiding tx -> gap_cache::mutex with gap_cache::mutex -> tx deadlock when resizing environment. --- rai/node/node.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rai/node/node.cpp b/rai/node/node.cpp index 468522f4..79c25627 100755 --- a/rai/node/node.cpp +++ b/rai/node/node.cpp @@ -1268,13 +1268,13 @@ void rai::gap_cache::add (MDB_txn * transaction_a, rai::block const & block_a) void rai::gap_cache::vote (rai::vote const & vote_a) { + rai::transaction transaction (node.store.environment, nullptr, false); std::lock_guard lock (mutex); auto hash (vote_a.block->hash ()); auto existing (blocks.get <1> ().find (hash)); if (existing != blocks.get <1> ().end ()) { existing->votes->vote (vote_a); - rai::transaction transaction (node.store.environment, nullptr, false); auto winner (node.ledger.winner (transaction, *existing->votes)); if (winner.first > bootstrap_threshold (transaction)) { @@ -1410,6 +1410,8 @@ void rai::node::process_receive_many (rai::block const & block_a, std::function } ++count; } + // Let other threads get an opportunity to transaction lock + std::this_thread::yield (); } }