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

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

    Code Coverage & Benchmarks

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

    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!):

     0diff --git a/src/net.cpp b/src/net.cpp
     1index 735985a841..2bb6db0cf7 100644
     2--- a/src/net.cpp
     3+++ b/src/net.cpp
     4@@ -1965,6 +1965,9 @@ void CConnman::DisconnectNodes()
     5             // Destroy the object only after other threads have stopped using it.
     6             if (pnode->GetRefCount() <= 0) {
     7                 m_nodes_disconnected.remove(pnode);
     8+
     9+                std::this_thread::sleep_for(std::chrono::seconds(1)); // SLEEP for 1 second to 100% reproduce the issue
    10+
    11                 DeleteNode(pnode);
    12             }
    13         }
    
  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


maflcko DrahtBot mzumsande


instagibbs

Labels
Tests


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: 2025-03-28 15:12 UTC

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