aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2024-03-29 04:17:59 +0500
committerGitHub <noreply@github.com>2024-03-28 16:17:59 -0700
commitdf40908e578fdf0d41044a5d521c961c95b0ab55 (patch)
treef9cd011c3af87c615575430d0aa6cbc0ecc80f05
parent6aa804b368242f853b5258f20178eae8a5eda26f (diff)
downloadseaweedfs-df40908e578fdf0d41044a5d521c961c95b0ab55.tar.xz
seaweedfs-df40908e578fdf0d41044a5d521c961c95b0ab55.zip
fix panic 5435 (#5436)
-rw-r--r--weed/server/master_grpc_server_assign.go3
-rw-r--r--weed/server/master_server_handlers.go4
-rw-r--r--weed/topology/volume_layout.go2
-rw-r--r--weed/topology/volume_location_list.go3
4 files changed, 10 insertions, 2 deletions
diff --git a/weed/server/master_grpc_server_assign.go b/weed/server/master_grpc_server_assign.go
index 2aede2d50..5839a6a73 100644
--- a/weed/server/master_grpc_server_assign.go
+++ b/weed/server/master_grpc_server_assign.go
@@ -97,6 +97,9 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest
continue
}
dn := dnList.Head()
+ if dn == nil {
+ continue
+ }
var replicas []*master_pb.Location
for _, r := range dnList.Rest() {
replicas = append(replicas, &master_pb.Location{
diff --git a/weed/server/master_server_handlers.go b/weed/server/master_server_handlers.go
index c5e059f21..9dc6351a4 100644
--- a/weed/server/master_server_handlers.go
+++ b/weed/server/master_server_handlers.go
@@ -149,7 +149,9 @@ func (ms *MasterServer) dirAssignHandler(w http.ResponseWriter, r *http.Request)
} else {
ms.maybeAddJwtAuthorization(w, fid, true)
dn := dnList.Head()
-
+ if dn == nil {
+ continue
+ }
writeJsonQuiet(w, r, http.StatusOK, operation.AssignResult{Fid: fid, Url: dn.Url(), PublicUrl: dn.PublicUrl, Count: count})
return
}
diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go
index 278978292..516d6a947 100644
--- a/weed/topology/volume_layout.go
+++ b/weed/topology/volume_layout.go
@@ -301,7 +301,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vi
if float64(info.Size) > float64(vl.volumeSizeLimit)*option.Threshold() {
shouldGrow = true
}
- return vid, count, locationList, shouldGrow, nil
+ return vid, count, locationList.Copy(), shouldGrow, nil
}
return 0, 0, nil, shouldGrow, errors.New("Strangely vid " + vid.String() + " is on no machine!")
}
diff --git a/weed/topology/volume_location_list.go b/weed/topology/volume_location_list.go
index c26f77104..127ad67eb 100644
--- a/weed/topology/volume_location_list.go
+++ b/weed/topology/volume_location_list.go
@@ -28,6 +28,9 @@ func (dnll *VolumeLocationList) Copy() *VolumeLocationList {
func (dnll *VolumeLocationList) Head() *DataNode {
//mark first node as master volume
+ if dnll.Length() == 0 {
+ return nil
+ }
return dnll.list[0]
}