-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-2834 Direct read/write retries to another mongos if possible #1421
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
Conversation
@@ -1153,3 +1153,9 @@ def prepare_spec_arguments(spec, arguments, opname, entity_map, with_txn_callbac | |||
raise AssertionError(f"Unsupported cursorType: {cursor_type}") | |||
else: | |||
arguments[c2s] = arguments.pop(arg_name) | |||
|
|||
|
|||
def set_fail_point(client, command_args): |
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.
Can you use the with self.fail_point() helper instead?
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.
We need to set the fail point on each individual mongos to ensure the failure occurs on every node. with self.fail_point()
does not set the fail point correctly.
}, | ||
} | ||
|
||
for mongos in client_context.mongos_seeds().split(","): |
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.
for mongos in client_context.mongoses:
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.
That change causes the following error:
h = ('localhost', 27017)
def _connection_string(h):
> if h.startswith(("mongodb://", "mongodb+srv://")):
E AttributeError: 'tuple' object has no attribute 'startswith'
test/utils.py:544: AttributeError
pymongo/mongo_client.py
Outdated
@@ -2334,6 +2338,8 @@ def run(self) -> T: | |||
raise | |||
self._retrying = True | |||
self._last_error = exc | |||
if self._client.topology_description.topology_type == TOPOLOGY_TYPE.Sharded: | |||
self._deprioritized_servers.append(self._server) |
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.
Since this logic is the same for reads and writes and we do it in one place?
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.
Good catch, thanks!
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.
One more minor thing, otherwise LGTM
pymongo/topology.py
Outdated
if len(servers) == 1: | ||
return servers[0] | ||
server1, server2 = random.sample(servers, 2) | ||
filtered_servers = _filter_servers(servers, deprioritized_servers) |
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.
Can we rename filtered_servers->servers so the rest of this code doesn't have to change?
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!
No description provided.