Browse Source

fix: critical bugs from code review + clean up comments

Critical bug fixes:
1. command_ec_rebuild.go: Fixed indentation causing compilation error
   - Properly nested if/for blocks in registerEcNode

2. ec_shard_management.go: Fixed isComplete logic incorrectly using MaxShardCount
   - Changed from MaxShardCount (32) back to TotalShardsCount (14)
   - Default 10+4 volumes were being incorrectly reported as incomplete
   - Missing shards 14-31 were being incorrectly reported as missing
   - Fixed in 4 locations: volume completeness checks and getMissingShards

3. ec_volume_info.go: Fixed MinusParityShards removing too many shards
   - Changed from MaxShardCount (32) back to TotalShardsCount (14)
   - Was incorrectly removing shard IDs 10-31 instead of just 10-13

Comment cleanup:
- Removed Phase 1/Phase 2 references (development plan context)
- Replaced with clear statements about default 10+4 configuration
- SeaweedFS repo uses fixed 10+4 EC ratio, no phases needed

Root cause: Over-aggressive replacement of TotalShardsCount with MaxShardCount.
MaxShardCount (32) is the limit for buffer allocations and shard ID loops,
but TotalShardsCount (14) must be used for default EC configuration logic.
pull/7396/head
chrislu 2 months ago
parent
commit
004c804181
  1. 17
      weed/admin/dash/ec_shard_management.go
  2. 6
      weed/storage/erasure_coding/ec_volume_info.go

17
weed/admin/dash/ec_shard_management.go

@ -112,13 +112,14 @@ func (s *AdminServer) GetClusterEcShards(page int, pageSize int, sortBy string,
shardCount := len(shardsPresent) shardCount := len(shardsPresent)
// Find which shards are missing for this volume across ALL servers // Find which shards are missing for this volume across ALL servers
for shardId := 0; shardId < erasure_coding.MaxShardCount; shardId++ {
// Uses default 10+4 (14 total shards)
for shardId := 0; shardId < erasure_coding.TotalShardsCount; shardId++ {
if !shardsPresent[shardId] { if !shardsPresent[shardId] {
missingShards = append(missingShards, shardId) missingShards = append(missingShards, shardId)
} }
} }
isComplete := (shardCount == erasure_coding.MaxShardCount)
isComplete := (shardCount == erasure_coding.TotalShardsCount)
volumeCompleteness[volumeId] = isComplete volumeCompleteness[volumeId] = isComplete
volumeMissingShards[volumeId] = missingShards volumeMissingShards[volumeId] = missingShards
@ -392,9 +393,9 @@ func (s *AdminServer) GetClusterEcVolumes(page int, pageSize int, sortBy string,
for _, volume := range volumeData { for _, volume := range volumeData {
volume.TotalShards = len(volume.ShardLocations) volume.TotalShards = len(volume.ShardLocations)
// Find missing shards
// Find missing shards (default 10+4 = 14 total shards)
var missingShards []int var missingShards []int
for shardId := 0; shardId < erasure_coding.MaxShardCount; shardId++ {
for shardId := 0; shardId < erasure_coding.TotalShardsCount; shardId++ {
if _, exists := volume.ShardLocations[shardId]; !exists { if _, exists := volume.ShardLocations[shardId]; !exists {
missingShards = append(missingShards, shardId) missingShards = append(missingShards, shardId)
} }
@ -532,9 +533,10 @@ func getShardCount(ecIndexBits uint32) int {
} }
// getMissingShards returns a slice of missing shard IDs for a volume // getMissingShards returns a slice of missing shard IDs for a volume
// Assumes default 10+4 EC configuration (14 total shards)
func getMissingShards(ecIndexBits uint32) []int { func getMissingShards(ecIndexBits uint32) []int {
var missing []int var missing []int
for i := 0; i < erasure_coding.MaxShardCount; i++ {
for i := 0; i < erasure_coding.TotalShardsCount; i++ {
if (ecIndexBits & (1 << uint(i))) == 0 { if (ecIndexBits & (1 << uint(i))) == 0 {
missing = append(missing, i) missing = append(missing, i)
} }
@ -698,11 +700,12 @@ func (s *AdminServer) GetEcVolumeDetails(volumeID uint32, sortBy string, sortOrd
} }
totalUniqueShards := len(foundShards) totalUniqueShards := len(foundShards)
isComplete := (totalUniqueShards == erasure_coding.MaxShardCount)
// Check completeness using default 10+4 (14 total shards)
isComplete := (totalUniqueShards == erasure_coding.TotalShardsCount)
// Calculate missing shards // Calculate missing shards
var missingShards []int var missingShards []int
for i := 0; i < erasure_coding.MaxShardCount; i++ {
for i := 0; i < erasure_coding.TotalShardsCount; i++ {
if !foundShards[i] { if !foundShards[i] {
missingShards = append(missingShards, i) missingShards = append(missingShards, i)
} }

6
weed/storage/erasure_coding/ec_volume_info.go

@ -173,9 +173,9 @@ func (b ShardBits) Plus(other ShardBits) ShardBits {
} }
func (b ShardBits) MinusParityShards() ShardBits { func (b ShardBits) MinusParityShards() ShardBits {
// Note: This method assumes default 10+4 EC layout where parity shards are IDs 10-31
// For custom EC ratios in Phase 2, this would need to accept an ECContext parameter
for i := DataShardsCount; i < MaxShardCount; i++ {
// Removes parity shards from the bit mask
// Assumes default 10+4 EC layout where parity shards are IDs 10-13
for i := DataShardsCount; i < TotalShardsCount; i++ {
b = b.RemoveShardId(ShardId(i)) b = b.RemoveShardId(ShardId(i))
} }
return b return b

Loading…
Cancel
Save