-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-2143 Use an allow-list to determine resumable change stream errors #445
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
PYTHON-2143 Use an allow-list to determine resumable change stream errors #445
Conversation
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'm not intending to review the code changes here, but please don't use the word whitelist (or blacklist) in the code or commit message.
c59c305
to
b28dbc2
Compare
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.
Still waiting for the outcome of the CursorNotFound
discussion, but the main change (adding wire version information to OperationFailure
instances) can now be reviewed.
pymongo/errors.py
Outdated
@@ -167,6 +170,15 @@ def details(self): | |||
""" | |||
return self.__details | |||
|
|||
@property | |||
def max_wire_version(self): |
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 make this private+undocumented (_ max_wire_version
)? Do you see any reason to make it public?
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.
Nope, no reason. I'll make it private.
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.
Also removed the docstring.
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 make this private (again)? Somehow it got re-added.
pymongo/helpers.py
Outdated
@@ -103,14 +103,16 @@ def _index_document(index_list): | |||
|
|||
|
|||
def _check_command_response(response, msg=None, allowable_errors=None, | |||
parse_write_concern_error=False): | |||
parse_write_concern_error=False, | |||
max_wire_version=None): |
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 suggest we make max_wire_version
a required argument to ensure we don't forget to pass it.
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.
Done. Note that I used None as the max_wire_version
value in several tests that directly use this method.
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.
Addressed your suggestions.
pymongo/errors.py
Outdated
@@ -167,6 +170,15 @@ def details(self): | |||
""" | |||
return self.__details | |||
|
|||
@property | |||
def max_wire_version(self): |
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.
Nope, no reason. I'll make it private.
pymongo/errors.py
Outdated
@@ -167,6 +170,15 @@ def details(self): | |||
""" | |||
return self.__details | |||
|
|||
@property | |||
def max_wire_version(self): |
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.
Also removed the docstring.
pymongo/helpers.py
Outdated
@@ -103,14 +103,16 @@ def _index_document(index_list): | |||
|
|||
|
|||
def _check_command_response(response, msg=None, allowable_errors=None, | |||
parse_write_concern_error=False): | |||
parse_write_concern_error=False, | |||
max_wire_version=None): |
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.
Done. Note that I used None as the max_wire_version
value in several tests that directly use this method.
pymongo/errors.py
Outdated
@@ -136,18 +136,25 @@ class ConfigurationError(PyMongoError): | |||
class OperationFailure(PyMongoError): | |||
"""Raised when a database operation fails. | |||
|
|||
.. versionadded:: 3.11 | |||
The :attr:`max_wire_version` attribute. |
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 can remove this now.
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.
Done.
4278190
to
dd23624
Compare
pymongo/network.py
Outdated
@@ -40,7 +40,7 @@ | |||
_UNPACK_HEADER = struct.Struct("<iiii").unpack | |||
|
|||
|
|||
def command(sock_info, dbname, spec, slave_ok, is_mongos, | |||
def command(sock_info, max_wire_version, dbname, spec, slave_ok, is_mongos, |
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.
Please remove max_wire_version and use sock_info.max_wire_version instead.
pymongo/pool.py
Outdated
self.is_mongos, read_preference, codec_options, | ||
session, client, check, allowable_errors, | ||
self.address, check_keys, listeners, | ||
self.max_bson_size, read_concern, |
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 undo these changes?
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.