diff --git a/wasmsdk/blobber.go b/wasmsdk/blobber.go index 3f4add853..f0e65a394 100644 --- a/wasmsdk/blobber.go +++ b/wasmsdk/blobber.go @@ -1086,7 +1086,19 @@ func repairAllocation(allocationID, callbackFuncName string) error { return err } wg.Wait() - return statusBar.err + if statusBar.err != nil { + fmt.Println("Error in repair allocation: ", statusBar.err) + return statusBar.err + } + status, _, err := alloc.CheckAllocStatus() + if err != nil { + return err + } + if status == sdk.Repair || status == sdk.Broken { + fmt.Println("allocation repair failed") + return errors.New("allocation repair failed") + } + return nil } // checkAllocStatus check the status of the allocation, either it is ok, needs repair or broken diff --git a/zboxcore/sdk/chunked_upload.go b/zboxcore/sdk/chunked_upload.go index 22dc58a74..3aa10eb8d 100644 --- a/zboxcore/sdk/chunked_upload.go +++ b/zboxcore/sdk/chunked_upload.go @@ -412,6 +412,7 @@ func (su *ChunkedUpload) process() error { su.statusCallback.Started(su.allocationObj.ID, su.fileMeta.RemotePath, su.opCode, int(su.fileMeta.ActualSize)+int(su.fileMeta.ActualThumbnailSize)) } su.startProcessor() + defer su.chunkReader.Release() defer su.chunkReader.Close() defer su.ctxCncl(nil) for { diff --git a/zboxcore/sdk/chunked_upload_chunk_reader.go b/zboxcore/sdk/chunked_upload_chunk_reader.go index c576ebd92..a54159b3c 100644 --- a/zboxcore/sdk/chunked_upload_chunk_reader.go +++ b/zboxcore/sdk/chunked_upload_chunk_reader.go @@ -33,6 +33,8 @@ type ChunkedUploadChunkReader interface { GetFileHash() (string, error) //Reset reset offset Reset() + //Release Buffer + Release() } // chunkedUploadChunkReader read chunk bytes from io.Reader. see detail on https://github.com/0chain/blobber/wiki/Protocols#what-is-fixedmerkletree @@ -315,7 +317,6 @@ func (r *chunkedUploadChunkReader) Close() { r.closeOnce.Do(func() { close(r.hasherDataChan) r.hasherWG.Wait() - uploadPool.Put(r.fileShardsDataBuffer) }) } @@ -328,6 +329,10 @@ func (r *chunkedUploadChunkReader) GetFileHash() (string, error) { return r.hasher.GetFileHash() } +func (r *chunkedUploadChunkReader) Release() { + uploadPool.Put(r.fileShardsDataBuffer) +} + func (r *chunkedUploadChunkReader) hashData() { defer r.hasherWG.Done() for data := range r.hasherDataChan { diff --git a/zboxcore/sdk/downloadworker.go b/zboxcore/sdk/downloadworker.go index 08c554bbd..e6cba05b1 100644 --- a/zboxcore/sdk/downloadworker.go +++ b/zboxcore/sdk/downloadworker.go @@ -559,7 +559,7 @@ func (req *DownloadRequest) processDownload() { req.bufferMap[blobberIdx] = zboxutil.NewDownloadBufferWithChan(sz, bufBlocks, req.effectiveBlockSize) } else { bufMask := zboxutil.NewDownloadBufferWithMask(sz, bufBlocks, req.effectiveBlockSize) - bufMask.SetNumBlocks(int(numBlocks)) + bufMask.SetNumBlocks(int(bufBlocks)) req.bufferMap[blobberIdx] = bufMask } } @@ -996,6 +996,7 @@ func (req *DownloadRequest) errorCB(err error, remotePathCB string) { return } req.skip = true + logger.Logger.Error("Download failed: ", err, " remotefilepath: ", remotePathCB) if req.localFilePath != "" { if info, err := req.fileHandler.Stat(); err == nil && info.Size() == 0 { os.Remove(req.localFilePath) //nolint: errcheck diff --git a/zboxcore/sdk/repairworker.go b/zboxcore/sdk/repairworker.go index bfb42fd8c..1b570ce02 100644 --- a/zboxcore/sdk/repairworker.go +++ b/zboxcore/sdk/repairworker.go @@ -77,6 +77,10 @@ func (r *RepairRequest) processRepair(ctx context.Context, a *Allocation) { SetSingleClietnMode(true) defer SetSingleClietnMode(false) } + if shouldSaveProgress { + SetSaveProgress(false) + defer SetSaveProgress(true) + } r.iterateDir(a, r.listDir) if r.statusCB != nil { r.statusCB.RepairCompleted(r.filesRepaired)