test: indexes, fix on error infinite loop #28044

pull furszy wants to merge 1 commits into bitcoin:master from furszy:2023_test_fix_infinite_loop changing 1 files +7 −0
  1. furszy commented at 1:20 pm on July 7, 2023: member

    Coming from #28036 (comment), I thought that we were going to fix it there but seems that got merged without it for some reason.

    As index sync failures trigger a shutdown request without notifying BaseIndex::BlockUntilSyncedToCurrentChain in any way, we also need to check whether a shutdown was requested or not inside ‘IndexWaitSynced’.

    Otherwise, any error inside the index sync process will hang the test forever.

  2. DrahtBot commented at 1:20 pm on July 7, 2023: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK jamesob, MarcoFalke, ryanofsky

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Tests on Jul 7, 2023
  4. in src/test/util/index.cpp:16 in 98fa44c227 outdated
    12 {
    13-    while (!index.BlockUntilSyncedToCurrentChain()) {
    14+    // As index sync failures trigger a shutdown request without notifying BlockUntilSyncedToCurrentChain in any way,
    15+    // we also need to check whether a shutdown was requested or not. Otherwise, any error inside the index sync process
    16+    // will hang the test forever.
    17+    while (!ShutdownRequested() && !index.BlockUntilSyncedToCurrentChain()) {
    


    maflcko commented at 1:26 pm on July 7, 2023:
    I think you can just check Assert(!ShutdownRequested()) inside the loop, to give a better error message when an internal error causes a shutdown, instead of breaking out of the loop and then asserting synced?

    furszy commented at 2:04 pm on July 7, 2023:
    pushed.
  5. maflcko approved
  6. maflcko commented at 1:27 pm on July 7, 2023: member
    lgtm
  7. furszy force-pushed on Jul 7, 2023
  8. maflcko commented at 2:08 pm on July 7, 2023: member

    Nice, thank you.

    lgtm ACK 4b405318d4c476351cccc30588f9126edd94cc35

  9. maflcko commented at 10:12 am on July 8, 2023: member

    Can be tested on current master with:

     0diff --git a/src/index/base.cpp b/src/index/base.cpp
     1index cf07cae286..2987eeb97b 100644
     2--- a/src/index/base.cpp
     3+++ b/src/index/base.cpp
     4@@ -234,6 +234,7 @@ void BaseIndex::ThreadSync()
     5                            __func__, pindex->GetBlockHash().ToString());
     6                 return;
     7             }
     8+            return FatalErrorf("foobar");
     9         }
    10     }
    11 
    

    Result on master:

     0$ ./src/test/test_bitcoin -t blockfilter_index_tests 
     1Running 2 test cases...
     2Error: A fatal internal error occurred, see debug.log for details
     3
     4
     5...
     6
     7
     8Never finishes ...
     9...
    10^C
    

    Result with this pull applied, immediate crash:

     0$ ./src/test/test_bitcoin -t blockfilter_index_tests 
     1Running 2 test cases...
     2Error: A fatal internal error occurred, see debug.log for details
     3test/util/index.cpp:18 IndexWaitSynced: Assertion `!ShutdownRequested()' failed.
     4unknown location(0): fatal error: in "blockfilter_index_tests/blockfilter_index_initial_sync": signal: SIGABRT (application abort requested)
     5test/blockfilter_index_tests.cpp(142): last checkpoint
     6test_bitcoin: common/args.cpp:577: void ArgsManager::AddArg(const std::string &, const std::string &, unsigned int, const OptionsCategory &): Assertion `ret.second' failed.
     7unknown location(0): fatal error: in "blockfilter_index_tests/blockfilter_index_init_destroy": signal: SIGABRT (application abort requested)
     8test/blockfilter_index_tests.cpp(272): last checkpoint: "blockfilter_index_init_destroy" fixture ctor
     9
    10*** 2 failures are detected in the test module "Bitcoin Core Test Suite"
    11test_bitcoin: checkqueue.h:198: CCheckQueue<CScriptCheck>::~CCheckQueue() [T = CScriptCheck]: Assertion `m_worker_threads.empty()' failed.
    12Aborted (core dumped)
    
  10. maflcko added this to the milestone 26.0 on Jul 8, 2023
  11. in src/test/util/index.cpp:15 in 4b405318d4 outdated
    10 #include <util/time.h>
    11 
    12 void IndexWaitSynced(const BaseIndex& index)
    13 {
    14     while (!index.BlockUntilSyncedToCurrentChain()) {
    15+        // As index sync failures trigger a shutdown request without notifying BlockUntilSyncedToCurrentChain in any way,
    


    ryanofsky commented at 5:49 pm on July 10, 2023:

    In commit “test: indexes, fix on error infinite loop” (4b405318d4c476351cccc30588f9126edd94cc35)

    I found “As index sync failures” comment difficult to understand because it was hard to see how it directly related to code. Would suggest something more literal like “Assert shutdown was not requested to abort the test, instead of looping forever, in case there was an unexpected error in the index that caused it to stop syncing and request a shutdown”


    furszy commented at 6:24 pm on July 10, 2023:
    hmm ok. What I meant with the “As index sync failures” comment is that all index sync errors trigger a shutdown.
  12. ryanofsky approved
  13. ryanofsky commented at 5:51 pm on July 10, 2023: contributor
    Code review ACK 4b405318d4c476351cccc30588f9126edd94cc35
  14. test: indexes, fix on error infinite loop
    As index sync failures trigger a shutdown request without notifying
    BaseIndex::BlockUntilSyncedToCurrentChain in any way, we also need
    to check whether a shutdown was requested or not inside 'IndexWaitSynced'.
    
    Otherwise, any error inside the index sync process will hang the test
    forever.
    89ba8905f5
  15. furszy force-pushed on Jul 10, 2023
  16. furszy commented at 6:28 pm on July 10, 2023: member
    Updated comment per feedback. Thanks ryanofsky.
  17. jamesob approved
  18. jamesob commented at 4:05 pm on July 11, 2023: member

    ACK 89ba890

    Built/tested locally. Seems like a commonsense way to assert-fail instead of causing an infinite loop on CI machines.

  19. DrahtBot requested review from maflcko on Jul 11, 2023
  20. DrahtBot requested review from ryanofsky on Jul 11, 2023
  21. maflcko commented at 4:09 pm on July 11, 2023: member
    lgtm ACK 89ba8905f5c68ae29412f9c4010314c5a113c234
  22. DrahtBot removed review request from maflcko on Jul 11, 2023
  23. ryanofsky approved
  24. ryanofsky commented at 4:10 pm on July 11, 2023: contributor
    Code review ACK 89ba8905f5c68ae29412f9c4010314c5a113c234. Just comment update since last review
  25. ryanofsky merged this on Jul 11, 2023
  26. ryanofsky closed this on Jul 11, 2023

  27. sidhujag referenced this in commit 7adb772c88 on Jul 12, 2023
  28. furszy deleted the branch on Jul 20, 2023
  29. bitcoin locked this on Jul 19, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me