Browse Source

fix ec.rebuild bugs

pull/991/head
Chris Lu 6 years ago
parent
commit
11cffb3168
  1. 1
      weed/server/volume_grpc_erasure_coding.go
  2. 6
      weed/storage/erasure_coding/ec_encoder.go

1
weed/server/volume_grpc_erasure_coding.go

@ -68,6 +68,7 @@ func (vs *VolumeServer) VolumeEcShardsRebuild(ctx context.Context, req *volume_s
for _, location := range vs.store.Locations {
if util.FileExists(path.Join(location.Directory, baseFileName+".ecx")) {
// write .ec01 ~ .ec14 files
baseFileName = path.Join(location.Directory, baseFileName)
if generatedShardIds, err := erasure_coding.RebuildEcFiles(baseFileName); err != nil {
return nil, fmt.Errorf("RebuildEcFiles %s: %v", baseFileName, err)
} else {

6
weed/storage/erasure_coding/ec_encoder.go

@ -249,19 +249,17 @@ func rebuildEcFiles(shardHasData []bool, inputFiles []*os.File, outputFiles []*o
if n == 0 {
return nil
}
if inputBufferDataSize != 0 {
if inputBufferDataSize == 0 {
inputBufferDataSize = n
}
if inputBufferDataSize != n {
return fmt.Errorf("ec shard size need to be the same")
return fmt.Errorf("ec shard size expected %d actual %d", inputBufferDataSize, n)
}
} else {
buffers[i] = nil
}
}
fmt.Printf("reconstructing [%d,%d)\n", startOffset, startOffset+int64(inputBufferDataSize))
// encode the data
err = enc.Reconstruct(buffers)
if err != nil {

Loading…
Cancel
Save