mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
use util.Retry to retry
This commit is contained in:
parent
3bf8e772f8
commit
28b862f45f
|
@ -171,28 +171,27 @@ func (fs *FilerServer) dataToChunk(fileName, contentType string, data []byte, ch
|
||||||
var auth security.EncodedJwt
|
var auth security.EncodedJwt
|
||||||
var uploadErr error
|
var uploadErr error
|
||||||
var uploadResult *operation.UploadResult
|
var uploadResult *operation.UploadResult
|
||||||
for i := 0; i < 3; i++ {
|
|
||||||
|
err := util.Retry("filerDataToChunk", func() error {
|
||||||
// assign one file id for one chunk
|
// assign one file id for one chunk
|
||||||
fileId, urlLocation, auth, uploadErr = fs.assignNewFileInfo(so)
|
fileId, urlLocation, auth, uploadErr = fs.assignNewFileInfo(so)
|
||||||
if uploadErr != nil {
|
if uploadErr != nil {
|
||||||
glog.V(4).Infof("retry later due to assign error: %v", uploadErr)
|
glog.V(4).Infof("retry later due to assign error: %v", uploadErr)
|
||||||
stats.FilerRequestCounter.WithLabelValues(stats.ChunkAssignRetry).Inc()
|
stats.FilerRequestCounter.WithLabelValues(stats.ChunkAssignRetry).Inc()
|
||||||
time.Sleep(time.Duration(i+1) * 251 * time.Millisecond)
|
return uploadErr
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
// upload the chunk to the volume server
|
// upload the chunk to the volume server
|
||||||
uploadResult, uploadErr, _ = fs.doUpload(urlLocation, dataReader, fileName, contentType, nil, auth)
|
uploadResult, uploadErr, _ = fs.doUpload(urlLocation, dataReader, fileName, contentType, nil, auth)
|
||||||
if uploadErr != nil {
|
if uploadErr != nil {
|
||||||
glog.V(4).Infof("retry later due to upload error: %v", uploadErr)
|
glog.V(4).Infof("retry later due to upload error: %v", uploadErr)
|
||||||
stats.FilerRequestCounter.WithLabelValues(stats.ChunkDoUploadRetry).Inc()
|
stats.FilerRequestCounter.WithLabelValues(stats.ChunkDoUploadRetry).Inc()
|
||||||
time.Sleep(time.Duration(i+1) * 251 * time.Millisecond)
|
return uploadErr
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
break
|
return nil
|
||||||
}
|
})
|
||||||
if uploadErr != nil {
|
if err != nil {
|
||||||
glog.Errorf("upload error: %v", uploadErr)
|
glog.Errorf("upload error: %v", err)
|
||||||
return nil, uploadErr
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// if last chunk exhausted the reader exactly at the border
|
// if last chunk exhausted the reader exactly at the border
|
||||||
|
|
Loading…
Reference in a new issue