diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-05-07 07:29:26 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-05-07 07:29:26 -0700 |
| commit | 8f8738867f10c98d59b11eaf165e1c6028d7b1d0 (patch) | |
| tree | db57540c45309f15d0efdaed274f84ece94f5a05 /weed/filesys/wfs_write.go | |
| parent | 007401f3a0b87f0a3d07f16ea731d6eec63d6975 (diff) | |
| download | seaweedfs-8f8738867f10c98d59b11eaf165e1c6028d7b1d0.tar.xz seaweedfs-8f8738867f10c98d59b11eaf165e1c6028d7b1d0.zip | |
add retry to assign volume
fix https://github.com/chrislusf/seaweedfs/issues/2056
Diffstat (limited to 'weed/filesys/wfs_write.go')
| -rw-r--r-- | weed/filesys/wfs_write.go | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/weed/filesys/wfs_write.go b/weed/filesys/wfs_write.go index 9d2ce26ec..730578202 100644 --- a/weed/filesys/wfs_write.go +++ b/weed/filesys/wfs_write.go @@ -20,35 +20,36 @@ func (wfs *WFS) saveDataAsChunk(fullPath util.FullPath, writeOnly bool) filer.Sa var auth security.EncodedJwt if err := wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error { + return util.Retry("assignVolume", func() error { + request := &filer_pb.AssignVolumeRequest{ + Count: 1, + Replication: wfs.option.Replication, + Collection: wfs.option.Collection, + TtlSec: wfs.option.TtlSec, + DiskType: string(wfs.option.DiskType), + DataCenter: wfs.option.DataCenter, + Path: string(fullPath), + } - request := &filer_pb.AssignVolumeRequest{ - Count: 1, - Replication: wfs.option.Replication, - Collection: wfs.option.Collection, - TtlSec: wfs.option.TtlSec, - DiskType: string(wfs.option.DiskType), - DataCenter: wfs.option.DataCenter, - Path: string(fullPath), - } + resp, err := client.AssignVolume(context.Background(), request) + if err != nil { + glog.V(0).Infof("assign volume failure %v: %v", request, err) + return err + } + if resp.Error != "" { + return fmt.Errorf("assign volume failure %v: %v", request, resp.Error) + } - resp, err := client.AssignVolume(context.Background(), request) - if err != nil { - glog.V(0).Infof("assign volume failure %v: %v", request, err) - return err - } - if resp.Error != "" { - return fmt.Errorf("assign volume failure %v: %v", request, resp.Error) - } + fileId, auth = resp.FileId, security.EncodedJwt(resp.Auth) + loc := &filer_pb.Location{ + Url: resp.Url, + PublicUrl: resp.PublicUrl, + } + host = wfs.AdjustedUrl(loc) + collection, replication = resp.Collection, resp.Replication - fileId, auth = resp.FileId, security.EncodedJwt(resp.Auth) - loc := &filer_pb.Location{ - Url: resp.Url, - PublicUrl: resp.PublicUrl, - } - host = wfs.AdjustedUrl(loc) - collection, replication = resp.Collection, resp.Replication - - return nil + return nil + }) }); err != nil { return nil, "", "", fmt.Errorf("filerGrpcAddress assign volume: %v", err) } |
