Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bor: milestone avoid
TryLock
(#12422)
`TryLock` - tells that mutex was locked - but doesn't tell by whom. maybe by parent caller, maybe by another goroutine. So next pattern is bad: ``` if m.finality.TryLock() { defer m.finality.Unlock() } // mutate ``` because mutex can be locked by another goroutine and our func will mutate fields without waiting for mutex. ``` ================== WARNING: DATA RACE Write at 0x00c004e64688 by goroutine 28583: github.com/erigontech/erigon/polygon/bor/finality/whitelist.(*milestone).UnlockSprint() github.com/erigontech/erigon/polygon/bor/finality/whitelist/milestone.go:175 +0x106 github.com/erigontech/erigon/polygon/bor/finality.fetchWhitelistMilestone() github.com/erigontech/erigon/polygon/bor/finality/whitelist_helpers.go:113 +0xb3b github.com/erigontech/erigon/polygon/bor/finality.handleMilestone() github.com/erigontech/erigon/polygon/bor/finality/whitelist.go:202 +0xc8 github.com/erigontech/erigon/polygon/bor/finality.retryHeimdallHandler() github.com/erigontech/erigon/polygon/bor/finality/whitelist.go:159 +0x5cb github.com/erigontech/erigon/polygon/bor/finality.RetryHeimdallHandler() github.com/erigontech/erigon/polygon/bor/finality/whitelist.go:117 +0x5c github.com/erigontech/erigon/polygon/bor/finality.startMilestoneWhitelistService() github.com/erigontech/erigon/polygon/bor/finality/whitelist.go:93 +0x2a github.com/erigontech/erigon/polygon/bor/finality.Whitelist.gowrap2() github.com/erigontech/erigon/polygon/bor/finality/whitelist.go:64 +0x17 Previous write at 0x00c004e64688 by goroutine 28584: github.com/erigontech/erigon/polygon/bor/finality/whitelist.(*milestone).RemoveMilestoneID() github.com/erigontech/erigon/polygon/bor/finality/whitelist/milestone.go:194 +0x164 github.com/erigontech/erigon/polygon/bor/finality.handleNoAckMilestone() github.com/erigontech/erigon/polygon/bor/finality/whitelist.go:237 +0x12c github.com/erigontech/erigon/polygon/bor/finality.retryHeimdallHandler() github.com/erigontech/erigon/polygon/bor/finality/whitelist.go:159 +0x5cb github.com/erigontech/erigon/polygon/bor/finality.RetryHeimdallHandler() github.com/erigontech/erigon/polygon/bor/finality/whitelist.go:117 +0x57 github.com/erigontech/erigon/polygon/bor/finality.startNoAckMilestoneService() github.com/erigontech/erigon/polygon/bor/finality/whitelist.go:102 +0x2a github.com/erigontech/erigon/polygon/bor/finality.Whitelist.gowrap3() github.com/erigontech/erigon/polygon/bor/finality/whitelist.go:65 +0x17 ```
- Loading branch information