@@ -866,7 +866,7 @@ def _txn_read_preference(self):
866
866
return self ._transaction .opts .read_preference
867
867
return None
868
868
869
- def _apply_to (self , command , is_retryable , read_preference ):
869
+ def _apply_to (self , command , is_retryable , read_preference , sock_info ):
870
870
self ._check_ended ()
871
871
872
872
self ._server_session .last_use = monotonic .time ()
@@ -891,7 +891,7 @@ def _apply_to(self, command, is_retryable, read_preference):
891
891
rc = self ._transaction .opts .read_concern .document
892
892
if rc :
893
893
command ['readConcern' ] = rc
894
- self ._update_read_concern (command )
894
+ self ._update_read_concern (command , sock_info )
895
895
896
896
command ['txnNumber' ] = self ._server_session .transaction_id
897
897
command ['autocommit' ] = False
@@ -900,12 +900,15 @@ def _start_retryable_write(self):
900
900
self ._check_ended ()
901
901
self ._server_session .inc_transaction_id ()
902
902
903
- def _update_read_concern (self , cmd ):
903
+ def _update_read_concern (self , cmd , sock_info ):
904
904
if (self .options .causal_consistency
905
905
and self .operation_time is not None ):
906
906
cmd .setdefault ('readConcern' , {})[
907
907
'afterClusterTime' ] = self .operation_time
908
908
if self .options .snapshot :
909
+ if sock_info .max_wire_version < 13 :
910
+ raise ConfigurationError (
911
+ 'Snapshot reads require MongoDB 5.0 or later' )
909
912
rc = cmd .setdefault ('readConcern' , {})
910
913
rc ['level' ] = 'snapshot'
911
914
if self ._snapshot_time is not None :
0 commit comments