storage: bound each delete-retry probe with the read-hint timeout

A holder that keeps the stream open without answering held the delete's
reply, even after the reporting holder took the delete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-11-22 18:08:39 -08:00
1 parent a3ca4aca09
commit 58ede90bbe
3 files changed
+53 -3

No files matched your search

+3 -2
View File
@@ -1277,8 +1277,9 @@ func (s *Store) cachedLookupEcShardLocations(ecVolume *erasure_coding.EcVolume)
// to peers or reconstruction first.
var errShardQuarantined = fmt.Errorf("ec shard on a quarantined disk: %w", errShardNotLocal)
// ecReadHintTimeout bounds asking a delisted holder, which may have stopped
// answering, before the read reconstructs the shard.
// ecReadHintTimeout bounds a one-byte probe of a holder that may have stopped
// answering: a delisted holder before the read reconstructs the shard, or a
// holder a delete retry asks.
var ecReadHintTimeout = 5 * time.Second
// askEcShardReadHints reports whether a delisted holder of the shard journaled
+4 -1
View File
@@ -68,7 +68,10 @@ func (s *Store) forwardEcDeleteOfDeletedNeedle(ecVolume *erasure_coding.EcVolume
reported := false
var errs []error
for _, holder := range holders {
if _, deleted, _ := s.doReadRemoteEcShardInterval(context.Background(), holder, needleId, ecVolume.VolumeId, shardId, make([]byte, 1), offset, ecVolume.EncodeTsNs); !deleted {
ctx, cancel := context.WithTimeout(context.Background(), ecReadHintTimeout)
_, deleted, _ := s.doReadRemoteEcShardInterval(ctx, holder, needleId, ecVolume.VolumeId, shardId, make([]byte, 1), offset, ecVolume.EncodeTsNs)
cancel()
if !deleted {
continue
}
reported = true
@@ -477,3 +477,49 @@ func TestDeleteEcShardNeedleForwardsToTheHolderReadingDeleted(t *testing.T) {
t.Errorf("forwarded %d deletes to the unreadable holder, want 0", unreadable.deletes.Load())
}
}
// A holder that stops answering after the reporter took the delete does not
// hold the delete's answer.
func TestDeleteEcShardNeedleProbeSkipsAStalledHolder(t *testing.T) {
store := newTestStore(t, 1)
store.grpcDialOption = grpc.WithTransportCredentials(insecure.NewCredentials())
const vid = needle.VolumeId(10)
_, n := writeEcVolumeFiles(t, store.Locations[0].Directory, vid)
for shardId := 1; shardId < erasure_coding.TotalShardsCount; shardId++ {
if err := store.MountEcShards("", vid, erasure_coding.ShardId(shardId), ""); err != nil {
t.Fatalf("mount shard %d: %v", shardId, err)
}
}
ecVolume, found := store.Locations[0].FindEcVolume(vid)
if !found {
t.Fatal("ec volume not mounted")
}
defer func(old time.Duration) { ecReadHintTimeout = old }(ecReadHintTimeout)
ecReadHintTimeout = 200 * time.Millisecond
reporter := &partlyDeletedEcShardPeer{}
reporterAddr := serveEcShardPeer(t, reporter)
seedShardLocations(ecVolume, reporterAddr)
ecVolume.ShardLocationsLock.Lock()
ecVolume.ShardLocations[0] = []pb.ServerAddress{reporterAddr, serveEcShardPeer(t, stalledPeer{})}
ecVolume.ShardLocationsLock.Unlock()
done := make(chan error, 1)
go func() {
got := new(needle.Needle)
got.Id = n.Id
_, err := store.DeleteEcShardNeedle(ecVolume, got, n.Cookie)
done <- err
}()
select {
case err := <-done:
if err != ErrorDeleted {
t.Fatalf("delete of a needle read as deleted returned %v, want %v", err, ErrorDeleted)
}
case <-time.After(10 * time.Second):
t.Fatal("delete still waiting on the stalled holder")
}
if reporter.deletes.Load() != 1 {
t.Errorf("forwarded %d deletes to the holder reading it deleted, want 1", reporter.deletes.Load())
}
}