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 )
dependabot/go_modules/github.com/parquet-go/parquet-go-0.25.0
hoverseu
20 hours ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
10 additions and
0 deletions
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 ) )