Skip to content

Commit 4ba159c

Browse files
committed
fix overload retry for clientBulk
1 parent 4644074 commit 4ba159c

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

pymongo/asynchronous/client_bulk.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,21 @@ async def _execute_command(
563563
error, ConnectionFailure
564564
) and not isinstance(error, (NotPrimaryError, WaitQueueTimeoutError))
565565

566+
retryable_label_error = (
567+
hasattr(error, "details")
568+
and isinstance(error.details, dict)
569+
and "errorLabels" in error.details
570+
and isinstance(error.details["errorLabels"], list)
571+
and "RetryableError" in error.details["errorLabels"]
572+
)
573+
566574
# Synthesize the full bulk result without modifying the
567575
# current one because this write operation may be retried.
568-
if retryable and (retryable_top_level_error or retryable_network_error):
576+
if retryable and (
577+
retryable_top_level_error
578+
or retryable_network_error
579+
or retryable_label_error
580+
):
569581
full = copy.deepcopy(full_result)
570582
_merge_command(self.ops, self.idx_offset, full, result)
571583
_throw_client_bulk_write_exception(full, self.verbose_results)

pymongo/synchronous/client_bulk.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,21 @@ def _execute_command(
561561
error, ConnectionFailure
562562
) and not isinstance(error, (NotPrimaryError, WaitQueueTimeoutError))
563563

564+
retryable_label_error = (
565+
hasattr(error, "details")
566+
and isinstance(error.details, dict)
567+
and "errorLabels" in error.details
568+
and isinstance(error.details["errorLabels"], list)
569+
and "RetryableError" in error.details["errorLabels"]
570+
)
571+
564572
# Synthesize the full bulk result without modifying the
565573
# current one because this write operation may be retried.
566-
if retryable and (retryable_top_level_error or retryable_network_error):
574+
if retryable and (
575+
retryable_top_level_error
576+
or retryable_network_error
577+
or retryable_label_error
578+
):
567579
full = copy.deepcopy(full_result)
568580
_merge_command(self.ops, self.idx_offset, full, result)
569581
_throw_client_bulk_write_exception(full, self.verbose_results)

0 commit comments

Comments
 (0)