The regression was introduced in #19056: if the GUI is running without -server=1
, the *txoutset*
call in the console returns “Shutting down”.
Fix #19255.
996@@ -997,7 +997,7 @@ static UniValue gettxoutsetinfo(const JSONRPCRequest& request)
997 ::ChainstateActive().ForceFlushStateToDisk();
998
999 CCoinsView* coins_view = WITH_LOCK(cs_main, return &ChainstateActive().CoinsDB());
1000- if (GetUTXOStats(coins_view, stats, RpcInterruptionPoint)) {
1001+ if (GetUTXOStats(coins_view, stats, IsRPCRunning() ? RpcInterruptionPoint : [] {})) {
Also, it seems racy when the rpc is shut down during flush (which might take a long time)
Maybe the interruption point can be passed in through the request
similar to how the connman is passed in?
Also, it seems racy when the rpc is shut down during flush (which might take a long time)
Did not get why. IsRPCRunning()
is checked after synchronous ForceFlushStateToDisk()
call. During GUI shutdown #17659 should ensure the correct RPCConsole
behavior.
gettxoutsetinfo
stop
-> Doesn’t stop because gettxoutsetinfo is not interruptiblegettxoutsetinfo
finishes and server stopsThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Updated 369f5d263ee5a26b62545b604ee0b33f24eaadfa -> 434f74365ebb265bcf04bbb1c87d368b5c6553a4 (pr19323.01 -> pr19323.02, diff):
Also, it seems racy when the rpc is shut down during flush (which might take a long time)
Maybe the interruption point can be passed in through the
request
similar to how the connman is passed in?
weak review ACK 434f74365ebb265bcf04bbb1c87d368b5c6553a4
cc @ryanofsky is the use of NodeContext
here appropriate?
Code review ACK 434f74365ebb265bcf04bbb1c87d368b5c6553a4 with followup suggestions below.
weak review ACK 434f743
cc @ryanofsky is the use of
NodeContext
here appropriate?
This seems ok as a workaround but IMO better would be to eliminate g_rpc_running
global. Might do that by moving g_rpc_running and g_rpcSignals into an RpcContext struct, adding a unique_ptr<RpcContext> or RpcContext* member to NodeContext, and passing RpcContext& to StartRPC/InterruptRPC/StopRPC.
A more immediate concern with this PR is it that it seems incomplete. I see 4 references to RpcInterruptionPoint that will throw in the GUI, but 434f74365ebb265bcf04bbb1c87d368b5c6553a4 is only fixing one of the four:
https://github.com/bitcoin/bitcoin/blob/5f72ddb7ee4cc177de31f43c69390ee72687222a/src/rpc/blockchain.cpp#L1000 https://github.com/bitcoin/bitcoin/blob/5f72ddb7ee4cc177de31f43c69390ee72687222a/src/rpc/blockchain.cpp#L1979 https://github.com/bitcoin/bitcoin/blob/5f72ddb7ee4cc177de31f43c69390ee72687222a/src/rpc/blockchain.cpp#L2319 https://github.com/bitcoin/bitcoin/blob/5f72ddb7ee4cc177de31f43c69390ee72687222a/src/rpc/blockchain.cpp#L2337
Updated 434f74365ebb265bcf04bbb1c87d368b5c6553a4 -> e75b125264e8dc8115fd035b1334b023a4913a11 (pr19323.02 -> pr19323.03, diff):
A more immediate concern with this PR is it that it seems incomplete. I see 4 references to RpcInterruptionPoint that will throw in the GUI, but 434f743 is only fixing one of the four
Re: #19323#pullrequestreview-434066791
This seems ok as a workaround but IMO better would be to eliminate
g_rpc_running
global. Might do that by moving g_rpc_running and g_rpcSignals into an RpcContext struct, adding a unique_ptr or RpcContext* member to NodeContext, and passing RpcContext& to StartRPC/InterruptRPC/StopRPC.
These changes appear non-trivial as g_rpc_running
is used in IsRPCRunning()
, and its usage is too broad.
2146@@ -2143,7 +2147,8 @@ UniValue scantxoutset(const JSONRPCRequest& request)
2147 tip = ::ChainActive().Tip();
2148 CHECK_NONFATAL(tip);
2149 }
2150- bool res = FindScriptPubKey(g_scan_progress, g_should_abort_scan, count, pcursor.get(), needles, coins);
2151+ NodeContext& node = EnsureNodeContext(request.context);
2152+ bool res = FindScriptPubKey(g_scan_progress, g_should_abort_scan, count, pcursor.get(), needles, coins, node);
nit: why not pass in the rpc_interruption_point
like below for GetUTXOStats
?
0 bool res = FindScriptPubKey(g_scan_progress, g_should_abort_scan, count, pcursor.get(), needles, coins, node.rpc_interruption_point);
Updated e75b125264e8dc8115fd035b1334b023a4913a11 -> 44ef1170cf1466bfa3ea296c78b821605caa0311 (pr19323.03 -> pr19323.04, diff):
nit: why not pass in the
rpc_interruption_point
like below forGetUTXOStats
?
Code review ACK 44ef1170cf1466bfa3ea296c78b821605caa0311. Only change since last review is replacing more uses of RpcInterruptionPoint that could also throw and fail unexpectedly.
I think there is room to improve this in the future. RPC globals be eliminated as described #19323#pullrequestreview-434066791. Also more importantly these methods should always be interrupted when the gui is shutting down, whether or not -server=0 or -server=1 is used, not just when -server=1 is used.
Review ACK 44ef1170cf1466bfa3ea296c78b821605caa0311 , checked that all RpcInterruptionPoint are replaced by node.rpc_interruption_point 👥
Signature:
0-----BEGIN PGP SIGNED MESSAGE-----
1Hash: SHA512
2
3Review ACK 44ef1170cf1466bfa3ea296c78b821605caa0311 , checked that all RpcInterruptionPoint are replaced by node.rpc_interruption_point 👥
4-----BEGIN PGP SIGNATURE-----
5
6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
7pUiyEgwAzwkY2V+cNbtFvl4G/65/9I3dhHDE68NmHRgq6qQxP0/oA4MKcUrSjaoO
8naJMn9LP4L8NMmNR3VQe9lhxu63qzhymxRYCzJJRkXHAWQ1WQMapMsR1NN1861VG
9c3Zz0/t6okQHx1o6N5XwMx1YiecPcMEs8h61JGXLq1f17ECVRI8z5oSo4nL3j+FH
10oeS4iIszG46CSWlueqZE7Vq7h7J1aEVj3CidHIPsopYRs/WhlvkQDAIkoxqdbWIU
11xpk/wQZzUWOFL9C0dhMVybvouJW3ZPuw+AnS11nPBkagmw7DLUZ13+u4kon2qi6a
12UNJA670fqlR0mEK6scKy3/PoRJCPl2z05iyB4Kcxv7/FISPQOc9MJ1IZ/fuyikn7
139XsTITd5C+7a3KUEaROe94tEsTOJJ+ZrvAgzNQ93coy+f7LnPyMOLTGVUPagmNpY
14B8lpF7manTmkKjuzCHKUXzTqq0505eXYvGP7L+kGmiPxA69ajEbBGgdqKvPv+/NC
15ntWM9mto
16=KOfS
17-----END PGP SIGNATURE-----
Timestamp of file with hash 30e3c19b4b83028940a62fea9a5feb72bad494a01063d4dacab284af3dfd0f8a -
This change prevents "Shutting down" message during "dumptxoutset",
"gettxoutsetinfo" and "scantxoutset" calls.