[#969] policer: Restrict the number of remembered errors
All checks were successful
DCO action / DCO (pull_request) Successful in 4m23s
Vulncheck / Vulncheck (pull_request) Successful in 4m57s
Build / Build Components (1.21) (pull_request) Successful in 6m3s
Build / Build Components (1.20) (pull_request) Successful in 9m2s
Tests and linters / Staticcheck (pull_request) Successful in 10m4s
Tests and linters / Lint (pull_request) Successful in 10m51s
Tests and linters / Tests (1.21) (pull_request) Successful in 10m44s
Tests and linters / Tests (1.20) (pull_request) Successful in 10m56s
Tests and linters / Tests with -race (pull_request) Successful in 10m57s

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-02-08 10:05:02 +03:00
parent 6010dfdf3d
commit c3fa902780

View file

@ -98,6 +98,13 @@ func (m *errMap) addSeenError(cnr cid.ID, err error) bool {
return true 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 return false
} }