test: Fix intermittent issue in p2p_orphan_handling.py #32092

pull maflcko wants to merge 1 commits into bitcoin:master from maflcko:2503-test-orph changing 2 files +3 −1
  1. maflcko commented at 4:30 PM on March 18, 2025: member

    The test may fail intermittently when the net thread is lagging while calling DeleteNode. This may result in a split getdata, meaning that peer2.wait_for_parent_requests([int(parent_peekaboo_AB["txid"], 16), int(parent_missing["txid"], 16)]) fails.

    Fix it by adding a sync on the net thread.

    Fixes #31700

  2. DrahtBot commented at 4:30 PM on March 18, 2025: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32092.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK mzumsande

    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 Mar 18, 2025
  4. maflcko commented at 4:31 PM on March 18, 2025: member

    Can be tested by the diff provided by @tnndbtc in #32063 (comment) (thanks!):

    diff --git a/src/net.cpp b/src/net.cpp
    index 735985a841..2bb6db0cf7 100644
    --- a/src/net.cpp
    +++ b/src/net.cpp
    @@ -1965,6 +1965,9 @@ void CConnman::DisconnectNodes()
                 // Destroy the object only after other threads have stopped using it.
                 if (pnode->GetRefCount() <= 0) {
                     m_nodes_disconnected.remove(pnode);
    +
    +                std::this_thread::sleep_for(std::chrono::seconds(1)); // SLEEP for 1 second to 100% reproduce the issue
    +
                     DeleteNode(pnode);
                 }
             }
    
  5. fanquake requested review from instagibbs on Mar 18, 2025
  6. fanquake requested review from mzumsande on Mar 18, 2025
  7. in test/functional/p2p_orphan_handling.py:793 in fa8c344584 outdated
     788 | @@ -789,6 +789,7 @@ def test_parents_change(self):
     789 |          # Disconnect peer1. peer2 should become the new candidate for orphan resolution.
     790 |          peer1.peer_disconnect()
     791 |          self.wait_until(lambda: node.num_test_p2p_connections() == 1)
     792 | +        peer2.sync_with_ping()  # Sync with the 'net' thread which completes the disconnection fully
     793 |          node.bumpmocktime(TXREQUEST_TIME_SKIP)
    


    mzumsande commented at 11:56 PM on March 18, 2025:

    it would be good to also add a comment in disconnect_p2ps that the wait there does not guarantee that the resources of all nodes (such as outstanding txrequests) are cleared.


    maflcko commented at 7:21 PM on March 19, 2025:

    thx, done

  8. test: Fix intermittent issue in p2p_orphan_handling.py fa310cc6f4
  9. maflcko force-pushed on Mar 19, 2025
  10. mzumsande commented at 3:50 PM on March 20, 2025: contributor

    Code Review ACK fa310cc6f499e3e3dd58dc382e04e9db3f02bc3b

  11. fanquake merged this on Mar 21, 2025
  12. fanquake closed this on Mar 21, 2025

  13. maflcko deleted the branch on Mar 21, 2025
  14. sedited referenced this in commit a9c46ce3c3 on Apr 24, 2025
  15. stickies-v referenced this in commit 772a33e052 on May 23, 2025
  16. yuvicc referenced this in commit 069643f094 on Jul 6, 2025
  17. bug-castercv502 referenced this in commit 5b0af4b944 on Sep 28, 2025
  18. Kino1994 referenced this in commit 2a9049b6c9 on Jun 28, 2026
  19. BigcoinBGC referenced this in commit d031226b24 on Jun 30, 2026
  20. bitcoin locked this on Jul 30, 2026

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: 2026-08-03 23:51 UTC

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