Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

problem: concurrent rw on state db stateobjects map #614

Merged
merged 2 commits into from
Jun 4, 2018

Conversation

whilei
Copy link
Contributor

@whilei whilei commented Jun 2, 2018

solution: use mutex lock

fixes #284, again

solution: use mutex lock

fixes #284, again
if obj := self.stateObjects[addr]; obj != nil {
self.lock.Unlock()
if obj.deleted {
Copy link
Member

Choose a reason for hiding this comment

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

Сan it be changed here, I mean after Unlock and before return?

Copy link
Contributor Author

@whilei whilei Jun 4, 2018

Choose a reason for hiding this comment

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

@r8d8 Sorry.. what do you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(One could use a defer self.lock.Unlock() to unlock before any return point, but that would make the map possibly be locked for the rest of the logic after just reading the value) --

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@r8d8 Maybe I see what you mean. Just pushed a small refactor, I think is better.

@whilei whilei force-pushed the fix-statedb-stateobject-concurrent-rw-panic branch from eac354e to 476a39f Compare June 4, 2018 16:01
@whilei
Copy link
Contributor Author

whilei commented Jun 4, 2018

@tzdybal If you have a free second, curious your thoughts on this too. As documented in the original PR, I'm still wondering how and why there aren't MORE locks in this file and package. Is it developer laziness? Is it ok and there's just some concept I'm missing?

Since the original change appears to have fixed the reported issue, I'm OK merging this as-is, but just putting the question/seed-of-doubt on the table for consideration.

@tzdybal
Copy link
Contributor

tzdybal commented Jun 4, 2018

@whilei I don't understand it. It looks like patching ad hoc, just where it actually crashes. Lock in Copy is oldest - this is rather long operation, chances for crash are the biggest.

@whilei
Copy link
Contributor Author

whilei commented Jun 4, 2018

Yea.. sketchily ad hoc was my impression too. It seemed to me like the code was somehow usually/luckily "getting away" with not having more locks around the map r/w's.

I just threw the patch in there where it crashed because I assumed that I didn't understand why my lock was the first around so many map interactions.

@whilei
Copy link
Contributor Author

whilei commented Jun 4, 2018

I'm going to go ahead and merge as-is, then we can maybe come back later and add a more consistent locking strategy. Or at least be aware that we're living dangerously.

@whilei whilei merged commit a3d20f6 into master Jun 4, 2018
@soc1c soc1c deleted the fix-statedb-stateobject-concurrent-rw-panic branch June 19, 2019 12:31
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.

Geth 3.5.0 Constantly Crashing - concurrent map read and map write
3 participants