Page MenuHomePhabricator

[avalanche] Reverse cs_main and cs_peerManager lock order
AbandonedPublic

Authored by Fabien on May 11 2021, 19:19.

Details

Reviewers
deadalnix
Group Reviewers
Restricted Project
Summary

The locking order defined in the avalanche processor and peer manager is
currently cs_peerManager->cs_main. This makes it very difficult to call
from the network layer because most of the large functions here are
locking cs_main, causing a lock order issue
cs_main->cs_peerManager->cs_main.
This diff reverse the lock order to always use cs_main->cs_peerManager
at the expense of a holding cs_main for longer. This is done by passing
down the coins view needed to verify the utxos where it is needed.

Test Plan

With clang and debug enabled:

ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Branch
avalanche_reverse_lock_order
Lint
Lint Errors
SeverityLocationCodeMessage
Errorsrc/avalanche/test/processor_tests.cpp:424CPPCHECKcontainerOutOfBounds
Errorsrc/avalanche/test/processor_tests.cpp:425CPPCHECKcontainerOutOfBounds
Errorsrc/avalanche/test/processor_tests.cpp:445CPPCHECKcontainerOutOfBounds
Errorsrc/avalanche/test/processor_tests.cpp:446CPPCHECKcontainerOutOfBounds
Unit
No Test Coverage
Build Status
Buildable 15682
Build 31268: Build Diffbuild-clang-tidy · build-without-wallet · lint-circular-dependencies · build-diff · build-debug · build-clang
Build 31267: arc lint + arc unit

Event Timeline

Fabien requested review of this revision.May 11 2021, 19:19

Excuse the linting errors, my cppcheck version still has this false positive bug

deadalnix requested changes to this revision.May 11 2021, 22:17
deadalnix added a subscriber: deadalnix.

That is a significant step backward. The contention on cs_main is obviously far greater than the one on the peer manager. What alternative have you considered? Why do they fail?

This revision now requires changes to proceed.May 11 2021, 22:17

Hopefully this won't be needed anymore