|
31 | 31 | "configureFailPoint": "failCommand",
|
32 | 32 | "mode": {"times": 1},
|
33 | 33 | "data": {
|
34 |
| - "failCommands": ["find", "insert"], |
| 34 | + "failCommands": ["find", "insert", "update"], |
35 | 35 | "errorCode": 462, # IngressRequestRateLimitExceeded
|
36 | 36 | "errorLabels": ["Retryable"],
|
37 | 37 | },
|
@@ -98,6 +98,27 @@ async def test_retry_overload_error_insert_one(self):
|
98 | 98 |
|
99 | 99 | self.assertIn("Retryable", str(error.exception))
|
100 | 100 |
|
| 101 | + @async_client_context.require_failCommand_appName |
| 102 | + async def test_retry_overload_error_update_many(self): |
| 103 | + # Even though update_many is not a retryable write operation, it will |
| 104 | + # still be retried via the "Retryable" error label. |
| 105 | + await self.db.t.insert_one({"x": 1}) |
| 106 | + |
| 107 | + # Ensure command is retried on overload error. |
| 108 | + fail_once = mock_overload_error.copy() |
| 109 | + fail_once["mode"] = {"times": _MAX_RETRIES} |
| 110 | + async with self.fail_point(fail_once): |
| 111 | + await self.db.t.update_many({}, {"$set": {"x": 2}}) |
| 112 | + |
| 113 | + # Ensure command stops retrying after _MAX_RETRIES. |
| 114 | + fail_many_times = mock_overload_error.copy() |
| 115 | + fail_many_times["mode"] = {"times": _MAX_RETRIES + 1} |
| 116 | + async with self.fail_point(fail_many_times): |
| 117 | + with self.assertRaises(PyMongoError) as error: |
| 118 | + await self.db.t.update_many({}, {"$set": {"x": 2}}) |
| 119 | + |
| 120 | + self.assertIn("Retryable", str(error.exception)) |
| 121 | + |
101 | 122 | @async_client_context.require_failCommand_appName
|
102 | 123 | async def test_retry_overload_error_getMore(self):
|
103 | 124 | coll = self.db.t
|
|
0 commit comments