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

Qt: Fix for bitcoin-qt becoming unresponsive during shutdown (issue #13217) #13674

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
6 participants
@LeandroRocha84
Copy link

commented Jul 16, 2018

This pull request contains a fix for the issue #13217, where bitcoin-qt becomes unresponsive during shutdown after a long running call (like gettxoutsetinfo) in the QT console.
The problem occurs because, during shutdown, waiting for the RPCExecutor thread to finish happens in the main thread.

@LeandroRocha84

This comment has been minimized.

Copy link
Author

commented Jul 16, 2018

There's also the possibility of emitting the shutdown signal from RPCExecutor destructor so we don't need a wrapper - that simplify the solution. I created the PR with the wrapper solution because it might be considered unsafe to emit signals from a destructor in a multi-threaded application. Would appreciate any input on this and I'll update the PR accordingly.

@promag
Copy link
Member

left a comment

Indeed looks like unnecessary complexity. IIUC the main even loop blocks when joining the executor thread, so consider a different approach instead?

QEventLoop loop;
connect(&thread, SIGNAL(finished()), &loop, SLOT(quit()));
if (!thread.isFinished()) loop.exec();
Show resolved Hide resolved src/qt/rpcconsole.cpp Outdated

@LeandroRocha84 LeandroRocha84 force-pushed the LeandroRocha84:qt-shutdown-13217 branch 3 times, most recently Jul 17, 2018

@LeandroRocha84

This comment has been minimized.

Copy link
Author

commented Jul 17, 2018

Thanks for the suggestion @promag
I've updated the PR to remove the unnecessary complexity. Aside from your suggested code, I've made a small change to bitcoingui.cpp so that the UI clientModel is not cleared until the RPCExecutor thread joins. Otherwise, network events, like a new connection, that trigger a UI update would raise exceptions.

@fanquake fanquake requested a review from jonasschnelli Jul 17, 2018

Show resolved Hide resolved src/qt/rpcconsole.cpp Outdated

@LeandroRocha84 LeandroRocha84 force-pushed the LeandroRocha84:qt-shutdown-13217 branch Jul 18, 2018

Show resolved Hide resolved src/qt/bitcoingui.cpp Outdated
Show resolved Hide resolved src/qt/bitcoingui.cpp
Show resolved Hide resolved src/qt/bitcoingui.cpp Outdated

@LeandroRocha84 LeandroRocha84 force-pushed the LeandroRocha84:qt-shutdown-13217 branch Jul 27, 2018

@LeandroRocha84

This comment has been minimized.

Copy link
Author

commented Sep 1, 2018

Hi all, please let me know if there's anything that needs to be done to have this fix merged.
Thanks

Show resolved Hide resolved src/qt/rpcconsole.cpp Outdated
@DrahtBot

This comment has been minimized.

Copy link
Contributor

commented Oct 24, 2018

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #15894 (Remove duplicated "Error: " prefix in logs by hebasto)
  • #9849 (Qt: Network Watch tool by luke-jr)

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.

Show resolved Hide resolved src/qt/bitcoingui.cpp Outdated
@hebasto

This comment has been minimized.

Copy link
Member

commented Dec 5, 2018

tACK 18850903f803bba58d110d3994df18969992f383 (on Linux)
Would you squash commits?

@LeandroRocha84 LeandroRocha84 force-pushed the LeandroRocha84:qt-shutdown-13217 branch to abff369 Dec 5, 2018

@LeandroRocha84

This comment has been minimized.

Copy link
Author

commented Dec 6, 2018

All comments addressed. Commits squashed. Please let me know if there's anything.

@hebasto

This comment has been minimized.

Copy link
Member

commented Dec 6, 2018

re-tACK abff369 (Linux, macOS 10.13.6)

@jonasschnelli

This comment has been minimized.

Copy link
Member

commented Apr 16, 2019

@LeandroRocha84 sorry for keeping this up so long...
can you rebase once and then we try to get this merged?

@LeandroRocha84

This comment has been minimized.

Copy link
Author

commented Apr 17, 2019

Thanks @jonasschnelli I'm working on solving the conflicts after the rebase.
The order change in fd6d499 breaks the solution in this PR as it makes the QEventLoop.exec returns right away. I've confirmed that the bug this PR intends to solve is still reproducible; the shutdown screen is frozen/blocked when we have a long running RPC command.
I'm going to spend some time this weekend to find out how exactly the order change I linked affects the QEventLoop.

Adding @promag as he might have some insight.

@LeandroRocha84 LeandroRocha84 force-pushed the LeandroRocha84:qt-shutdown-13217 branch 2 times, most recently from 59ebf17 to a302c99 Apr 19, 2019

@LeandroRocha84

This comment has been minimized.

Copy link
Author

commented Apr 20, 2019

Conflicts resolved, rebase completed. I've tested the fix on linux.
@jonasschnelli please let me know if there's anything else I can do to get this pull request completed.
Thank you.

Show resolved Hide resolved src/qt/bitcoingui.cpp
Show resolved Hide resolved src/qt/rpcconsole.cpp Outdated
Show resolved Hide resolved src/qt/bitcoingui.cpp Outdated
Show resolved Hide resolved src/qt/bitcoingui.h

@LeandroRocha84 LeandroRocha84 force-pushed the LeandroRocha84:qt-shutdown-13217 branch from a302c99 to ba230e4 Apr 20, 2019

@DrahtBot DrahtBot removed the Needs rebase label Apr 22, 2019

Show resolved Hide resolved src/qt/rpcconsole.cpp Outdated

@LeandroRocha84 LeandroRocha84 force-pushed the LeandroRocha84:qt-shutdown-13217 branch 4 times, most recently from 937e77a to c42788e May 5, 2019

@LeandroRocha84 LeandroRocha84 force-pushed the LeandroRocha84:qt-shutdown-13217 branch from c42788e to 0636f38 May 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.