-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-3388 Propagate Original Error for Write Errors Labeled NoWritesPerformed #1117
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
Changes from 10 commits
046ef86
e042e44
27870fe
b32d420
bf0e8db
76727df
2120179
1747e38
f40daec
527c8c3
4bcdd21
b68ed63
5f96242
f8122bf
824008b
31f148d
bdd5b46
2800643
b60847d
643c109
98fd502
23be66e
67c73fc
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 |
---|---|---|
|
@@ -81,6 +81,7 @@ | |
PyMongoError, | ||
ServerSelectionTimeoutError, | ||
WaitQueueTimeoutError, | ||
WriteConcernError, | ||
) | ||
from pymongo.lock import _HAS_REGISTER_AT_FORK, _create_lock, _release_locks | ||
from pymongo.pool import ConnectionClosedReason | ||
|
@@ -836,6 +837,8 @@ def __init__( | |
# This will be used later if we fork. | ||
MongoClient._clients[self._topology._topology_id] = self | ||
|
||
self._indefinite_error: Optional[WriteConcernError] = None | ||
|
||
def _init_background(self): | ||
self._topology = Topology(self._topology_settings) | ||
|
||
|
@@ -1405,6 +1408,10 @@ def is_retrying(): | |
# Add the RetryableWriteError label, if applicable. | ||
_add_retryable_write_error(exc, max_wire_version) | ||
retryable_error = exc.has_error_label("RetryableWriteError") | ||
if self._indefinite_error and exc.has_error_label("NoWritesPerformed"): | ||
raise self._indefinite_error from exc | ||
if isinstance(exc, WriteConcernError): | ||
self._indefinite_error = exc | ||
|
||
if retryable_error: | ||
session._unpin() | ||
if not retryable_error or (is_retrying() and not multiple_retries): | ||
|
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't use an instance variable to track this because it makes MongoClient not thread safe.