Skip to content

block_processor::flush() has a race condition #3908

@dsiganos

Description

@dsiganos

block_processor::flush() has a race condition. The problem is that a block can be queued to be signature checked and the signature checker could be inactive and then block processor flush would return when it shouldn't. I can make several tests consistently fail by adding this delay in signature checker thread:

ds@tux:~/CLionProjects/work$ git diff nano/node/state_block_signature_verification.cpp
diff --git a/nano/node/state_block_signature_verification.cpp b/nano/node/state_block_signature_verification.cpp
index 553da3de3..c97ceb1ab 100644
--- a/nano/node/state_block_signature_verification.cpp
+++ b/nano/node/state_block_signature_verification.cpp
@@ -47,6 +47,7 @@ void nano::state_block_signature_verification::run (uint64_t state_block_signatu
        {
                if (!state_blocks.empty ())
                {
+                       std::this_thread::sleep_for(std::chrono::milliseconds(50));
                        std::size_t const max_verification_batch (state_block_signature_verification_size != 0 ? state_block_signature_verification_size : nano::signature_checker::batch_size * (node_config.signature_checker_threads + 1));
                        active = true;
                        while (!state_blocks.empty () && !stopped) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    unit testRelated to a new, changed or fixed unit test

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions