Repository navigation
Conversation
The assigner shares one worker cache across all queued tasks in a pass, and LazyCtx cached the first TaskTypes result for each worker. When a cancelled task's selector call came first, context canceled was cached and every other task in the pass failed with it. The cancelled request also stayed in the queue, so this could repeat on every pass. Drop requests with a done context before the assigner runs, and don't cache a LazyCtx result when the caller's context was cancelled. Fixes filecoin-project#10262
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Fixes #10262
Proposed Changes
tryScheddrops queued requests whose context is done before the assigner runs.Schedulehas already returnedctx.Err()to their callers, so there is nothing to respond to. The newRequestQueue.RemoveCancelleddoes this in one pass and keeps the order of the rest.LazyCtx.Valdoesn't cache a failed call when the caller's context was cancelled, so the next caller callsGetagain. Other errors are still cached, including a deadline fromSelectorTimeout, so a slow worker still fails fast for the rest of the pass.Additional Info
The assigner builds one
schedWorkerCacheper pass, shared by all queued tasks, andLazyCtxcached the firstTaskTypesresult for each worker. Selector calls use a context derived from the task's context. When a cancelled task's call came first,context canceledwas cached for that worker, and every other task in the pass failed with the samegetting supported worker task typeserror as in the issue. The cancelled request could never be assigned, so it stayed in the queue and the next pass could hit it again.Each change alone fixes the case in the issue. Dropping requests covers tasks cancelled before a pass, and the
LazyCtxchange covers a task that gets cancelled while a pass is running.LazyCtxnow uses a mutex instead ofsync.Once. Concurrent callers still wait for the call in progress, as before. The scheduler's worker cache is its only user.Tests:
TestSchedCancelledRequestDoesNotBlockOthersruns onetrySchedpass with a cancelled request ahead of a live one, and a worker whoseTaskTypesfails on a done context like an RPC client does. With thesched.goandgetonce.gochanges reverted, it logstrySched(1) req.Sel.Ok error: getting supported worker task typesfor both requests and neither is scheduled.TestRequestQueueRemoveCancelledand the newlib/lazytests cover the two changes separately.go test ./storage/sealer/ ./lib/lazy/passes, and golangci-lint reports no issues for both packages.Checklist
Before you mark the PR ready for review, please make sure that: