mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
non mutating requests pass through quotaKVServer when NOSPACE
This commit is contained in:
parent
ef1f71a9f6
commit
7b6554fd30
@ -127,8 +127,13 @@ func NewBackendQuota(cfg config.ServerConfig, be backend.Backend, name string) Q
|
||||
}
|
||||
|
||||
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.be.Size()+int64(b.Cost(v)) < b.maxBackendBytes
|
||||
return b.be.Size()+int64(cost) < b.maxBackendBytes
|
||||
}
|
||||
|
||||
func (b *BackendQuota) Cost(v interface{}) int {
|
||||
|
@ -88,6 +88,30 @@ func TestV3StorageQuotaApply(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// txn with non-mutating Ops should go through when NOSPACE alarm is raised
|
||||
_, err = kvc0.Txn(context.TODO(), &pb.TxnRequest{
|
||||
Compare: []*pb.Compare{
|
||||
{
|
||||
Key: key,
|
||||
Result: pb.Compare_EQUAL,
|
||||
Target: pb.Compare_CREATE,
|
||||
TargetUnion: &pb.Compare_CreateRevision{CreateRevision: 0},
|
||||
},
|
||||
},
|
||||
Success: []*pb.RequestOp{
|
||||
{
|
||||
Request: &pb.RequestOp_RequestDeleteRange{
|
||||
RequestDeleteRange: &pb.DeleteRangeRequest{
|
||||
Key: key,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), integration.RequestWaitTimeout)
|
||||
defer cancel()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user