aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-10-30 19:46:04 -0700
committerchrislu <chris.lu@gmail.com>2025-10-30 19:46:04 -0700
commit6cbfb240229f43021061260157091b5861567f5a (patch)
treedc5c24a4f4abe34d81bc5096501e7b15fa5871c7
parentd1428df1df4ca6ff01d242134f5b211bdc783b86 (diff)
downloadseaweedfs-6cbfb240229f43021061260157091b5861567f5a.tar.xz
seaweedfs-6cbfb240229f43021061260157091b5861567f5a.zip
errors.Join(lookupErrors...)
-rw-r--r--weed/wdclient/masterclient.go17
1 files changed, 5 insertions, 12 deletions
diff --git a/weed/wdclient/masterclient.go b/weed/wdclient/masterclient.go
index 62ced6daf..57523c8ec 100644
--- a/weed/wdclient/masterclient.go
+++ b/weed/wdclient/masterclient.go
@@ -2,6 +2,7 @@ package wdclient
import (
"context"
+ "errors"
"fmt"
"math/rand"
"sort"
@@ -39,7 +40,7 @@ type MasterClient struct {
OnPeerUpdate func(update *master_pb.ClusterNodeUpdate, startFrom time.Time)
OnPeerUpdateLock sync.RWMutex
- // Per-volume-ID in-flight tracking to prevent duplicate lookups
+ // Per-batch in-flight tracking to prevent duplicate lookups for the same set of volumes
vidLookupGroup singleflight.Group
}
@@ -108,7 +109,7 @@ func (mc *MasterClient) LookupFileIdWithFallback(ctx context.Context, fileId str
}
// LookupVolumeIdsWithFallback looks up volume locations, querying master if not in cache
-// Uses per-volume-ID singleflight to prevent duplicate lookups, with batched master queries
+// Uses singleflight to coalesce concurrent requests for the same batch of volumes
func (mc *MasterClient) LookupVolumeIdsWithFallback(ctx context.Context, volumeIds []string) (map[string][]Location, error) {
result := make(map[string][]Location)
var needsLookup []string
@@ -227,16 +228,8 @@ func (mc *MasterClient) LookupVolumeIdsWithFallback(ctx context.Context, volumeI
}
}
- // Return aggregated errors with clear formatting
- if len(lookupErrors) > 0 {
- errorMessages := make([]string, 0, len(lookupErrors))
- for _, err := range lookupErrors {
- errorMessages = append(errorMessages, err.Error())
- }
- return result, fmt.Errorf("lookup errors: %s", strings.Join(errorMessages, "; "))
- }
-
- return result, nil
+ // Return aggregated errors using errors.Join to preserve error types
+ return result, errors.Join(lookupErrors...)
}
func (mc *MasterClient) getCurrentMaster() pb.ServerAddress {