-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-2452 Ensure command-responses with RetryableWriteError label are retried on MongoDB 4.4+ #530
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-2452 Ensure command-responses with RetryableWriteError label are retried on MongoDB 4.4+ #530
Changes from 3 commits
ea37679
e27166e
1b17169
a03be35
69b3033
e7c9968
afbde7f
94ca2f8
1aaff7a
5a3bef9
8cb236f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,8 @@ | |
|
||
from pymongo.errors import (ConnectionFailure, | ||
OperationFailure, | ||
ServerSelectionTimeoutError) | ||
ServerSelectionTimeoutError, | ||
WriteConcernError) | ||
from pymongo.mongo_client import MongoClient | ||
from pymongo.operations import (InsertOne, | ||
DeleteMany, | ||
|
@@ -453,6 +454,34 @@ def test_batch_splitting_retry_fails(self): | |
self.assertEqual(final_txn, expected_txn) | ||
self.assertEqual(coll.find_one(projection={'_id': True}), {'_id': 1}) | ||
|
||
@client_context.require_version_min(4, 4) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also needs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why require 4.4? Shouldn't this test also work the same on 4.2? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section https://github.com/mongodb/specifications/blob/master/source/retryable-writes/retryable-writes.rst#determining-retryable-errors seems to suggest that only MongoDB 4.4+ will add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's correct but if I understand correctly, the spec says that on <4.4 the driver adds the RetryableWritesError label to retryable errors. So shouldn't the label be there either way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update this to
|
||
@client_context.require_failCommand_fail_point | ||
def test_retryable_write_error_label_is_propagated(self): | ||
listener = OvertCommandListener() | ||
client = rs_or_single_client( | ||
retryWrites=True, event_listeners=[listener]) | ||
prashantmital marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
fail_insert = { | ||
prashantmital marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'configureFailPoint': 'failCommand', | ||
'mode': {'times': 2}, | ||
'data': { | ||
'failCommands': ['insert'], | ||
'closeConnection': False, | ||
'writeConcernError': { | ||
'code': 91, | ||
'errmsg': 'Replication is being shut down'}, | ||
}} | ||
|
||
with self.fail_point(fail_insert): | ||
with self.assertRaises(WriteConcernError) as cm: | ||
client.pymongo_test.testcoll.insert_one({}) | ||
self.assertIn('RetryableWriteError', | ||
cm.exception._error_labels) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use the has_error_label api. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
self.assertIn( | ||
'RetryableWriteError', | ||
listener.results['succeeded'][-1].reply['errorLabels']) | ||
|
||
|
||
# TODO: Make this a real integration test where we stepdown the primary. | ||
class TestRetryableWritesTxnNumber(IgnoreDeprecationsTest): | ||
|
Uh oh!
There was an error while loading. Please reload this page.