diff options
| author | chrislu <chris.lu@gmail.com> | 2024-04-08 11:03:14 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2024-04-08 11:03:14 -0700 |
| commit | cc1c69f312a967dfb636a677db910eb64ab65a06 (patch) | |
| tree | 086fa2b7ce6e7b80c4a00516cba2810655579709 /weed/topology/volume_layout.go | |
| parent | ccdd9cd8decf66089ac201b7c2ca1f5889582b93 (diff) | |
| parent | f08f95ac800b788e42290e58eb6444e094acf97f (diff) | |
| download | seaweedfs-cc1c69f312a967dfb636a677db910eb64ab65a06.tar.xz seaweedfs-cc1c69f312a967dfb636a677db910eb64ab65a06.zip | |
Merge branch 'master' into mq-subscribe
Diffstat (limited to 'weed/topology/volume_layout.go')
| -rw-r--r-- | weed/topology/volume_layout.go | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go index 278978292..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 } @@ -301,7 +306,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!") } @@ -336,7 +341,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vi return } } - return vid, count, locationList, shouldGrow, fmt.Errorf("No writable volumes in DataCenter:%v Rack:%v DataNode:%v", option.DataCenter, option.Rack, option.DataNode) + return vid, count, locationList, true, fmt.Errorf("No writable volumes in DataCenter:%v Rack:%v DataNode:%v", option.DataCenter, option.Rack, option.DataNode) } func (vl *VolumeLayout) HasGrowRequest() bool { |
