chore: release failed running piece (#3214)
Signed-off-by: Jim Ma <majinjing3@gmail.com>
This commit is contained in:
parent
328b43268c
commit
c40cba5208
|
|
@ -1086,11 +1086,16 @@ func (pt *peerTaskConductor) downloadPiece(workerID int32, request *DownloadPiec
|
||||||
pt.runningPieces.Set(request.piece.PieceNum)
|
pt.runningPieces.Set(request.piece.PieceNum)
|
||||||
pt.runningPiecesLock.Unlock()
|
pt.runningPiecesLock.Unlock()
|
||||||
|
|
||||||
defer func() {
|
var cleanRunningPieceDone bool
|
||||||
pt.runningPiecesLock.Lock()
|
cleanRunningPiece := func() {
|
||||||
pt.runningPieces.Clean(request.piece.PieceNum)
|
if cleanRunningPieceDone {
|
||||||
pt.runningPiecesLock.Unlock()
|
cleanRunningPieceDone = true
|
||||||
}()
|
pt.runningPiecesLock.Lock()
|
||||||
|
pt.runningPieces.Clean(request.piece.PieceNum)
|
||||||
|
pt.runningPiecesLock.Unlock()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defer cleanRunningPiece()
|
||||||
|
|
||||||
ctx, span := tracer.Start(pt.pieceDownloadCtx, fmt.Sprintf(config.SpanDownloadPiece, request.piece.PieceNum))
|
ctx, span := tracer.Start(pt.pieceDownloadCtx, fmt.Sprintf(config.SpanDownloadPiece, request.piece.PieceNum))
|
||||||
span.SetAttributes(config.AttributePiece.Int(int(request.piece.PieceNum)))
|
span.SetAttributes(config.AttributePiece.Int(int(request.piece.PieceNum)))
|
||||||
|
|
@ -1117,6 +1122,9 @@ func (pt *peerTaskConductor) downloadPiece(workerID int32, request *DownloadPiec
|
||||||
pt.Infof("switch to back source, skip send failed piece")
|
pt.Infof("switch to back source, skip send failed piece")
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clean running piece first
|
||||||
|
cleanRunningPiece()
|
||||||
attempt, success := pt.pieceTaskSyncManager.acquire(
|
attempt, success := pt.pieceTaskSyncManager.acquire(
|
||||||
&commonv1.PieceTaskRequest{
|
&commonv1.PieceTaskRequest{
|
||||||
Limit: 1,
|
Limit: 1,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue