satellite/repair: ignore expired segments at the beginning of the repair

work

Since we have changed the repair worker to also mark a node as audit
failure if they return a not found error, we should ignore expired
segments when possible

Change-Id: Ie6a677e1d7b234e93965c736d05950440236653c
This commit is contained in:
Yingrong Zhao 2021-10-15 18:38:53 -04:00 committed by Yingrong Zhao
parent 29599dd7cd
commit 35e4a87e60
2 changed files with 9 additions and 3 deletions

View File

@ -1349,13 +1349,13 @@ func testCorruptDataRepairFailed(t *testing.T, inMemoryRepair bool) {
})
}
// TestRemoveExpiredSegmentFromQueue
// TestRepairExpiredSegment
// - Upload tests data to 7 nodes
// - Kill nodes so that repair threshold > online nodes > minimum threshold
// - Call checker to add segment to the repair queue
// - Modify segment to be expired
// - Run the repairer
// - Verify segment is still in the repair queue. We don't want the data repairer to have any special treatment for expired segment.
// - Verify segment is no longer in the repair queue.
func TestRepairExpiredSegment(t *testing.T) {
testplanet.Run(t, testplanet.Config{
SatelliteCount: 1,
@ -1431,7 +1431,7 @@ func TestRepairExpiredSegment(t *testing.T) {
// Verify that the segment is still in the queue
count, err = satellite.DB.RepairQueue().Count(ctx)
require.NoError(t, err)
require.Equal(t, 1, count)
require.Equal(t, 0, count)
})
}

View File

@ -137,6 +137,12 @@ func (repairer *SegmentRepairer) Repair(ctx context.Context, queueSegment *queue
return true, invalidRepairError.New("cannot repair inline segment")
}
// ignore segment if expired
if segment.Expired(repairer.nowFn()) {
repairer.log.Debug("segment has expired", zap.Stringer("Stream ID", segment.StreamID), zap.Uint64("Position", queueSegment.Position.Encode()))
return true, nil
}
redundancy, err := eestream.NewRedundancyStrategyFromStorj(segment.Redundancy)
if err != nil {
return true, invalidRepairError.New("invalid redundancy strategy: %w", err)