Skip to content

Commit f3e747e

Browse files
author
MarcoFalke
committed
Merge #13201: [qa] Handle disconnect_node race
09c6699 [qa] Handle disconnect_node race (Suhas Daftuar) Pull request description: Several tests call disconnect_nodes() on each node-pair in rapid succession, resulting in a race condition if a node disconnects a peer in-between the calculation of the nodeid's to disconnect and the invocation of the disconnectnode rpc call. Handle this. Tree-SHA512: 3078cea0006fcb507c812004a777c505eb1e9dda7c6df12dbbe72395a73ff6f6760f597b6492054f5487b34534417ddef5fbad30553c135c288c4b7cfce79223
2 parents 196c5a9 + 09c6699 commit f3e747e

File tree

1 file changed

+8
-1
lines changed
  • test/functional/test_framework

1 file changed

+8
-1
lines changed

test/functional/test_framework/util.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,14 @@ def set_node_times(nodes, t):
352352

353353
def disconnect_nodes(from_connection, node_num):
354354
for peer_id in [peer['id'] for peer in from_connection.getpeerinfo() if "testnode%d" % node_num in peer['subver']]:
355-
from_connection.disconnectnode(nodeid=peer_id)
355+
try:
356+
from_connection.disconnectnode(nodeid=peer_id)
357+
except JSONRPCException as e:
358+
# If this node is disconnected between calculating the peer id
359+
# and issuing the disconnect, don't worry about it.
360+
# This avoids a race condition if we're mass-disconnecting peers.
361+
if e.error['code'] != -29: # RPC_CLIENT_NODE_NOT_CONNECTED
362+
raise
356363

357364
# wait to disconnect
358365
wait_until(lambda: [peer['id'] for peer in from_connection.getpeerinfo() if "testnode%d" % node_num in peer['subver']] == [], timeout=5)

0 commit comments

Comments
 (0)