Skip to content
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

Merged
merged 1 commit into from
Jul 14, 2020

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Jun 18, 2020

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.

@@ -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 : [] {})) {
Copy link
Member

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

Copy link
Member Author

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"?

Copy link
Member

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?

Copy link
Member Author

@hebasto hebasto Jun 18, 2020

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.

Copy link
Member

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 interruptible
  • gettxoutsetinfo finishes and server stops

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maflcko maflcko added this to the 0.21.0 milestone Jun 18, 2020
@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 19, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

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.

@hebasto
Copy link
Member Author

hebasto commented Jun 19, 2020

Updated 369f5d2 -> 434f743 (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?

@maflcko
Copy link
Member

maflcko commented Jun 19, 2020

weak review ACK 434f743

cc @ryanofsky is the use of NodeContext here appropriate?

Copy link
Contributor

@ryanofsky ryanofsky left a 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:

if (GetUTXOStats(coins_view, stats, RpcInterruptionPoint)) {

RpcInterruptionPoint();

if (!GetUTXOStats(&::ChainstateActive().CoinsDB(), stats, RpcInterruptionPoint)) {

if (iter % 5000 == 0) RpcInterruptionPoint();

@hebasto
Copy link
Member Author

hebasto commented Jun 19, 2020

Updated 434f743 -> e75b125 (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 (review)

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.

src/rpc/blockchain.cpp Outdated Show resolved Hide resolved
@hebasto
Copy link
Member Author

hebasto commented Jun 20, 2020

Updated e75b125 -> 44ef117 (pr19323.03 -> pr19323.04, diff):

nit: why not pass in the rpc_interruption_point like below for GetUTXOStats?

Copy link
Contributor

@ryanofsky ryanofsky left a 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.

@maflcko
Copy link
Member

maflcko commented Jul 2, 2020

Review ACK 44ef117 , checked that all RpcInterruptionPoint are replaced by node.rpc_interruption_point 👥

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Review ACK 44ef1170cf1466bfa3ea296c78b821605caa0311 , checked that all RpcInterruptionPoint are replaced by node.rpc_interruption_point 👥
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUiyEgwAzwkY2V+cNbtFvl4G/65/9I3dhHDE68NmHRgq6qQxP0/oA4MKcUrSjaoO
naJMn9LP4L8NMmNR3VQe9lhxu63qzhymxRYCzJJRkXHAWQ1WQMapMsR1NN1861VG
c3Zz0/t6okQHx1o6N5XwMx1YiecPcMEs8h61JGXLq1f17ECVRI8z5oSo4nL3j+FH
oeS4iIszG46CSWlueqZE7Vq7h7J1aEVj3CidHIPsopYRs/WhlvkQDAIkoxqdbWIU
xpk/wQZzUWOFL9C0dhMVybvouJW3ZPuw+AnS11nPBkagmw7DLUZ13+u4kon2qi6a
UNJA670fqlR0mEK6scKy3/PoRJCPl2z05iyB4Kcxv7/FISPQOc9MJ1IZ/fuyikn7
9XsTITd5C+7a3KUEaROe94tEsTOJJ+ZrvAgzNQ93coy+f7LnPyMOLTGVUPagmNpY
B8lpF7manTmkKjuzCHKUXzTqq0505eXYvGP7L+kGmiPxA69ajEbBGgdqKvPv+/NC
ntWM9mto
=KOfS
-----END PGP SIGNATURE-----

Timestamp of file with hash 30e3c19b4b83028940a62fea9a5feb72bad494a01063d4dacab284af3dfd0f8a -

@maflcko
Copy link
Member

maflcko commented Jul 2, 2020

cc @fanquake you might be interested in this, based on your bug report #19255

This change prevents "Shutting down" message during "dumptxoutset",
"gettxoutsetinfo" and "scantxoutset" calls.
@hebasto
Copy link
Member Author

hebasto commented Jul 8, 2020

Rebased 44ef117 -> 314b49b (pr19323.04 -> pr19323.05) due to the conflict with #19328.

Copy link
Contributor

@ryanofsky ryanofsky left a 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

@maflcko maflcko merged commit 834ac4c into bitcoin:master Jul 14, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 14, 2020
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
@hebasto hebasto deleted the 200618-utxo branch July 14, 2020 15:34
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Dec 10, 2020
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gui: calling txoutset commands broken in console
4 participants