Skip to content

Bug: "concurrent map read and map write" #176

@santi1234567

Description

@santi1234567

Description

A bug has been happening periodically where an exception is thrown:

Exception has occurred: fatal error
"concurrent map read and map write"

It is caused by a concurrent read/write at the validatorsRewardsAggregations map at lines:

}
if s.rewardsAggregationEpochs > 1 {
// if validator is not in s.validatorsRewardsAggregations, we need to create it
if _, ok := s.validatorsRewardsAggregations[phase0.ValidatorIndex(valIdx)]; !ok {
s.validatorsRewardsAggregations[phase0.ValidatorIndex(valIdx)] = spec.NewValidatorRewardsAggregation(valIdx, s.startEpochAggregation, s.endEpochAggregation)
}
s.validatorsRewardsAggregations[valIdx].Aggregate(maxRewards)
}
insertValsObj = append(insertValsObj, maxRewards)

It should be looked into whether it is ok to be processing state transitions concurrently considering that the validatorsRewardsAggregations map contains data corresponding to multiple epochs and a race condition could possibly make it so the aggregations are persited without having correctly aggregated the full epoch range. In case it is ok, then a fix should be implemented to prevent concurrent read/writes, probably with a mutex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions