From 0bb8505e86ca28508776d4b4734cdd4911c14332 Mon Sep 17 00:00:00 2001 From: Alex Couture-Beil Date: Tue, 8 Nov 2022 12:29:11 -0800 Subject: [PATCH] Skip boltdb update call when queue is empty This prevents unnecessary calls (and disk writes) to the metadata cache db when there are no items in the queue. Signed-off-by: Alex Couture-Beil --- cache/metadata/metadata.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cache/metadata/metadata.go b/cache/metadata/metadata.go index ae957c3e72b7..170c0a8872f4 100644 --- a/cache/metadata/metadata.go +++ b/cache/metadata/metadata.go @@ -317,6 +317,9 @@ func (s *StorageItem) Queue(fn func(b *bolt.Bucket) error) { func (s *StorageItem) Commit() error { s.qmu.Lock() defer s.qmu.Unlock() + if len(s.queue) == 0 { + return nil + } return errors.WithStack(s.Update(func(b *bolt.Bucket) error { for _, fn := range s.queue { if err := fn(b); err != nil {