mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Merge pull request #1107 from song-zhang/master
use read lock to avoid io hang during heartbeat
This commit is contained in:
commit
926abf9115
|
@ -165,8 +165,9 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
|
||||||
var maxFileKey NeedleId
|
var maxFileKey NeedleId
|
||||||
collectionVolumeSize := make(map[string]uint64)
|
collectionVolumeSize := make(map[string]uint64)
|
||||||
for _, location := range s.Locations {
|
for _, location := range s.Locations {
|
||||||
|
var deleteVids []needle.VolumeId
|
||||||
maxVolumeCount = maxVolumeCount + location.MaxVolumeCount
|
maxVolumeCount = maxVolumeCount + location.MaxVolumeCount
|
||||||
location.Lock()
|
location.RLock()
|
||||||
for _, v := range location.volumes {
|
for _, v := range location.volumes {
|
||||||
if maxFileKey < v.MaxFileKey() {
|
if maxFileKey < v.MaxFileKey() {
|
||||||
maxFileKey = v.MaxFileKey()
|
maxFileKey = v.MaxFileKey()
|
||||||
|
@ -175,8 +176,7 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
|
||||||
volumeMessages = append(volumeMessages, v.ToVolumeInformationMessage())
|
volumeMessages = append(volumeMessages, v.ToVolumeInformationMessage())
|
||||||
} else {
|
} else {
|
||||||
if v.expiredLongEnough(MAX_TTL_VOLUME_REMOVAL_DELAY) {
|
if v.expiredLongEnough(MAX_TTL_VOLUME_REMOVAL_DELAY) {
|
||||||
location.deleteVolumeById(v.Id)
|
deleteVids = append(deleteVids, v.Id)
|
||||||
glog.V(0).Infoln("volume", v.Id, "is deleted.")
|
|
||||||
} else {
|
} else {
|
||||||
glog.V(0).Infoln("volume", v.Id, "is expired.")
|
glog.V(0).Infoln("volume", v.Id, "is expired.")
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,17 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
|
||||||
fileSize, _, _ := v.FileStat()
|
fileSize, _, _ := v.FileStat()
|
||||||
collectionVolumeSize[v.Collection] += fileSize
|
collectionVolumeSize[v.Collection] += fileSize
|
||||||
}
|
}
|
||||||
location.Unlock()
|
location.RUnlock()
|
||||||
|
|
||||||
|
if len(deleteVids) > 0 {
|
||||||
|
// delete expired volumes.
|
||||||
|
location.Lock()
|
||||||
|
for _, vid := range deleteVids {
|
||||||
|
location.deleteVolumeById(vid)
|
||||||
|
glog.V(0).Infoln("volume", vid, "is deleted.")
|
||||||
|
}
|
||||||
|
location.Unlock()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for col, size := range collectionVolumeSize {
|
for col, size := range collectionVolumeSize {
|
||||||
|
|
Loading…
Reference in a new issue