From 61553beba280d75f6676a57c2be41b57f519823c Mon Sep 17 00:00:00 2001 From: wusong <75450248+wusongANKANG@users.noreply.github.com> Date: Wed, 5 Jul 2023 14:22:10 +0800 Subject: [PATCH] Fix DataBackend nil pointer (#4641) --- weed/storage/store_vacuum.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/weed/storage/store_vacuum.go b/weed/storage/store_vacuum.go index 26cd370a4..531d859b8 100644 --- a/weed/storage/store_vacuum.go +++ b/weed/storage/store_vacuum.go @@ -33,7 +33,10 @@ func (s *Store) CommitCompactVolume(vid needle.VolumeId) (bool, int64, error) { if v := s.findVolume(vid); v != nil { isReadOnly := v.IsReadOnly() err := v.CommitCompact() - volumeSize, _, _ := v.DataBackend.GetStat() + var volumeSize int64 = 0 + if err == nil && v.DataBackend != nil { + volumeSize, _, _ = v.DataBackend.GetStat() + } return isReadOnly, volumeSize, err } return false, 0, fmt.Errorf("volume id %d is not found during commit compact", vid)