Merge pull request #14254 from ramses/backport-13435

[3.4] Backport: non mutating requests pass through quotaKVServer when NOSPACE
This commit is contained in:
Benjamin Wang
2022-07-22 09:27:00 +08:00
committed by GitHub
2 changed files with 31 additions and 1 deletions

View File

@@ -135,8 +135,14 @@ func NewBackendQuota(s *EtcdServer, name string) Quota {
}
func (b *backendQuota) Available(v interface{}) bool {
cost := b.Cost(v)
// if there are no mutating requests, it's safe to pass through
if cost == 0 {
return true
}
// TODO: maybe optimize backend.Size()
return b.s.Backend().Size()+int64(b.Cost(v)) < b.maxBackendBytes
return b.s.Backend().Size()+int64(cost) < b.maxBackendBytes
}
func (b *backendQuota) Cost(v interface{}) int {