apiserver/storage: free etcd kv early in list decoding loop

This commit is contained in:
Dr. Stefan Schimanski 2021-10-08 14:05:26 +02:00
parent 8d0acaa3ff
commit dbf98e4266

View File

@ -763,7 +763,7 @@ func (s *store) List(ctx context.Context, key string, opts storage.ListOptions,
} }
// take items from the response until the bucket is full, filtering as we go // take items from the response until the bucket is full, filtering as we go
for _, kv := range getResp.Kvs { for i, kv := range getResp.Kvs {
if paging && int64(v.Len()) >= pred.Limit { if paging && int64(v.Len()) >= pred.Limit {
hasMore = true hasMore = true
break break
@ -779,6 +779,9 @@ func (s *store) List(ctx context.Context, key string, opts storage.ListOptions,
return err return err
} }
numEvald++ numEvald++
// free kv early. Long lists can take O(seconds) to decode.
getResp.Kvs[i] = nil
} }
// indicate to the client which resource version was returned // indicate to the client which resource version was returned