diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2024-04-02 21:06:19 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-02 09:06:19 -0700 |
| commit | d5d8b8e2aef278fc5ca61b0140841c3909c1a5e8 (patch) | |
| tree | 93c971e108970ec22d4da367d0ca6532e298a7b2 | |
| parent | 2a88da4de757630a7d35779867f24c66c71ae7a9 (diff) | |
| download | seaweedfs-d5d8b8e2aef278fc5ca61b0140841c3909c1a5e8.tar.xz seaweedfs-d5d8b8e2aef278fc5ca61b0140841c3909c1a5e8.zip | |
fix panic at isAllWritable (#5457)
fix panic
https://github.com/seaweedfs/seaweedfs/issues/5456
| -rw-r--r-- | weed/topology/volume_layout.go | 13 |
1 files 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 } |
