Skip to content

Commit b91d983

Browse files
committed
Merge bitcoin/bitcoin#36078: qa: Reduce -maxconnections in the functional test framework
b8a8893 qa: Lower `-rpcmaxconnections` in `interface_http.py` test (Hennadii Stepanov) 6f4109b qa: Reduce `-maxconnections` in the functional test framework (Hennadii Stepanov) Pull request description: This PR follows up on bitcoin/bitcoin#35730 and fixes a [regression](bitcoin/bitcoin#35730 (comment)) 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`. ACKs for top commit: achow101: ACK b8a8893 hodlinator: re-ACK b8a8893 winterrdog: re-ACK b8a8893 Tree-SHA512: d6200cc334b98148d71992b1d085ca8f72ba68d330b26d7ba373a0917cca56a444b8d89b0c0827e2a56242893b268e9f581bffc8a631a2ff20cc51f10db3255e
2 parents 0f5c6d0 + b8a8893 commit b91d983

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

test/functional/interface_http.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,10 @@ def check_connection_limit(self):
612612

613613
# Disable timeout so the initial batch of clients stays connected
614614
# until the end of the test.
615-
for comment, extra_args, limit in [
616-
("default (16)", ["-rpcservertimeout=0", "-rest"], 16),
617-
("-rpcmaxconnections=128", ["-rpcservertimeout=0", "-rest", "-rpcmaxconnections=128"], 128)
615+
for comment, extra_args, limit in [
616+
("default (16)", ["-rpcservertimeout=0", "-rest"], 16),
617+
("-rpcmaxconnections=64", ["-rpcservertimeout=0", "-rest",
618+
"-rpcmaxconnections=64", "-maxconnections=16"], 64)
618619
]:
619620
self.log.info(f"Using connection limit: {comment}")
620621
self.restart_node(0, extra_args=extra_args)

test/functional/test_framework/util.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -557,15 +557,18 @@ def write_config(config_path, *, n, chain, extra_config="", disable_autoconnect=
557557
f.write("connect=0\n")
558558
# Limit max connections to mitigate test failures on some systems caused by the warning:
559559
# "Warning: Reducing -maxconnections from <...> to <...> due to system limitations".
560-
# The value is calculated as follows:
561-
# available_fds = 256 // Same as FD_SETSIZE on NetBSD.
562-
# MIN_CORE_FDS = 151 // Number of file descriptors required for core functionality.
563-
# MAX_ADDNODE_CONNECTIONS = 8 // Maximum number of -addnode outgoing nodes.
564-
# nBind == 3 // Maximum number of bound interfaces used in a test.
560+
# For details, consult the `AppInitParameterInteraction` function in src/init.cpp.
561+
# available_fds = 256 // Same as FD_SETSIZE on NetBSD.
562+
# MIN_CORE_FDS = 151 // Number of file descriptors required for core functionality.
563+
# MAX_ADDNODE_CONNECTIONS = 8 // Maximum number of -addnode outgoing nodes.
564+
# num_p2p_bind = 3 // Maximum number of bound P2P interfaces (-bind and -whitebind) used in a test.
565+
# num_rpc_bind = 2 // Maximum number of HTTP sockets used in a test.
566+
# DEFAULT_MAX_HTTP_CONNECTIONS = 16 // Reserved for connected HTTP clients.
565567
#
566-
# min_required_fds = MIN_CORE_FDS + MAX_ADDNODE_CONNECTIONS + nBind = 151 + 8 + 3 = 162;
567-
# nMaxConnections = available_fds - min_required_fds = 256 - 161 = 94;
568-
f.write("maxconnections=94\n")
568+
# min_required_fds = MIN_CORE_FDS + MAX_ADDNODE_CONNECTIONS + num_p2p_bind + num_rpc_bind + DEFAULT_MAX_HTTP_CONNECTIONS =
569+
# = 151 + 8 + 3 + 2 + 16 = 180;
570+
# num_p2p_max_connections = available_fds - min_required_fds = 256 - 180 = 76;
571+
f.write("maxconnections=76\n")
569572
f.write("par=" + str(min(2, os.cpu_count())) + "\n")
570573
# Use a single prevoutfetch worker thread to keep per-node resource usage low.
571574
f.write("prevoutfetchthreads=1\n")

0 commit comments

Comments
 (0)