Skip to content

Commit 0b4b265

Browse files
committed
address review
1 parent 2cd3c18 commit 0b4b265

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

pymongo/asynchronous/pool.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,10 @@ async def remove_stale_sockets(self, reference_generation: int) -> None:
10291029
self.requests -= 1
10301030
self.size_cond.notify()
10311031

1032+
# Assume all non dns/tcp/timeout errors mean the server rejected the connection due to overload.
1033+
# if not errorDuringDnsTcp and not timeoutError:
1034+
# error._add_error_label("SystemOverloadedError")
1035+
10321036
def _handle_connection_error(self, error: Exception, phase: str) -> None:
10331037
# Handle system overload condition. When the base AutoReconnect is
10341038
# raised and we are not an sdam pool, add to backoff and add the
@@ -1039,8 +1043,8 @@ def _handle_connection_error(self, error: Exception, phase: str) -> None:
10391043
or ("connection closed" in str(error).lower() and self._backoff)
10401044
):
10411045
self._backoff += 1
1042-
error._add_error_label("SystemOverloaded")
1043-
error._add_error_label("Retryable")
1046+
error._add_error_label("SystemOverloadedError")
1047+
error._add_error_label("RetryableError")
10441048
print(f"Setting backoff in {phase}:", self._backoff) # noqa: T201
10451049

10461050
async def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> AsyncConnection:

pymongo/asynchronous/topology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ async def _handle_error(self, address: _Address, err_ctx: _ErrorContext) -> None
891891
await server.reset(service_id)
892892
elif isinstance(error, ConnectionFailure):
893893
if isinstance(error, WaitQueueTimeoutError) or error.has_error_label(
894-
"SystemOverloaded"
894+
"SystemOverloadedError"
895895
):
896896
return
897897
# "Client MUST replace the server's description with type Unknown

pymongo/synchronous/pool.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,10 @@ def remove_stale_sockets(self, reference_generation: int) -> None:
10251025
self.requests -= 1
10261026
self.size_cond.notify()
10271027

1028+
# Assume all non dns/tcp/timeout errors mean the server rejected the connection due to overload.
1029+
# if not errorDuringDnsTcp and not timeoutError:
1030+
# error._add_error_label("SystemOverloadedError")
1031+
10281032
def _handle_connection_error(self, error: Exception, phase: str) -> None:
10291033
# Handle system overload condition. When the base AutoReconnect is
10301034
# raised and we are not an sdam pool, add to backoff and add the
@@ -1035,8 +1039,8 @@ def _handle_connection_error(self, error: Exception, phase: str) -> None:
10351039
or ("connection closed" in str(error).lower() and self._backoff)
10361040
):
10371041
self._backoff += 1
1038-
error._add_error_label("SystemOverloaded")
1039-
error._add_error_label("Retryable")
1042+
error._add_error_label("SystemOverloadedError")
1043+
error._add_error_label("RetryableError")
10401044
print(f"Setting backoff in {phase}:", self._backoff) # noqa: T201
10411045

10421046
def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> Connection:

pymongo/synchronous/topology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ def _handle_error(self, address: _Address, err_ctx: _ErrorContext) -> None:
889889
server.reset(service_id)
890890
elif isinstance(error, ConnectionFailure):
891891
if isinstance(error, WaitQueueTimeoutError) or error.has_error_label(
892-
"SystemOverloaded"
892+
"SystemOverloadedError"
893893
):
894894
return
895895
# "Client MUST replace the server's description with type Unknown

0 commit comments

Comments
 (0)