@@ -4220,15 +4220,14 @@ def wait_for_schema_agreement(self, connection=None, preloaded_results=None, wai
4220
4220
if self ._is_shutdown :
4221
4221
return
4222
4222
4223
- if not connection :
4224
- connection = self ._connection
4223
+ current_connection = connection or self ._connection
4225
4224
4226
4225
if preloaded_results :
4227
4226
log .debug ("[control connection] Attempting to use preloaded results for schema agreement" )
4228
4227
4229
4228
peers_result = preloaded_results [0 ]
4230
4229
local_result = preloaded_results [1 ]
4231
- schema_mismatches = self ._get_schema_mismatches (peers_result , local_result , connection .endpoint )
4230
+ schema_mismatches = self ._get_schema_mismatches (peers_result , local_result , current_connection .endpoint )
4232
4231
if schema_mismatches is None :
4233
4232
return True
4234
4233
@@ -4237,16 +4236,18 @@ def wait_for_schema_agreement(self, connection=None, preloaded_results=None, wai
4237
4236
elapsed = 0
4238
4237
cl = ConsistencyLevel .ONE
4239
4238
schema_mismatches = None
4240
- select_peers_query = self ._get_peers_query (self .PeersQueryType .PEERS_SCHEMA , connection )
4239
+ select_peers_query = self ._get_peers_query (self .PeersQueryType .PEERS_SCHEMA , current_connection )
4241
4240
4242
4241
while elapsed < total_timeout :
4242
+ current_connection = connection or self ._connection
4243
+
4243
4244
peers_query = QueryMessage (query = maybe_add_timeout_to_query (select_peers_query , self ._metadata_request_timeout ),
4244
4245
consistency_level = cl )
4245
4246
local_query = QueryMessage (query = maybe_add_timeout_to_query (self ._SELECT_SCHEMA_LOCAL , self ._metadata_request_timeout ),
4246
4247
consistency_level = cl )
4247
4248
try :
4248
4249
timeout = min (self ._timeout , total_timeout - elapsed )
4249
- peers_result , local_result = connection .wait_for_responses (
4250
+ peers_result , local_result = current_connection .wait_for_responses (
4250
4251
peers_query , local_query , timeout = timeout )
4251
4252
except OperationTimedOut as timeout :
4252
4253
log .debug ("[control connection] Timed out waiting for "
@@ -4258,9 +4259,9 @@ def wait_for_schema_agreement(self, connection=None, preloaded_results=None, wai
4258
4259
log .debug ("[control connection] Aborting wait for schema match due to shutdown" )
4259
4260
return None
4260
4261
else :
4261
- raise
4262
+ continue
4262
4263
4263
- schema_mismatches = self ._get_schema_mismatches (peers_result , local_result , connection .endpoint )
4264
+ schema_mismatches = self ._get_schema_mismatches (peers_result , local_result , current_connection .endpoint )
4264
4265
if schema_mismatches is None :
4265
4266
return True
4266
4267
@@ -4269,7 +4270,7 @@ def wait_for_schema_agreement(self, connection=None, preloaded_results=None, wai
4269
4270
elapsed = self ._time .time () - start
4270
4271
4271
4272
log .warning ("Node %s is reporting a schema disagreement: %s" ,
4272
- connection .endpoint , schema_mismatches )
4273
+ current_connection .endpoint , schema_mismatches )
4273
4274
return False
4274
4275
4275
4276
def _get_schema_mismatches (self , peers_result , local_result , local_address ):
0 commit comments