Skip to content

consensus: Move CheckBlock() call to critical section - #14841

Merged
laanwj merged 1 commit into
bitcoin:masterfrom
hebasto:20181129-checkblock-mutex
Dec 1, 2018
Merged

laanwj merged 1 commit into
bitcoin:masterfrom
hebasto:20181129-checkblock-mutex

Conversation

@hebasto

@hebasto hebasto commented Nov 29, 2018

Copy link
Copy Markdown
Member

This is an alternative to #14803.

Refs:

It doesn't support multithreaded validation and there are lot of things that prevent that, which is why I was concerned. Why doesn't the lock on the block index or even cs main prevent concurrency here?

@practicalswift

Copy link
Copy Markdown
Contributor

Concept ACK

Thanks for working on this @hebasto

You might want to review #14829 which enables TSan testing in Travis for the functional tests (which are the relevants tests from a data race/threading perspective :-)).

@DrahtBot

Copy link
Copy Markdown
Contributor

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #14829 (travis: Enable functional tests in the ThreadSanitizer (TSan) build job by practicalswift)

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.

@promag

promag commented Nov 29, 2018

Copy link
Copy Markdown
Contributor

#9765 moved the lock after CheckBlock call for unknown reason cc @sdaftuar.

Verified that all CheckBlock calls hold cs_main, except PartiallyDownloadedBlock::FillBlock. It would be cool to add annotation but because of that exception I don't think it's possible (?)

utACK 9cab291.

Comment thread src/validation.cpp Resolved
@hebasto
hebasto force-pushed the 20181129-checkblock-mutex branch from 9cab291 to 5b6ae66 Compare November 29, 2018 21:05
@hebasto

hebasto commented Nov 29, 2018

Copy link
Copy Markdown
Member Author

@MarcoFalke
Thank you for your review. Your comment has been addressed.

@kallewoof kallewoof left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

utACK

Comment thread src/validation.cpp Resolved
This prevents data race for CBlock::fChecked.
@hebasto
hebasto force-pushed the 20181129-checkblock-mutex branch from 5b6ae66 to c5ed6e7 Compare November 30, 2018 10:41
@hebasto

hebasto commented Nov 30, 2018

Copy link
Copy Markdown
Member Author

@kallewoof
Thank you for your review. Your comment has been addressed.

@gmaxwell

Copy link
Copy Markdown
Contributor

utACK. I talked to @sdaftuar and it sounded like this change is fine, it was an incidental side effect of an earlier change.

@hebasto

hebasto commented Nov 30, 2018 •

Copy link
Copy Markdown
Member Author

How can the comment line modifying cause mempool_persist.py test failure in Travis?

@maflcko

maflcko commented Nov 30, 2018

Copy link
Copy Markdown
Member

utACK c5ed6e7

@gmaxwell

Copy link
Copy Markdown
Contributor

Has someone validated that all other calls to checkblock are also under a lock?

@promag

promag commented Nov 30, 2018

Copy link
Copy Markdown
Contributor

@gmaxwell yes ☝️ #14841 (comment)

@maflcko

maflcko commented Nov 30, 2018

Copy link
Copy Markdown
Member

Yes, but adding the annotation would poison the blockencodings header. Not sure if that is worth it.

@gmaxwell

Copy link
Copy Markdown
Contributor

Great! (still utACK)

@meshcollider

Copy link
Copy Markdown
Contributor

utACK c5ed6e7

@laanwj

laanwj commented Dec 1, 2018

Copy link
Copy Markdown
Member

utACK c5ed6e7

@laanwj
laanwj merged commit c5ed6e7 into bitcoin:master Dec 1, 2018
laanwj added a commit that referenced this pull request Dec 1, 2018
c5ed6e7 Move CheckBlock() call to critical section (Hennadii Stepanov)

Pull request description:

  This is an alternative to #14803.

  Refs:
  - #14058
  - #14072
  - #14803 (comment) by @gmaxwell
  > It doesn't support multithreaded validation and there are lot of things that prevent that, which is why I was concerned. Why doesn't the lock on the block index or even cs main prevent concurrency here?

  - #14803 (comment) by @MarcoFalke

Tree-SHA512: 2152e97106e11da5763b2748234ecd2982daadab13a0da04215f4db60af802a44ab5700f32249137d122eb13fc2a02e0f2d561d364607d727d8c6ab879339afb
@hebasto
hebasto deleted the 20181129-checkblock-mutex branch December 1, 2018 09:46
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request Sep 6, 2021
…ction

c5ed6e7 Move CheckBlock() call to critical section (Hennadii Stepanov)

Pull request description:

  This is an alternative to bitcoin#14803.

  Refs:
  - bitcoin#14058
  - bitcoin#14072
  - bitcoin#14803 (comment) by @gmaxwell
  > It doesn't support multithreaded validation and there are lot of things that prevent that, which is why I was concerned. Why doesn't the lock on the block index or even cs main prevent concurrency here?

  - bitcoin#14803 (comment) by @MarcoFalke

Tree-SHA512: 2152e97106e11da5763b2748234ecd2982daadab13a0da04215f4db60af802a44ab5700f32249137d122eb13fc2a02e0f2d561d364607d727d8c6ab879339afb
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
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.

10 participants