Merge pull request #8130 from danlenar/main

Fix concurrent writes for UpdateContainerStats
This commit is contained in:
Fu Wei 2023-02-19 17:04:35 +08:00 committed by GitHub
commit 887395aa12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -129,8 +129,8 @@ func (s *Store) List() []Sandbox {
// stats present in 'newContainerStats'. Returns errdefs.ErrNotFound
// if the sandbox does not exist in the store.
func (s *Store) UpdateContainerStats(id string, newContainerStats *stats.ContainerStats) error {
s.lock.RLock()
defer s.lock.RUnlock()
s.lock.Lock()
defer s.lock.Unlock()
id, err := s.idIndex.Get(id)
if err != nil {
if err == truncindex.ErrNotExist {