mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-05-24 02:31:28 +00:00
Update disk_location_ec.go
When loadEcShards() fails partway through, some EC shards may already be loaded into the l.ecVolumes map in memory. The previous code only cleaned up filesystem files but left orphaned in-memory state, which could cause memory leaks and inconsistent state.
This commit is contained in:
@@ -208,26 +208,30 @@ func (l *DiskLocation) loadAllEcShards() (err error) {
|
||||
continue
|
||||
}
|
||||
|
||||
if err = l.loadEcShards(sameVolumeShards, collection, volumeId); err != nil {
|
||||
// If EC shards failed to load and .dat still exists, clean up EC files to allow .dat file to be used
|
||||
// If .dat is gone, log error but don't clean up (may be waiting for shards from other servers)
|
||||
if datExists {
|
||||
glog.Warningf("Failed to load EC shards for volume %d and .dat exists: %v, cleaning up EC files to use .dat...", volumeId, err)
|
||||
l.removeEcVolumeFiles(collection, volumeId)
|
||||
} else {
|
||||
glog.Warningf("Failed to load EC shards for volume %d: %v (this may be normal for distributed EC volumes)", volumeId, err)
|
||||
}
|
||||
sameVolumeShards = nil
|
||||
prevVolumeId = 0
|
||||
continue
|
||||
if err = l.loadEcShards(sameVolumeShards, collection, volumeId); err != nil {
|
||||
// If EC shards failed to load and .dat still exists, clean up EC files to allow .dat file to be used
|
||||
// If .dat is gone, log error but don't clean up (may be waiting for shards from other servers)
|
||||
if datExists {
|
||||
glog.Warningf("Failed to load EC shards for volume %d and .dat exists: %v, cleaning up EC files to use .dat...", volumeId, err)
|
||||
// Clean up any partially loaded in-memory state before removing files
|
||||
l.DestroyEcVolume(volumeId)
|
||||
l.removeEcVolumeFiles(collection, volumeId)
|
||||
} else {
|
||||
glog.Warningf("Failed to load EC shards for volume %d: %v (this may be normal for distributed EC volumes)", volumeId, err)
|
||||
// Clean up any partially loaded in-memory state even if we don't remove files
|
||||
l.DestroyEcVolume(volumeId)
|
||||
}
|
||||
prevVolumeId = volumeId
|
||||
sameVolumeShards = nil
|
||||
prevVolumeId = 0
|
||||
continue
|
||||
}
|
||||
|
||||
prevVolumeId = volumeId
|
||||
sameVolumeShards = nil
|
||||
continue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check for orphaned EC shards without .ecx file (incomplete EC encoding)
|
||||
// This happens when encoding is interrupted after writing shards but before writing .ecx
|
||||
if len(sameVolumeShards) > 0 && prevVolumeId != 0 {
|
||||
|
||||
Reference in New Issue
Block a user