Bt/repair no nodes (#1974)

* handle cases where repair is equal to total
This commit is contained in:
Bill Thorp 2019-05-17 15:02:40 -04:00 committed by GitHub
parent b23afb7aaa
commit 91721f63ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 6 deletions

View File

@ -127,8 +127,15 @@ func (checker *Checker) IdentifyInjuredSegments(ctx context.Context) (err error)
}
remoteSegmentsChecked++
numHealthy := len(pieces) - len(missingPieces)
if (int32(numHealthy) >= pointer.Remote.Redundancy.MinReq) && (int32(numHealthy) <= pointer.Remote.Redundancy.RepairThreshold) {
numHealthy := int32(len(pieces) - len(missingPieces))
redundancy := pointer.Remote.Redundancy
// we repair when the number of healthy files is less than or equal to the repair threshold
// except for the case when the repair and success thresholds are the same (a case usually seen during testing)
if numHealthy >= redundancy.MinReq && numHealthy <= redundancy.RepairThreshold && redundancy.RepairThreshold != redundancy.SuccessThreshold {
if len(missingPieces) == 0 {
checker.logger.Warn("Missing pieces is zero in checker, but this should be impossible -- bad redundancy scheme.")
continue
}
remoteSegmentsNeedingRepair++
err = checker.repairQueue.Insert(ctx, &pb.InjuredSegment{
Path: string(item.Key),
@ -137,7 +144,7 @@ func (checker *Checker) IdentifyInjuredSegments(ctx context.Context) (err error)
if err != nil {
return Error.New("error adding injured segment to queue %s", err)
}
} else if int32(numHealthy) < pointer.Remote.Redundancy.MinReq {
} else if numHealthy < redundancy.MinReq {
pathElements := storj.SplitPath(storj.Path(item.Key))
// check to make sure there are at least *4* path elements. the first three
// are project, segment, and bucket name, but we want to make sure we're talking

View File

@ -457,8 +457,10 @@ func (endpoint *Endpoint) filterValidPieces(pointer *pb.Pointer) error {
remotePieces = append(remotePieces, piece)
}
if int32(len(remotePieces)) < remote.Redundancy.RepairThreshold {
return Error.New("Number of valid pieces is lower then repair threshold: %v < %v",
// we repair when the number of healthy files is less than or equal to the repair threshold
// except for the case when the repair and success thresholds are the same (a case usually seen during testing)
if int32(len(remotePieces)) <= remote.Redundancy.RepairThreshold && remote.Redundancy.RepairThreshold != remote.Redundancy.SuccessThreshold {
return Error.New("Number of valid pieces is less than or equal to the repair threshold: %v < %v",
len(remotePieces),
remote.Redundancy.RepairThreshold,
)

View File

@ -216,7 +216,7 @@ func TestCommitSegment(t *testing.T) {
}
_, err = metainfo.CommitSegment(ctx, "bucket", "path", -1, pointer, limits)
require.Error(t, err)
require.Contains(t, err.Error(), "Number of valid pieces is lower then repair threshold")
require.Contains(t, err.Error(), "Number of valid pieces is less than or equal to the repair threshold")
}
})
}