Closed jholdstock closed 2 years ago
this seems like a data race, and unrelated to the fact that the map is being modified during iteration in the loop. can you reproduce with the race detector enabled?
Almost certainly the WaitForSync
call in handleExistsAddresses
. Seems like the Indexer interface
needs a NotifiySubscribers
to clear out the map while under lock. It's not even safe to check the length of the map... so it's not clear how to safely use the Subscribers
method at all unless it returned a copy of the map.
Bingo - race detected
It is fixed in https://github.com/decred/dcrd/pull/2871 then. It introduced NotifySyncSubscribers
and deprecated Subscribers
.
Maybe needs a backport though...
This is fixed by #2871. However, unfortunately @dnldd implemented it in such a way that it can't be back ported to the v1.7.1 release, because it required a major module version bump. It will need to be backported in a way that doesn't break the API.
Noted, working on it 👍
Full trace
https://github.com/decred/dcrd/blob/e1b2e6011bf679a36ed39494dfcb1dcac30bbc80/blockchain/indexers/common.go#L692-L695
Maybe relevant for #2871