Skip to content

Commit dfaa31c

Browse files
committed
schema-agreement: propagate post-mismatch connection errors
1 parent 9f92cd8 commit dfaa31c

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

cassandra/cluster.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4251,12 +4251,12 @@ def wait_for_schema_agreement(self, connection=None, preloaded_results=None, wai
42514251
log.debug("[control connection] Aborting wait for schema match due to shutdown")
42524252
return None
42534253

4254+
elapsed = self._time.time() - start
42544255
if schema_mismatches is not None:
4255-
log.warning("Node %s is reporting a schema disagreement: %s",
4256-
connection.endpoint, schema_mismatches)
4257-
return False
4256+
log.debug("[control connection] Error during schema agreement check after mismatch: %s",
4257+
exc)
4258+
raise
42584259

4259-
elapsed = self._time.time() - start
42604260
fallback_wait = total_timeout - elapsed
42614261
fallback = self._wait_for_schema_agreement_through_session(fallback_wait)
42624262
if fallback is not None:

tests/unit/test_control_connection.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,17 @@ def test_wait_for_schema_agreement_retries_control_connection_after_mismatch_the
332332
session.wait_for_schema_agreement.assert_not_called()
333333
assert self.connection.wait_for_responses.call_count == 3
334334

335+
def test_wait_for_schema_agreement_raises_connection_error_after_mismatch(self):
336+
peer_columns = self.connection.peer_results[0]
337+
mismatching_peer_rows = [list(row) for row in self.connection.peer_results[1]]
338+
mismatching_peer_rows[1][2] = 'b'
339+
self.connection.wait_for_responses.side_effect = [
340+
_node_meta_results(self.connection.local_results, (peer_columns, mismatching_peer_rows)),
341+
ConnectionShutdown("closed")]
342+
343+
with self.assertRaises(ConnectionShutdown):
344+
self.control_connection.wait_for_schema_agreement()
345+
335346
def test_wait_for_schema_agreement_does_not_exceed_configured_wait_with_session_fallback(self):
336347
session = Mock(is_shutdown=False)
337348

0 commit comments

Comments
 (0)