From d5d8b8e2aef278fc5ca61b0140841c3909c1a5e8 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Tue, 2 Apr 2024 21:06:19 +0500 Subject: [PATCH] fix panic at isAllWritable (#5457) fix panic https://github.com/seaweedfs/seaweedfs/issues/5456 --- weed/topology/volume_layout.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go index 3c1c31aef..d04552d35 100644 --- a/weed/topology/volume_layout.go +++ b/weed/topology/volume_layout.go @@ -234,13 +234,18 @@ func (vl *VolumeLayout) ensureCorrectWritables(vid needle.VolumeId) { } func (vl *VolumeLayout) isAllWritable(vid needle.VolumeId) bool { - for _, dn := range vl.vid2location[vid].list { - if v, getError := dn.GetVolumesById(vid); getError == nil { - if v.ReadOnly { - return false + if location, ok := vl.vid2location[vid]; ok { + for _, dn := range location.list { + if v, getError := dn.GetVolumesById(vid); getError == nil { + if v.ReadOnly { + return false + } } } + } else { + return false } + return true }