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
core/state/snapshot: fix data race in layer flattening #23628
core/state/snapshot: fix data race in layer flattening #23628
Conversation
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 seems correct
Thinking about this some more, doesn't this only fix half the problem? Let's say you have this situation
Now, from snapshot However, won't the same problem still be present for the Summary: whatever problem you have which prompted this, are you sure this PR really makes it go away? |
In the scenario you described
after cap(a)
when we access state via
The real problem is: previously when the flattening happens(p1+p2 => p2'), the layer p1 and p2 are marked as stale but the b.parent is still p2. In this PR, the read will be blocked until the b.parent is replaced by p2' |
Will it? IIUC, only reads via |
@holiman ah, yes.
But in this case, flatten p1->p0, the blocking will start from p2. This PR works in most of the cases since we have 128 layer depth. |
Heh, you dodged the scenario by adding another level above, nice move :) Ok, so I guess my concern was that this PR introduces a new "guarantee" which is correct in 99% of all cases, but not 100. It might be fine, just sayin. |
@holiman @rjl493456442 can this be merged? |
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.
Seems good to me
* core/state/snapshot: fix data race in layer flattening * core/state/snapshot: fix typo
* core/state/snapshot: fix data race in layer flattening * core/state/snapshot: fix typo
This PR fixes a data race in snapshot tree which is described with a unit test.