You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously, when a bunch of calls to the singleton made a list of waiters, but the underlying service errored making the service, only the first caller would get the underlying error. All the rest of the waiters would just be told the operation was canceled. Which is true, but it made it harder for higher layers to know what to do.
Now, since they are all shared the make call, any error that happens is also shared to all the waiters. We do this by putting the error inside an Arc<dyn std::error::Error> internally, though that exact type isn't exposed. The source chain now properly will show a caller the underlying problem.
I ran the #4119 repro against this branch: waiter outcome goes from 1/8 to 8/8 succeeding, deterministic across 5 runs.
If I'm understanding right, the mechanism for why the waiters recover: on the UseOther bounce, the maker's error is the UseOther sentinel. Propagating it through SingletonError::source() means each waiter's Negotiate future matches it via UseOther::is() and bounces to its own fallback leg. So sharing the error re-arms the existing fallback path for the waiters; no separate re-drive is needed.
This covers the case where the maker's future resolves Err but I don't think it covers the case where the maker's future is dropped before resolving: DitchGuard::drop still resets state to Empty and drops the waiters' senders, so those waiters resolve Canceled. That's the cancel_driver_cancels_all case with the // TODO: cooperative baton refactor comment.
Overall looks good, just one question. Is leaving the maker-dropped path on Canceled intended for this PR or do you have an idea of what that path should look like?
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
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.
Previously, when a bunch of calls to the singleton made a list of waiters, but the underlying service errored making the service, only the first caller would get the underlying error. All the rest of the waiters would just be told the operation was canceled. Which is true, but it made it harder for higher layers to know what to do.
Now, since they are all shared the make call, any error that happens is also shared to all the waiters. We do this by putting the error inside an
Arc<dyn std::error::Error>internally, though that exact type isn't exposed. The source chain now properly will show a caller the underlying problem.Closes hyperium/hyper#4119
cc @aajtodd