diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2021-03-09 09:52:59 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-09 09:52:59 -0800 |
| commit | 36e12ce6f5104bc478d40b00a4f344bf07d906e1 (patch) | |
| tree | eb766773834a5503a7d505e237323c4c11d4ce0b | |
| parent | 453170f42fb1701ef977128fd33af8cffbde19dd (diff) | |
| parent | 5b1682092428a5288be20d433012632759ec406a (diff) | |
| download | seaweedfs-36e12ce6f5104bc478d40b00a4f344bf07d906e1.tar.xz seaweedfs-36e12ce6f5104bc478d40b00a4f344bf07d906e1.zip | |
Merge pull request #1879 from qieqieplus/fix-stats
fix: collection stats won't update if all volumes expired at once
| -rw-r--r-- | weed/storage/store.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/weed/storage/store.go b/weed/storage/store.go index 47829666a..a67c43a90 100644 --- a/weed/storage/store.go +++ b/weed/storage/store.go @@ -220,20 +220,30 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat { if maxFileKey < curMaxFileKey { maxFileKey = curMaxFileKey } + deleteVolume := false if !v.expired(volumeMessage.Size, s.GetVolumeSizeLimit()) { volumeMessages = append(volumeMessages, volumeMessage) } else { if v.expiredLongEnough(MAX_TTL_VOLUME_REMOVAL_DELAY) { deleteVids = append(deleteVids, v.Id) + deleteVolume = true } else { glog.V(0).Infof("volume %d is expired", v.Id) } if v.lastIoError != nil { deleteVids = append(deleteVids, v.Id) + deleteVolume = true glog.Warningf("volume %d has IO error: %v", v.Id, v.lastIoError) } } - collectionVolumeSize[v.Collection] += volumeMessage.Size + + if _, exist := collectionVolumeSize[v.Collection]; !exist { + collectionVolumeSize[v.Collection] = 0 + } + if !deleteVolume { + collectionVolumeSize[v.Collection] += volumeMessage.Size + } + if _, exist := collectionVolumeReadOnlyCount[v.Collection]; !exist { collectionVolumeReadOnlyCount[v.Collection] = map[string]uint8{ "IsReadOnly": 0, @@ -242,7 +252,7 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat { "isDiskSpaceLow": 0, } } - if v.IsReadOnly() { + if !deleteVolume && v.IsReadOnly() { collectionVolumeReadOnlyCount[v.Collection]["IsReadOnly"] += 1 if v.noWriteOrDelete { collectionVolumeReadOnlyCount[v.Collection]["noWriteOrDelete"] += 1 @@ -267,7 +277,7 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat { glog.V(0).Infof("volume %d is deleted", vid) } } else { - glog.V(0).Infof("delete volume %d: %v", vid, err) + glog.Warningf("delete volume %d: %v", vid, err) } } location.volumesLock.Unlock() |
