-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSHARP-3757: Redirect read/write retries to other mongos if possible #1304
base: master
Are you sure you want to change the base?
Conversation
|
||
var deprioritizedServers = new List<ServerDescription> { connected1 }; | ||
|
||
for (int i = 0; i < 15; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running multiple times to account for server selection randomness and guarantee we get the expected result for each run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, few minor comments.
src/MongoDB.Driver.Core/Core/Operations/RetryableReadOperationExecutor.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments.
src/MongoDB.Driver.Core/Core/Clusters/ServerSelectors/PriorityServerSelector.cs
Outdated
Show resolved
Hide resolved
src/MongoDB.Driver.Core/Core/Clusters/ServerSelectors/PriorityServerSelector.cs
Outdated
Show resolved
Hide resolved
src/MongoDB.Driver.Core/Core/Clusters/ServerSelectors/PriorityServerSelector.cs
Outdated
Show resolved
Hide resolved
src/MongoDB.Driver.Core/Core/Clusters/ServerSelectors/PriorityServerSelector.cs
Outdated
Show resolved
Hide resolved
src/MongoDB.Driver.Core/Core/Operations/RetryableReadOperationExecutor.cs
Outdated
Show resolved
Hide resolved
tests/MongoDB.Driver.Tests/Specifications/retryable-reads/RetryableReadsProseTests.cs
Outdated
Show resolved
Hide resolved
tests/MongoDB.Driver.Core.Tests/Core/Bindings/WritableServerBindingTests.cs
Outdated
Show resolved
Hide resolved
tests/MongoDB.Driver.Tests/Specifications/retryable-reads/RetryableReadsProseTests.cs
Outdated
Show resolved
Hide resolved
.../MongoDB.Driver.Tests/Specifications/retryable-writes/prose-tests/RetryWriteOnOtherMongos.cs
Outdated
Show resolved
Hide resolved
src/MongoDB.Driver.Core/Core/Operations/RetryableWriteOperationExecutor.cs
Outdated
Show resolved
Hide resolved
src/MongoDB.Driver.Core/Core/Clusters/ServerSelectors/PriorityServerSelector.cs
Show resolved
Hide resolved
src/MongoDB.Driver.Core/Core/Clusters/ServerSelectors/PriorityServerSelector.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
/// <param name="deprioritizedServers">The collection of servers to deprioritize.</param> | ||
public PriorityServerSelector(IReadOnlyCollection<ServerDescription> deprioritizedServers) | ||
{ | ||
_deprioritizedServers = Ensure.IsNotNullOrEmpty(deprioritizedServers, nameof(deprioritizedServers)) as IReadOnlyCollection<ServerDescription>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish we had appropriate overload, to skip the as
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't our list of deprioritized servers be empty? Wouldn't this be the case on the first call and wouldn't it only contain servers on the subsequent retry?
Right now 26 out of 28 patch variants are failing because deprioritizedServers
is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PriorityServerSelector
is created conditionally (deprioritizedServers != null
), so extending this condition to involve PriorityServerSelector
only when deprioritizedServers is not empty seems natural.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the logic around PriorityServerSelector
isn't quite right as we have a lot of failing variants complaining about deprioritizedServers
being empty. Please investigate and resolve. Thanks.
} | ||
|
||
/// <inheritdoc/> | ||
public override string ToString() => "PriorityServerSelector"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"PriorityServerSelector" => nameof(PriorityServerSelector)
We should also output _deprioritizedServers
for debug purposes.
/// <param name="deprioritizedServers">The collection of servers to deprioritize.</param> | ||
public PriorityServerSelector(IReadOnlyCollection<ServerDescription> deprioritizedServers) | ||
{ | ||
_deprioritizedServers = Ensure.IsNotNullOrEmpty(deprioritizedServers, nameof(deprioritizedServers)) as IReadOnlyCollection<ServerDescription>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't our list of deprioritized servers be empty? Wouldn't this be the case on the first call and wouldn't it only contain servers on the subsequent retry?
Right now 26 out of 28 patch variants are failing because deprioritizedServers
is empty.
Description
On a sharded cluster, retrying reads and writes will attempt to prioritize other mongos for selection if available.
What is changing?