-
Notifications
You must be signed in to change notification settings - Fork 36.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gui: Fix regression in *txoutset* in GUI console #19323
Conversation
src/rpc/blockchain.cpp
Outdated
@@ -997,7 +997,7 @@ static UniValue gettxoutsetinfo(const JSONRPCRequest& request) | |||
::ChainstateActive().ForceFlushStateToDisk(); | |||
|
|||
CCoinsView* coins_view = WITH_LOCK(cs_main, return &ChainstateActive().CoinsDB()); | |||
if (GetUTXOStats(coins_view, stats, RpcInterruptionPoint)) { | |||
if (GetUTXOStats(coins_view, stats, IsRPCRunning() ? RpcInterruptionPoint : [] {})) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the rpc code needs such a workaround for the gui, I'd prefer to at least explain it with a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it self-documented: "interrupt RPC only if RPC is running"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gettxoutsetinfo
stop
-> Doesn't stop because gettxoutsetinfo is not interruptiblegettxoutsetinfo
finishes and server stops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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 369f5d2 -> 434f743 (pr19323.01 -> pr19323.02, diff):
|
weak review ACK 434f743 cc @ryanofsky is the use of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 434f743 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 434f743 is only fixing one of the four:
bitcoin/src/rpc/blockchain.cpp
Line 1000 in 5f72ddb
if (GetUTXOStats(coins_view, stats, RpcInterruptionPoint)) { |
bitcoin/src/rpc/blockchain.cpp
Line 1979 in 5f72ddb
RpcInterruptionPoint(); |
bitcoin/src/rpc/blockchain.cpp
Line 2319 in 5f72ddb
if (!GetUTXOStats(&::ChainstateActive().CoinsDB(), stats, RpcInterruptionPoint)) { |
bitcoin/src/rpc/blockchain.cpp
Line 2337 in 5f72ddb
if (iter % 5000 == 0) RpcInterruptionPoint(); |
Updated 434f743 -> e75b125 (pr19323.02 -> pr19323.03, diff):
Re: #19323 (review)
These changes appear non-trivial as |
Updated e75b125 -> 44ef117 (pr19323.03 -> pr19323.04, diff):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 44ef117. 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 (review). 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 44ef117 , checked that all RpcInterruptionPoint are replaced by node.rpc_interruption_point 👥 Show signature and timestampSignature:
Timestamp of file with hash |
This change prevents "Shutting down" message during "dumptxoutset", "gettxoutsetinfo" and "scantxoutset" calls.
Rebased 44ef117 -> 314b49b (pr19323.04 -> pr19323.05) due to the conflict with #19328. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 314b49b. Only change since last review is rebase
314b49b gui: Fix regression in GUI console (Hennadii Stepanov) Pull request description: The regression was introduced in bitcoin#19056: if the GUI is running without `-server=1`, the `*txoutset*` call in the console returns "Shutting down". Fix bitcoin#19255. ACKs for top commit: ryanofsky: Code review ACK 314b49b. Only change since last review is rebase Tree-SHA512: 8ff85641a5c249858fecb1ab69c7a1b2850af651ff2a94aa41ce352b5b5bc95bc45c41e1767e871b51e647612d09e4d54ede3e20c313488afef5678826c51b62
Summary: ``` Make it interruptible, so that shutdown doesn't block for up to one hour. ``` Backport of core [[bitcoin/bitcoin#19056 | PR19056]] and [[bitcoin/bitcoin#19323 | PR19323]] (bugfix). Test Plan: ninja all check-all Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D8645
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.