-
Notifications
You must be signed in to change notification settings - Fork 37.7k
validation, refactor: UnloadBlockIndex and ChainstateManager::Reset thread safety cleanups #24299
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
validation, refactor: UnloadBlockIndex and ChainstateManager::Reset thread safety cleanups #24299
Conversation
acb92c4
to
b63e704
Compare
@@ -5009,15 +5009,6 @@ void ChainstateManager::Unload() | |||
m_best_invalid = nullptr; | |||
} | |||
|
|||
void ChainstateManager::Reset() |
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.
I make use of this in #24232
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.
Ok, reverted to the original version in 686d35d that keeps Reset() and replaces the lock with annotation+assertion.
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.
Generally I am not a fan of putting test-only code in the "real" source code. Especially if it is validation. Longer term this may be used in non-test code accidentally, after which changes to it (and changes unrelated to it) become almost impossible to review. (See for example: #24145 (comment))
I think this should be removed from validation and added back in the test code where needed. Either src/test/util
or elsewhere.
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.
Un-reverted back to removing Reset() and will review #24232.
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.
(not saying what this pull should do, just saying what the long term goal should be)
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.
This was not just "test-only code" - the Reset() was used to detect snapshot dirs that needed to be cleaned up. The merge here isn't now just a matter of copy/pasting some code.
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.
(Already replied out-of-band) The code that isn't test-only (validatedSnapshotShutdownCleanup
) can be called in the destructor (where Reset
used to be called). The test-only code (if there is any) can be inlined, put in a test utility class, or a method. (The new method may even be called Reset
)
b63e704
to
7edab1e
Compare
Co-authored-by: Vasil Dimov <vd@FreeBSD.org> Co-authored-by: laanwj <126646+laanwj@users.noreply.github.com>
7edab1e
to
ae9ceed
Compare
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. |
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.
ACK ae9ceed
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.
crACK ae9ceed
Code review ACK ae9ceed |
Summary: This is a partial backport of [[bitcoin/bitcoin#24299 | core#24299]] bitcoin/bitcoin@daad009 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D12988
Summary: remove ChainstateManager::Reset(), as it is currently unused (can be reintroduced in the test utilities if needed for unit testing) Co-authored-by: Vasil Dimov <vd@FreeBSD.org> Co-authored-by: laanwj <126646+laanwj@users.noreply.github.com> This concludes backport of [[bitcoin/bitcoin#24299 | core#24299]] bitcoin/bitcoin@ae9ceed Depends on D12988 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D12989
Thread safety refactoring seen in #24177: