Browse Source

grouping logic should be updated to use both collection and volumeId to ensure correctness

pull/7384/head
chrislu 1 month ago
parent
commit
c6968ffd96
  1. 8
      weed/storage/disk_location_ec.go

8
weed/storage/disk_location_ec.go

@ -170,6 +170,7 @@ func (l *DiskLocation) loadAllEcShards() (err error) {
}) })
var sameVolumeShards []string var sameVolumeShards []string
var prevVolumeId needle.VolumeId var prevVolumeId needle.VolumeId
var prevCollection string
for _, fileInfo := range dirEntries { for _, fileInfo := range dirEntries {
if fileInfo.IsDir() { if fileInfo.IsDir() {
continue continue
@ -192,16 +193,18 @@ func (l *DiskLocation) loadAllEcShards() (err error) {
// 0 byte files should be only appearing erroneously for ec data files // 0 byte files should be only appearing erroneously for ec data files
// so we ignore them // so we ignore them
if re.MatchString(ext) && info.Size() > 0 { if re.MatchString(ext) && info.Size() > 0 {
if prevVolumeId == 0 || volumeId == prevVolumeId {
// Group shards by both collection and volumeId to avoid mixing collections
if prevVolumeId == 0 || (volumeId == prevVolumeId && collection == prevCollection) {
sameVolumeShards = append(sameVolumeShards, fileInfo.Name()) sameVolumeShards = append(sameVolumeShards, fileInfo.Name())
} else { } else {
sameVolumeShards = []string{fileInfo.Name()} sameVolumeShards = []string{fileInfo.Name()}
} }
prevVolumeId = volumeId prevVolumeId = volumeId
prevCollection = collection
continue continue
} }
if ext == ".ecx" && volumeId == prevVolumeId {
if ext == ".ecx" && volumeId == prevVolumeId && collection == prevCollection {
// Check if this is an incomplete EC encoding (not a distributed EC volume) // Check if this is an incomplete EC encoding (not a distributed EC volume)
// Key distinction: if .dat file still exists, EC encoding may have failed // Key distinction: if .dat file still exists, EC encoding may have failed
// If .dat file is gone, this is likely a distributed EC volume with shards on multiple servers // If .dat file is gone, this is likely a distributed EC volume with shards on multiple servers
@ -211,6 +214,7 @@ func (l *DiskLocation) loadAllEcShards() (err error) {
reset := func() { reset := func() {
sameVolumeShards = nil sameVolumeShards = nil
prevVolumeId = 0 prevVolumeId = 0
prevCollection = ""
} }
datExists := util.FileExists(datFileName) datExists := util.FileExists(datFileName)

Loading…
Cancel
Save