Skip to content

Commit

Permalink
rapide: fix: make unexpected blocks a retriable error
Browse files Browse the repository at this point in the history
In 719b5e6 I changed `download.expand` to release the node lock before returning.
This allows other workers to access the just expanded node while we walk up the chain ancestry.
This mean that when we relock the node later to add it to our list of tasks, someone else may have downloaded some of the blocks already and thus they are not in the childrens slice and thus we wont add them to our list.

This also solve the case where you give a Traversal that is not supported by the underlying protocol,
in that case we want to kill the current download and retry deeper, while previously we would hard error on this and kill the worker.
  • Loading branch information
Jorropo committed Feb 3, 2023
1 parent bc755ab commit 021b3c9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rapide/serverdriven.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (w *serverDrivenWorker) work(ctx context.Context) {

err := w.doOneDownload(ctx, workCid, traversal)
switch err {
case nil, io.EOF, errGotDoneBlock:
case nil, io.EOF, errGotDoneBlock, errGotUnexpectedBlock:
w.resetCurrentChildsNodeWorkState()
continue
default:
Expand All @@ -67,7 +67,7 @@ func (w *serverDrivenWorker) work(ctx context.Context) {
}
}

var errUnexpectedBlock = errors.New("got an unexpected block")
var errGotUnexpectedBlock = errors.New("got an unexpected block")
var errGotDoneBlock = errors.New("downloaded an already done node")

// doOneDownload will return nil when it does not find work
Expand Down Expand Up @@ -107,7 +107,7 @@ func (w *serverDrivenWorker) doOneDownload(ctx context.Context, workCid cid.Cid,
task, ok := w.tasks[c]
if !ok {
// received unexpected block
return errUnexpectedBlock
return errGotUnexpectedBlock
}
delete(w.tasks, c)

Expand Down

0 comments on commit 021b3c9

Please sign in to comment.