-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
race in TestServerSetup #5837
Comments
The culprit here is a waitgroup having Question is how should we handle this without the use of a waitgroup? I've tried using atomics but they're unreliable and cause the same problem of "check for close, not closed, continue on, close happens, defer called to I've started experimenting with using a go routine spun up inside the call to Any ideas? |
General goodness:
|
I think we're breaking quite a few of those rules in the mdbx stuff. We're not really in a position to call Add before the go routine is created because it could be off the back of an RPC call for example so the call to db.BeginRo could come from anywhere at any time. This is where the thought for using channels to manage communicating with the waitgroup came from. The 3 waitgroup actions we care about would all be handled within the same go routine effectively, the one that called |
waitgroup inside kv_mdbx.go - it's not much for goroutines, but just to not call Close() when not all txs are finished. because we have many components which using own mdbx db - and some of them are nested from Geth and not really adopted for transactions use. So, i was just lazy to change implementation of higher-level components - so they can guarantee don't call Close before all read/write activity is stopped. My opinion: we don't need any fancy communication patterns - just TestServerSetup must guarantee to wait for all read/write goroutines to finish - and only then call db.Close(). If TestServerSetup can't guarantee something because we spawn goroutines which TestServerSetup can't control - then just don't spawn such goroutiness - can ask TestServerSetup to spawn for us. I think if goroutine A created goroutine B - then A is responsible to: cancel/success_finish/wait_for_done of goroutine B. |
created #7111 to deal with this one |
The text was updated successfully, but these errors were encountered: