-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
-
Python Drivers
-
Not Needed
-
https://github.com/mongodb/mongo-python-driver/pull/1361 outlines an unexpected error case where a server description is in an unknown state but is attempting to access its round_trip_time. This behavior should result in a more useful error that contains the server description states.
Here's an example:
for doc in collection.find( File "/opt/venv/lib/python3.8/site-packages/pymongo/cursor.py", line 1264, in next if len(self.__data) or self._refresh(): File "/opt/venv/lib/python3.8/site-packages/pymongo/cursor.py", line 1181, in _refresh self.__send_message(q) File "/opt/venv/lib/python3.8/site-packages/pymongo/cursor.py", line 1060, in __send_message response = client._run_operation( File "/opt/venv/lib/python3.8/site-packages/pymongo/_csot.py", line 107, in csot_wrapper return func(self, *args, **kwargs) File "/opt/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1394, in _run_operation return self._retryable_read( File "/opt/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1492, in _retryable_read return self._retry_internal( File "/opt/venv/lib/python3.8/site-packages/pymongo/_csot.py", line 107, in csot_wrapper return func(self, *args, **kwargs) File "/opt/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1453, in _retry_internal return _ClientConnectionRetryable( File "/opt/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 2315, in run return self._read() if self._is_read else self._write() File "/opt/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 2437, in _read self._server = self._get_server() File "/opt/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 2400, in _get_server return self._client._select_server( File "/opt/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1303, in _select_server server = topology.select_server(server_selector) File "/opt/venv/lib/python3.8/site-packages/pymongo/topology.py", line 302, in select_server server = self._select_server(selector, server_selection_timeout, address) File "/opt/venv/lib/python3.8/site-packages/pymongo/topology.py", line 286, in _select_server servers = self.select_servers(selector, server_selection_timeout, address) File "/opt/venv/lib/python3.8/site-packages/pymongo/topology.py", line 237, in select_servers server_descriptions = self._select_servers_loop(selector, server_timeout, address) File "/opt/venv/lib/python3.8/site-packages/pymongo/topology.py", line 252, in _select_servers_loop server_descriptions = self._description.apply_selector( File "/opt/venv/lib/python3.8/site-packages/pymongo/topology_description.py", line 330, in apply_selector return self._apply_local_threshold(selection) File "/opt/venv/lib/python3.8/site-packages/pymongo/topology_description.py", line 272, in _apply_local_threshold return [ File "/opt/venv/lib/python3.8/site-packages/pymongo/topology_description.py", line 275, in <listcomp> if (cast(float, s.round_trip_time) - fastest) <= threshold TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'
- fixes
-
PYTHON-1271 Fail to read when server topology is not ready.
- Closed
- is related to
-
PYTHON-4600 bugfix: handle round trip time being negative because time.monotonic() is not monotonic #1758
- Closed