storage: Check for context cancellation in more places #10487
Merged
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.
#10427 saw a lot of commands that were canceled via their context while waiting in the command queue; it is possible that those contexts were canceled even earlier. If some process (like the GC queue) issued a bunch of commands on the same canceled context, those commands would all go into the command queue and have to wait on each other for
O(n**2)
worst-case performance (note that while this is a possibility, I don't find it a very convincing explanation for #10427 because I would expect more visible problems before the tipping point).Guard against this by checking for context cancellation before the command queue. Also add a cancellation check to the unbounded retry loop in Store.
This change is