mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
storage: bound each delete a retry forwards
A holder that answers the probe deleted but stalls on the delete held the reply and the holders after it. The Rust server already bounds this call at 10 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
df6e1d5970
commit
ede64dea9e
2 files changed
+69
-4
No files matched your search
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb"
|
||||
|
||||
@@ -47,6 +48,10 @@ func (s *Store) DeleteEcShardNeedle(ecVolume *erasure_coding.EcVolume, n *needle
|
||||
|
||||
}
|
||||
|
||||
// ecDeleteRetryTimeout bounds each delete a retry sends, so a holder that
|
||||
// stops answering does not hold the reply or the holders after it.
|
||||
var ecDeleteRetryTimeout = 10 * time.Second
|
||||
|
||||
// forwardEcDeleteOfDeletedNeedle retries a delete whose read found the needle
|
||||
// deleted. A holder's read checks one disk's deletion set, and a delete that
|
||||
// failed part way can leave its other disks live, so the delete goes to the
|
||||
@@ -75,7 +80,10 @@ func (s *Store) forwardEcDeleteOfDeletedNeedle(ecVolume *erasure_coding.EcVolume
|
||||
continue
|
||||
}
|
||||
reported = true
|
||||
if err := s.doDeleteNeedleFromRemoteEcShard(holder, ecVolume.VolumeId, ecVolume.Collection, ecVolume.Version, needleId); err != nil {
|
||||
ctx, cancel = context.WithTimeout(context.Background(), ecDeleteRetryTimeout)
|
||||
err := s.doDeleteNeedleFromRemoteEcShard(ctx, holder, ecVolume.VolumeId, ecVolume.Collection, ecVolume.Version, needleId)
|
||||
cancel()
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
@@ -142,7 +150,7 @@ func (s *Store) doDeleteNeedleFromRemoteEcShardServers(shardId erasure_coding.Sh
|
||||
var lastErr error
|
||||
for _, sourceDataNode := range sourceDataNodes {
|
||||
glog.V(4).Infof("delete from remote ec shard %d.%d from %s", ecVolume.VolumeId, shardId, sourceDataNode)
|
||||
if err := s.doDeleteNeedleFromRemoteEcShard(sourceDataNode, ecVolume.VolumeId, ecVolume.Collection, ecVolume.Version, needleId); err == nil {
|
||||
if err := s.doDeleteNeedleFromRemoteEcShard(context.Background(), sourceDataNode, ecVolume.VolumeId, ecVolume.Collection, ecVolume.Version, needleId); err == nil {
|
||||
return nil
|
||||
} else {
|
||||
lastErr = err
|
||||
@@ -153,12 +161,12 @@ func (s *Store) doDeleteNeedleFromRemoteEcShardServers(shardId erasure_coding.Sh
|
||||
|
||||
}
|
||||
|
||||
func (s *Store) doDeleteNeedleFromRemoteEcShard(sourceDataNode pb.ServerAddress, vid needle.VolumeId, collection string, version needle.Version, needleId types.NeedleId) error {
|
||||
func (s *Store) doDeleteNeedleFromRemoteEcShard(ctx context.Context, sourceDataNode pb.ServerAddress, vid needle.VolumeId, collection string, version needle.Version, needleId types.NeedleId) error {
|
||||
|
||||
return operation.WithVolumeServerClient(false, sourceDataNode, s.grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
||||
|
||||
// copy data slice
|
||||
_, err := client.VolumeEcBlobDelete(context.Background(), &volume_server_pb.VolumeEcBlobDeleteRequest{
|
||||
_, err := client.VolumeEcBlobDelete(ctx, &volume_server_pb.VolumeEcBlobDeleteRequest{
|
||||
VolumeId: uint32(vid),
|
||||
Collection: collection,
|
||||
FileKey: uint64(needleId),
|
||||
|
||||
@@ -523,3 +523,60 @@ func TestDeleteEcShardNeedleProbeSkipsAStalledHolder(t *testing.T) {
|
||||
t.Errorf("forwarded %d deletes to the holder reading it deleted, want 1", reporter.deletes.Load())
|
||||
}
|
||||
}
|
||||
|
||||
// stalledDeleteEcShardPeer reads the needle as deleted but never answers a
|
||||
// delete.
|
||||
type stalledDeleteEcShardPeer struct {
|
||||
deletingEcShardPeer
|
||||
}
|
||||
|
||||
func (p *stalledDeleteEcShardPeer) VolumeEcBlobDelete(ctx context.Context, req *volume_server_pb.VolumeEcBlobDeleteRequest) (*volume_server_pb.VolumeEcBlobDeleteResponse, error) {
|
||||
<-ctx.Done()
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
|
||||
// A holder that reads the needle deleted but stalls on the delete holds
|
||||
// neither the reply nor the holders after it.
|
||||
func TestDeleteEcShardNeedleRetrySkipsAStalledDelete(t *testing.T) {
|
||||
store := newTestStore(t, 1)
|
||||
store.grpcDialOption = grpc.WithTransportCredentials(insecure.NewCredentials())
|
||||
const vid = needle.VolumeId(11)
|
||||
_, 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) { ecDeleteRetryTimeout = old }(ecDeleteRetryTimeout)
|
||||
ecDeleteRetryTimeout = 200 * time.Millisecond
|
||||
|
||||
reporter := &partlyDeletedEcShardPeer{}
|
||||
reporterAddr := serveEcShardPeer(t, reporter)
|
||||
seedShardLocations(ecVolume, reporterAddr)
|
||||
ecVolume.ShardLocationsLock.Lock()
|
||||
ecVolume.ShardLocations[0] = []pb.ServerAddress{serveEcShardPeer(t, &stalledDeleteEcShardPeer{}), reporterAddr}
|
||||
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(5 * time.Second):
|
||||
t.Fatal("delete still waiting on the holder stalled in its delete")
|
||||
}
|
||||
if reporter.deletes.Load() != 1 {
|
||||
t.Errorf("forwarded %d deletes to the holder after the stalled one, want 1", reporter.deletes.Load())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user