Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Wallets search pending deadlock #2983

Conversation

guilhermelawless
Copy link
Contributor

@guilhermelawless guilhermelawless commented Sep 25, 2020

Only an issue in develop. Two different paths can deadlock:

  • node::search_pending -> wallets::search_pending_all -> wallets mutex lock -> wallet::search_pending -> node::receive_confirmed -> wallets mutex lock

  • RPC -> wallets::search_pending -> wallets mutex lock -> wallet::search_pending -> node::receive_confirmed -> wallets mutex lock

This fixes the deadlock by unlocking the wallets mutex before calling wallet::search_pending, as there is no need to hold it. But also notes that calling node::receive_confirmed from the wallet is a dependency inversion. There's no need to search for the wallet again and we are sure the block exists, so receive_async can be directly called.

@SergiySW note this means pruning #2881 (I don't think this part has been split yet) will have to consider this new case in wallet::search_pending, not only in node::receive_confirmed.

The added unit test is identical to the existing wallet.search_pending but is now done for wallets

This avoids a dependency inversion as node::receive_confirmed searches all wallets. wallet::search_pending we already know the wallet responsible for receiving that block.
wezrule
wezrule previously approved these changes Sep 25, 2020
@guilhermelawless guilhermelawless merged commit 228522a into nanocurrency:develop Sep 25, 2020
@guilhermelawless guilhermelawless deleted the wallets/search-pending-deadlock branch September 25, 2020 21:20
guilhermelawless pushed a commit to guilhermelawless/nano-node that referenced this pull request Sep 28, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants