policer: Fix concurrent map write #969

Merged
fyrchik merged 1 commit from fyrchik/frostfs-node:fix-policer into master 2024-09-04 19:51:06 +00:00
Showing only changes of commit c3fa902780 - Show all commits

View file

@ -98,6 +98,13 @@ func (m *errMap) addSeenError(cnr cid.ID, err error) bool {
return true
}
}
m.skipMap[cnr] = append(m.skipMap[cnr], err)
// Restrict list length to avoid possible OOM if some random error is added in future.
const maxErrListLength = 10
lst := m.skipMap[cnr]
if len(lst) < maxErrListLength {
m.skipMap[cnr] = append(lst, err)
}
return false
}