Browse Source

fix: collection stats won't update if all volumes expired at same iteration

pull/1879/head
qieqieplus 4 years ago
parent
commit
5b16820924
  1. 16
      weed/storage/store.go

16
weed/storage/store.go

@ -220,20 +220,30 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
if maxFileKey < curMaxFileKey { if maxFileKey < curMaxFileKey {
maxFileKey = curMaxFileKey maxFileKey = curMaxFileKey
} }
deleteVolume := false
if !v.expired(volumeMessage.Size, s.GetVolumeSizeLimit()) { if !v.expired(volumeMessage.Size, s.GetVolumeSizeLimit()) {
volumeMessages = append(volumeMessages, volumeMessage) volumeMessages = append(volumeMessages, volumeMessage)
} else { } else {
if v.expiredLongEnough(MAX_TTL_VOLUME_REMOVAL_DELAY) { if v.expiredLongEnough(MAX_TTL_VOLUME_REMOVAL_DELAY) {
deleteVids = append(deleteVids, v.Id) deleteVids = append(deleteVids, v.Id)
deleteVolume = true
} else { } else {
glog.V(0).Infof("volume %d is expired", v.Id) glog.V(0).Infof("volume %d is expired", v.Id)
} }
if v.lastIoError != nil { if v.lastIoError != nil {
deleteVids = append(deleteVids, v.Id) deleteVids = append(deleteVids, v.Id)
deleteVolume = true
glog.Warningf("volume %d has IO error: %v", v.Id, v.lastIoError) 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 { if _, exist := collectionVolumeReadOnlyCount[v.Collection]; !exist {
collectionVolumeReadOnlyCount[v.Collection] = map[string]uint8{ collectionVolumeReadOnlyCount[v.Collection] = map[string]uint8{
"IsReadOnly": 0, "IsReadOnly": 0,
@ -242,7 +252,7 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
"isDiskSpaceLow": 0, "isDiskSpaceLow": 0,
} }
} }
if v.IsReadOnly() {
if !deleteVolume && v.IsReadOnly() {
collectionVolumeReadOnlyCount[v.Collection]["IsReadOnly"] += 1 collectionVolumeReadOnlyCount[v.Collection]["IsReadOnly"] += 1
if v.noWriteOrDelete { if v.noWriteOrDelete {
collectionVolumeReadOnlyCount[v.Collection]["noWriteOrDelete"] += 1 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) glog.V(0).Infof("volume %d is deleted", vid)
} }
} else { } else {
glog.V(0).Infof("delete volume %d: %v", vid, err)
glog.Warningf("delete volume %d: %v", vid, err)
} }
} }
location.volumesLock.Unlock() location.volumesLock.Unlock()

Loading…
Cancel
Save