qa: Reduce `-maxconnections` in the functional test framework #36078

pull hebasto wants to merge 2 commits into bitcoin:master from hebasto:260825-maxconnections changing 2 files +15 −11
  1. hebasto commented at 1:19 PM on August 25, 2026: member

    This PR follows up on bitcoin/bitcoin#35730 and fixes a regression on NetBSD.

    Since bitcoin/bitcoin#35730 the HTTP server reserves file descriptors for its listen sockets and for -rpcmaxconnections connected clients (16 by default), so min_required_fds in init.cpp grew.

    On select()-based platforms available_fds is capped at FD_SETSIZE, which is 256 on NetBSD. The previous value of 94 no longer fits and every node in the test suite started up with a warning, which the framework treats as unexpected stderr and fails on.

    Recompute the value with the new accounting (256 - 179 = 77) and update the comment to match the current variable names in init.cpp.

  2. hebasto added the label Tests on Aug 25, 2026
  3. DrahtBot commented at 1:19 PM on August 25, 2026: 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/36078.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK hodlinator, winterrdog, achow101
    Concept ACK pinheadmz

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. hebasto commented at 1:21 PM on August 25, 2026: member
  5. hebasto added this to the milestone 32.0 on Aug 25, 2026
  6. hodlinator approved
  7. hodlinator commented at 1:28 PM on August 25, 2026: contributor

    utcrACK 4669defc0f3495060938818f94d2669fec5b1a68

  8. in test/functional/test_framework/util.py:571 in 4669defc0f outdated
     574 | -        #  nMaxConnections = available_fds - min_required_fds = 256 - 161 = 94;
     575 | -        f.write("maxconnections=94\n")
     576 | +        #  min_required_fds = MIN_CORE_FDS + MAX_ADDNODE_CONNECTIONS + num_p2p_bind + num_rpc_bind + DEFAULT_MAX_HTTP_CONNECTIONS =
     577 | +        #    = 151 + 8 + 2 + 2 + 16 = 179;
     578 | +        #  num_p2p_max_connections = available_fds - min_required_fds = 256 - 179 = 77;
     579 | +        f.write("maxconnections=77\n")
    


    winterrdog commented at 2:04 PM on August 25, 2026:

    nit / just curious, since this value has had to change a few times (across years) would it make sense to encode the maxconnections's calculation in the code? something along the lines of deriving it from the FD budget constants & using the resulting value, rather than hardcoding a value like 77

    just wondering if there is a reason to prefer the static value


    hebasto commented at 3:54 PM on August 25, 2026:

    nit / just curious, since this value has had to change a few times (across years) would it make sense to encode the maxconnections's calculation in the code?

    Wouldn't this require the test framework to duplicate the constants from the C++ code? Also, some of the inputs, such as "maximum number of bound P2P interfaces", depend on how particular tests are written rather than on anything bitcoind exposes.

  9. winterrdog commented at 2:17 PM on August 25, 2026: contributor

    crACK 4669defc0f3495060938818f94d2669fec5b1a68

  10. hebasto commented at 2:41 PM on August 25, 2026: member

    See the CI run on NetBSD here: https://github.com/hebasto/bitcoin-core-nightly/actions/runs/32852803381.

    Unfortunately, some test fail.

    interface_http.py:

    test_framework.test_node.FailedToStartError: [node 0] bitcoind exited with status 1 during initialization. Error: Not enough file descriptors available. 256 available, 290 required.
    

    p2p_getaddr_caching.py:

    AssertionError: Unexpected stderr Warning: Reducing -maxconnections from 77 to 76, because of system limitations. != 
    
  11. janb84 commented at 2:43 PM on August 25, 2026: contributor

    Code looks good but the CI still fails :(

  12. hebasto commented at 3:00 PM on August 25, 2026: member

    p2p_getaddr_caching.py:

    AssertionError: Unexpected stderr Warning: Reducing -maxconnections from 77 to 76, because of system limitations. != 
    

    This test uses 2 extra -bind options, so num_p2p_bind should be 3.

  13. hebasto force-pushed on Aug 25, 2026
  14. pinheadmz commented at 3:43 PM on August 25, 2026: member

    concept ACK, setting up a BSD VM to test locally...

  15. hebasto commented at 3:44 PM on August 25, 2026: member

    Reworked.

    The CI on NetBSD is available here: https://github.com/hebasto/bitcoin-core-nightly/actions/runs/32867589050.

  16. qa: Reduce `-maxconnections` in the functional test framework
    Since bitcoin/bitcoin#35730 the HTTP server reserves file descriptors
    for its listen sockets and for `-rpcmaxconnections` connected clients
    (16 by default), so `min_required_fds` in init.cpp grew.
    
    On select()-based platforms `available_fds` is capped at FD_SETSIZE,
    which is 256 on NetBSD. The previous value of 94 no longer fits and
    every node in the test suite started up with a warning, which the
    framework treats as unexpected stderr and fails on.
    
    Recompute the value with the new accounting (256 - 179 = 77) and
    update the comment to match the current variable names in init.cpp.
    6f4109b448
  17. qa: Lower `-rpcmaxconnections` in `interface_http.py` test
    On some systems, such as NetBSD, the non-default
    `-rpcmaxconnections=128` is too high, so bitcoind refuses to start:
    ```
    Error: Not enough file descriptors available. 256 available, 290 required.
    ```
    
    The test only needs a value above the default of 16. Use 64 and lower
    `-maxconnections` in that case so the total fits in 256.
    b8a8893bf2
  18. in test/functional/test_framework/util.py:571 in 6c7358f102
     574 | -        #  nMaxConnections = available_fds - min_required_fds = 256 - 161 = 94;
     575 | -        f.write("maxconnections=94\n")
     576 | +        #  min_required_fds = MIN_CORE_FDS + MAX_ADDNODE_CONNECTIONS + num_p2p_bind + num_rpc_bind + DEFAULT_MAX_HTTP_CONNECTIONS =
     577 | +        #    = 151 + 8 + 3 + 2 + 16 = 180;
     578 | +        #  num_p2p_max_connections = available_fds - min_required_fds = 256 - 180 = 76;
     579 | +        f.write("maxconnections=77\n")
    


    hodlinator commented at 3:46 PM on August 25, 2026:

    76 != 77 ?

            #  num_p2p_max_connections = available_fds - min_required_fds = 256 - 180 = 76;
            f.write("maxconnections=76\n")
    

    hebasto commented at 3:55 PM on August 25, 2026:

    Thanks! Fixed.

  19. hebasto force-pushed on Aug 25, 2026
  20. DrahtBot added the label CI failed on Aug 25, 2026
  21. hebasto commented at 3:56 PM on August 25, 2026: member
  22. hodlinator approved
  23. hodlinator commented at 5:17 PM on August 25, 2026: contributor

    re-ACK b8a8893bf2a101e24f63902097c59ec0baddabb5

  24. DrahtBot requested review from winterrdog on Aug 25, 2026
  25. DrahtBot requested review from pinheadmz on Aug 25, 2026
  26. winterrdog commented at 5:18 PM on August 25, 2026: contributor

    re-ACK b8a8893bf2a101e24f63902097c59ec0baddabb5

  27. DrahtBot removed the label CI failed on Aug 25, 2026
  28. achow101 commented at 6:25 PM on August 25, 2026: member

    ACK b8a8893bf2a101e24f63902097c59ec0baddabb5

  29. achow101 merged this on Aug 25, 2026
  30. achow101 closed this on Aug 25, 2026

  31. hebasto deleted the branch on Aug 25, 2026
  32. pinheadmz commented at 7:50 PM on August 25, 2026: member

    post-merge ACK b8a8893bf2a101e24f63902097c59ec0baddabb5

    Confirmed the regression locally in NetBSD VM (macos arm64 qemu) and verified the fix.


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-31 17:51 UTC

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