Browse Source

fix issue: sometimes volume.fsck report 'volume not found' (#5537)

* fix issue: sometimes volume.fsck report 'volume not found' when a volume server has multiple disk types

* rename variable

* adjust counters

---------

Co-authored-by: chrislu <chris.lu@gmail.com>
pull/4508/merge
Taehyung Lim 6 months ago
committed by GitHub
parent
commit
4744889973
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      weed/shell/command_volume_fsck.go

15
weed/shell/command_volume_fsck.go

@ -651,9 +651,12 @@ func (c *commandVolumeFsck) collectVolumeIds() (volumeIdToServer map[string]map[
} }
eachDataNode(topologyInfo, func(dc string, rack RackId, t *master_pb.DataNodeInfo) { eachDataNode(topologyInfo, func(dc string, rack RackId, t *master_pb.DataNodeInfo) {
var volumeCount, ecShardCount int
dataNodeId := t.GetId()
for _, diskInfo := range t.DiskInfos { for _, diskInfo := range t.DiskInfos {
dataNodeId := t.GetId()
volumeIdToServer[dataNodeId] = make(map[uint32]VInfo)
if _, ok := volumeIdToServer[dataNodeId]; !ok {
volumeIdToServer[dataNodeId] = make(map[uint32]VInfo)
}
for _, vi := range diskInfo.VolumeInfos { for _, vi := range diskInfo.VolumeInfos {
volumeIdToServer[dataNodeId][vi.Id] = VInfo{ volumeIdToServer[dataNodeId][vi.Id] = VInfo{
server: pb.NewServerAddressFromDataNode(t), server: pb.NewServerAddressFromDataNode(t),
@ -661,6 +664,7 @@ func (c *commandVolumeFsck) collectVolumeIds() (volumeIdToServer map[string]map[
isEcVolume: false, isEcVolume: false,
isReadOnly: vi.ReadOnly, isReadOnly: vi.ReadOnly,
} }
volumeCount += 1
} }
for _, ecShardInfo := range diskInfo.EcShardInfos { for _, ecShardInfo := range diskInfo.EcShardInfos {
volumeIdToServer[dataNodeId][ecShardInfo.Id] = VInfo{ volumeIdToServer[dataNodeId][ecShardInfo.Id] = VInfo{
@ -669,10 +673,11 @@ func (c *commandVolumeFsck) collectVolumeIds() (volumeIdToServer map[string]map[
isEcVolume: true, isEcVolume: true,
isReadOnly: true, isReadOnly: true,
} }
ecShardCount += 1
} }
if *c.verbose {
fmt.Fprintf(c.writer, "dn %+v collected %d volumes and locations.\n", dataNodeId, len(volumeIdToServer[dataNodeId]))
}
}
if *c.verbose {
fmt.Fprintf(c.writer, "dn %+v collected %d volumes and %d ec shards.\n", dataNodeId, volumeCount, ecShardCount)
} }
}) })
return return

Loading…
Cancel
Save