diff --git a/nano/node/active_elections.cpp b/nano/node/active_elections.cpp index 8cb16c1e27..bef80ca378 100644 --- a/nano/node/active_elections.cpp +++ b/nano/node/active_elections.cpp @@ -506,6 +506,7 @@ bool nano::active_elections::erase (nano::qualified_root const & root_a) auto root_it (roots.get ().find (root_a)); if (root_it != roots.get ().end ()) { + release_assert (root_it->election->qualified_root == root_a); cleanup_election (lock, root_it->election); return true; } diff --git a/nano/node/confirming_set.cpp b/nano/node/confirming_set.cpp index 9a8f436e77..49f6daff7f 100644 --- a/nano/node/confirming_set.cpp +++ b/nano/node/confirming_set.cpp @@ -132,11 +132,15 @@ void nano::confirming_set::run_batch (std::unique_lock & lock) notification.cemented.swap (cemented); notification.already_cemented.swap (already); - // Wait for the worker thread if too many notifications are queued + std::unique_lock lock{ mutex }; while (notification_workers.num_queued_tasks () >= config.max_queued_notifications) { stats.inc (nano::stat::type::confirming_set, nano::stat::detail::cooldown); - std::this_thread::sleep_for (100ms); + condition.wait_for (lock, 100ms, [this] { return stopped; }); + if (stopped) + { + return; + } } notification_workers.push_task ([this, notification = std::move (notification)] () { diff --git a/nano/node/repcrawler.cpp b/nano/node/repcrawler.cpp index f6cca66b5f..debb30cd40 100644 --- a/nano/node/repcrawler.cpp +++ b/nano/node/repcrawler.cpp @@ -452,8 +452,9 @@ std::vector nano::rep_crawler::representatives (std::size_ } std::vector result; - for (auto const & [weight, rep] : ordered | std::views::take (count)) + for (auto i = ordered.begin (), n = ordered.end (); i != n && result.size () < count; ++i) { + auto const & [weight, rep] = *i; result.push_back ({ rep.account, rep.channel }); } return result; diff --git a/nano/node/unchecked_map.cpp b/nano/node/unchecked_map.cpp index 88e3cdb96f..9430f97e5b 100644 --- a/nano/node/unchecked_map.cpp +++ b/nano/node/unchecked_map.cpp @@ -168,10 +168,14 @@ void nano::unchecked_map::query_impl (nano::block_hash const & hash) std::unique_ptr nano::unchecked_map::collect_container_info (const std::string & name) { - nano::lock_guard lock{ mutex }; - auto composite = std::make_unique (name); - composite->add_component (std::make_unique (container_info{ "entries", entries.size (), sizeof (decltype (entries)::value_type) })); - composite->add_component (std::make_unique (container_info{ "queries", buffer.size (), sizeof (decltype (buffer)::value_type) })); + { + std::lock_guard guard{ entries_mutex }; + composite->add_component (std::make_unique (container_info{ "entries", entries.size (), sizeof (decltype (entries)::value_type) })); + } + { + nano::lock_guard lock{ mutex }; + composite->add_component (std::make_unique (container_info{ "queries", buffer.size (), sizeof (decltype (buffer)::value_type) })); + } return composite; } diff --git a/tsan_suppressions b/tsan_suppressions index e08006cef7..3936f8fabc 100644 --- a/tsan_suppressions +++ b/tsan_suppressions @@ -2,3 +2,5 @@ race:mdb.c race:rocksdb race:Rijndael::Base::FillEncTable race:Rijndael::Base::FillDecTable +race:CryptoPP::Rijndael +race:boost::asio::detail::conditionally_enabled_mutex::scoped_lock::scoped_lock