mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
Layout lookups wait until blockmaster serves
blockmaster logs "lock acquired" before it imports the cluster spec, which creates each volume's layout on the filer, and serves only after that. A harness that looks a volume up right after that line can find it not serving yet (F1 with ten volumes: DeadlineExceeded waiting for the connection). layoutID now retries an Unavailable or DeadlineExceeded answer within 60 s; any other answer still fails at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e647276503
commit
bac18bf79d
1 file changed
+19
-5
@@ -21,10 +21,13 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/nvme"
|
||||
"github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
"github.com/seaweedfs/seaweed-block/core/rpc/lifecycleclient"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// TestStandalonePlannedHandoffToTheSameHost runs the planned hand-over back
|
||||
@@ -349,11 +352,22 @@ func (env *handoffEnv) layoutID(volume string) string {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
id, err := lifecycleclient.ResolveVolume(ctx, control.NewLifecycleServiceClient(conn), volume)
|
||||
if err != nil {
|
||||
t.Fatalf("resolve layout identity for %s: %v", volume, err)
|
||||
// blockmaster logs "lock acquired" before it imports the cluster spec
|
||||
// (each volume's layout created on the filer) and only serves after
|
||||
// that, so a lookup right after that line can find it not serving yet:
|
||||
// retry while it is unavailable, within 60 s. Any other answer (not
|
||||
// found, refused) fails at once.
|
||||
var id layout.VolumeID
|
||||
for end := time.Now().Add(60 * time.Second); ; time.Sleep(500 * time.Millisecond) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
id, err = lifecycleclient.ResolveVolume(ctx, control.NewLifecycleServiceClient(conn), volume)
|
||||
cancel()
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
if c := status.Code(err); (c != codes.Unavailable && c != codes.DeadlineExceeded) || time.Now().After(end) {
|
||||
t.Fatalf("resolve layout identity for %s: %v", volume, err)
|
||||
}
|
||||
}
|
||||
if env.layoutIDs == nil {
|
||||
env.layoutIDs = make(map[string]string)
|
||||
|
||||
Reference in new issue
Block a user