diff --git a/cassandra/policies.py b/cassandra/policies.py index d4d8914c..6d6c23b9 100644 --- a/cassandra/policies.py +++ b/cassandra/policies.py @@ -816,7 +816,7 @@ class DowngradingConsistencyRetryPolicy(RetryPolicy): required_responses, received_responses, retry_num): if retry_num != 0: return (self.RETHROW, None) - elif write_type in (WriteType.SIMPLE, WriteType.BATCH, WriteType.COUNTER): + elif write_type in (WriteType.SIMPLE, WriteType.BATCH, WriteType.COUNTER) and received_responses > 0: return (self.IGNORE, None) elif write_type == WriteType.UNLOGGED_BATCH: return self._pick_consistency(received_responses) diff --git a/tests/unit/test_policies.py b/tests/unit/test_policies.py index 4f865fb1..bd854104 100644 --- a/tests/unit/test_policies.py +++ b/tests/unit/test_policies.py @@ -1052,6 +1052,14 @@ class DowngradingConsistencyRetryPolicyTest(unittest.TestCase): self.assertEqual(retry, RetryPolicy.RETHROW) self.assertEqual(consistency, None) + # On these type of writes failures should not be ignored + # if received_responses is 0 + for write_type in (WriteType.SIMPLE, WriteType.BATCH, WriteType.COUNTER): + retry, consistency = policy.on_write_timeout( + query=None, consistency=ONE, write_type=write_type, + required_responses=1, received_responses=0, retry_num=0) + self.assertEqual(retry, RetryPolicy.RETHROW) + # ignore failures on these types of writes for write_type in (WriteType.SIMPLE, WriteType.BATCH, WriteType.COUNTER): retry, consistency = policy.on_write_timeout(