-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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-4117 Require 4.3.1+ server version when using failCommand errorLabels option #1526
Conversation
…pect to determine retryability (mongodb#1489)
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 test is failing:
[2024/02/16 04:18:28.646] =================================== FAILURES ===================================
[2024/02/16 04:18:28.646] _ TestCommandMonitoringWriteConcernError.test_A_retryable_write_with_write_concern_errors_publishes_success_event _
[2024/02/16 04:18:28.646] self = <test.test_command_monitoring.TestCommandMonitoringWriteConcernError testMethod=test_A_retryable_write_with_write_concern_errors_publishes_success_event>
[2024/02/16 04:18:28.646] def test_case(self):
[2024/02/16 04:18:28.646] > self.run_scenario(spec)
[2024/02/16 04:18:28.646] test/unified_format.py:1851:
[2024/02/16 04:18:28.646] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[2024/02/16 04:18:28.646] test/unified_format.py:1798: in run_scenario
[2024/02/16 04:18:28.646] self._run_scenario(spec, uri)
[2024/02/16 04:18:28.646] test/unified_format.py:1834: in _run_scenario
[2024/02/16 04:18:28.646] self.check_events(expect_events)
[2024/02/16 04:18:28.646] test/unified_format.py:1712: in check_events
[2024/02/16 04:18:28.646] self.match_evaluator.match_event(event_type, expected_event, actual_events[idx])
[2024/02/16 04:18:28.646] test/unified_format.py:872: in match_event
[2024/02/16 04:18:28.646] self.match_result(reply, actual.reply)
[2024/02/16 04:18:28.646] test/unified_format.py:791: in match_result
[2024/02/16 04:18:28.646] return self._match_document(expectation, actual, is_root=not in_recursive_call)
[2024/02/16 04:18:28.646] test/unified_format.py:780: in _match_document
[2024/02/16 04:18:28.646] self.match_result(value, actual[key], in_recursive_call=True)
[2024/02/16 04:18:28.646] test/unified_format.py:791: in match_result
[2024/02/16 04:18:28.646] return self._match_document(expectation, actual, is_root=not in_recursive_call)
[2024/02/16 04:18:28.646] test/unified_format.py:787: in _match_document
[2024/02/16 04:18:28.646] self.test.assertEqual(expected_keys, set(actual.keys()))
[2024/02/16 04:18:28.646] E AssertionError: Items in the second set but not the first:
[2024/02/16 04:18:28.646] E 'errorLabels'
[2024/02/16 04:18:28.646] ------------------------------ Captured log call -------------------------------
[2024/02/16 04:18:28.646] INFO pymongo.serverSelection:logger.py:94 {"message": "Waiting for suitable server to become available", "selector": "<function writable_server_selector at 0x7f65496abac0>", "operation": "insert", "topologyDescription": "<TopologyDescription id: 65cf50f6de68da9dcd97141c, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=WriteConcernError(\"None, full error: {'code': 91, 'errorLabels': ['RetryableWriteError']}\")>, <ServerDescription ('localhost', 27018) server_type: RSSecondary, rtt: 0.0005081769999719654>, <ServerDescription ('localhost', 27019) server_type: RSArbiter, rtt: 0.001811891000045307>]>", "clientId": {"$oid": "65cf50f6de68da9dcd97141c"}, "remainingTimeMS": 29}
Test failures are CSOT and https://jira.mongodb.org/projects/PYTHON/issues/PYTHON-4182. |
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.
Once tests pass, updates look good to me.
@@ -254,6 +254,8 @@ def _get_wce_doc(result: Mapping[str, Any]) -> Optional[Mapping[str, Any]]: | |||
# convenient to attach it to the writeConcernError doc itself. | |||
error_labels = result.get("errorLabels") | |||
if error_labels: | |||
# Copy to avoid changing the original document. | |||
wce = wce.copy() |
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.
Does this work with if result is a RawBSONDocument? Can we add a test for it?
Edit: Oh I see, this is only used for write command responses so we only ever pass dict. Besides that, RawBSONDocument would already fail the wce["errorLabels"] = error_labels
assignment.
Also fixes PYTHON-4018