21
21
import logging
22
22
import time
23
23
import weakref
24
- from typing import TYPE_CHECKING , Any , Mapping , Optional , cast
24
+ from typing import TYPE_CHECKING , Any , Optional
25
25
26
26
from pymongo import common , periodic_executor
27
27
from pymongo ._csot import MovingMinimum
28
- from pymongo .errors import NetworkTimeout , NotPrimaryError , OperationFailure , _OperationCancelled
28
+ from pymongo .errors import NetworkTimeout , _OperationCancelled
29
29
from pymongo .hello import Hello
30
30
from pymongo .lock import _create_lock
31
31
from pymongo .logger import _SDAM_LOGGER , _debug_log , _SDAMStatusMessage
@@ -250,6 +250,7 @@ def _check_server(self) -> ServerDescription:
250
250
self ._conn_id = None
251
251
start = time .monotonic ()
252
252
try :
253
+ < << << << HEAD
253
254
try :
254
255
return self ._check_once ()
255
256
except (OperationFailure , NotPrimaryError ) as exc :
@@ -259,6 +260,17 @@ def _check_server(self) -> ServerDescription:
259
260
raise
260
261
except asyncio .CancelledError :
261
262
raise
263
+ | | | | | | | parent of 14 c8432bc (PYTHON - 4579 Stop gossiping $clusterTime on SDAM connections )
264
+ try :
265
+ return self ._check_once ()
266
+ except (OperationFailure , NotPrimaryError ) as exc :
267
+ # Update max cluster time even when hello fails.
268
+ details = cast (Mapping [str , Any ], exc .details )
269
+ self ._topology .receive_cluster_time (details .get ("$clusterTime" ))
270
+ raise
271
+ == == == =
272
+ return self ._check_once ()
273
+ >> >> >> > 14 c8432bc (PYTHON - 4579 Stop gossiping $clusterTime on SDAM connections )
262
274
except ReferenceError :
263
275
raise
264
276
except Exception as error :
@@ -355,7 +367,6 @@ def _check_with_socket(self, conn: Connection) -> tuple[Hello, float]:
355
367
356
368
Can raise ConnectionFailure or OperationFailure.
357
369
"""
358
- cluster_time = self ._topology .max_cluster_time ()
359
370
start = time .monotonic ()
360
371
if conn .more_to_come :
361
372
# Read the next streaming hello (MongoDB 4.4+).
@@ -365,13 +376,13 @@ def _check_with_socket(self, conn: Connection) -> tuple[Hello, float]:
365
376
):
366
377
# Initiate streaming hello (MongoDB 4.4+).
367
378
response = conn ._hello (
368
- cluster_time ,
379
+ None ,
369
380
self ._server_description .topology_version ,
370
381
self ._settings .heartbeat_frequency ,
371
382
)
372
383
else :
373
384
# New connection handshake or polling hello (MongoDB <4.4).
374
- response = conn ._hello (cluster_time , None , None )
385
+ response = conn ._hello (None , None , None )
375
386
duration = _monotonic_duration (start )
376
387
return response , duration
377
388
0 commit comments