Browse Source

[filer] UploadRequestToChunks: terminate the upload of remaining chunks as early as possible might be more reasonable when one chunk upload goroutine encounters a failure. (#6610)

master
hoverseu 17 hours ago
committed by GitHub
parent
commit
14cb8a24c6
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 10
      weed/server/filer_server_handlers_write_upload.go

10
weed/server/filer_server_handlers_write_upload.go

@ -64,6 +64,16 @@ func (fs *FilerServer) uploadReaderToChunks(reader io.Reader, startOffset int64,
// need to throttle used byte buffer // need to throttle used byte buffer
bytesBufferLimitChan <- struct{}{} bytesBufferLimitChan <- struct{}{}
// As long as there is an error in the upload of one chunk, it can be terminated early
// uploadErr may be modified in other go routines, lock is needed to avoid race condition
uploadErrLock.Lock()
if uploadErr != nil {
<-bytesBufferLimitChan
uploadErrLock.Unlock()
break
}
uploadErrLock.Unlock()
bytesBuffer := bufPool.Get().(*bytes.Buffer) bytesBuffer := bufPool.Get().(*bytes.Buffer)
limitedReader := io.LimitReader(partReader, int64(chunkSize)) limitedReader := io.LimitReader(partReader, int64(chunkSize))

Loading…
Cancel
Save