Replace the bitcoin-cli -rpcwait after spawning bitcoind with our own loop that detects when bitcoind exits prematurely (before RPC is up).
This prevents a hang in such a case (see #7463).
Not ready to merge yet. I've tested this with a -salvagewallet loop:
Unexpected exception caught during testing: bitcoind exited with status 1 during initialization
File "/data/src/bitcoin/qa/rpc-tests/test_framework/test_framework.py", line 135, in main
self.run_test()
File "./wallet.py", line 295, in run_test
self.nodes = start_nodes(3, self.options.tmpdir, [[m]] * 3)
File "/data/src/bitcoin/qa/rpc-tests/test_framework/util.py", line 283, in start_nodes
return [ start_node(i, dirname, extra_args[i], rpchost, binary=binary[i]) for i in range(num_nodes) ]
File "/data/src/bitcoin/qa/rpc-tests/test_framework/util.py", line 267, in start_node
wait_for_bitcoind_start(bitcoind_processes[i], url, i)
File "/data/src/bitcoin/qa/rpc-tests/test_framework/util.py", line 144, in wait_for_bitcoind_start
raise Exception('bitcoind exited with status %i during initialization' % process.returncode)
Stopping nodes
Even though reporting is better, it still hangs after "Stopping nodes", going to investigate why.
Should be fixed now. The problem was that start_nodes can fail with part of the nodes already started.
wait_bitcoinds will subsequently wait forever for them to exit (as it uses a global variable to communicate bitcoind_processes).
One-to-last commit makes sure that they're stopped properly in that case.
Replace the `bitcoin-cli -rpcwait` after spawning bitcoind
with our own loop that detects when bitcoind exits prematurely.
And if one node fails to start, stop the others.
This prevents a hang in such a case (see #7463).
279 | @@ -267,7 +280,14 @@ def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None): 280 | """ 281 | if extra_args is None: extra_args = [ None for i in range(num_nodes) ] 282 | if binary is None: binary = [ None for i in range(num_nodes) ] 283 | - return [ start_node(i, dirname, extra_args[i], rpchost, binary=binary[i]) for i in range(num_nodes) ] 284 | + rpcs = [] 285 | + try: 286 | + for i in range(num_nodes): 287 | + rpcs.append(start_node(i, dirname, extra_args[i], rpchost, binary=binary[i])) 288 | + except: # If one node failed to start, stop the others
Nice!
Good idea! utACK 018b60c5ea703ed12edcde034a185f79e77e5576
utACK 018b60c
130 | @@ -130,11 +131,33 @@ def initialize_datadir(dirname, n): 131 | f.write("listenonion=0\n") 132 | return datadir 133 | 134 | +def rpc_url(i, rpchost=None): 135 | + return "http://rt:rt@%s:%d" % (rpchost or '127.0.0.1', rpc_port(i))
Nit: rpcbind_test.py no longer works after this.
We should probably re-add that test to one of the standard sequence, otherwise it will just bitrot