Skip to content

Commit be479b9

Browse files
committed
Merge branch 'dcrt_rethrow_write_timeout' into 338
2 parents c9fb54a + 088a546 commit be479b9

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

cassandra/policies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ def on_write_timeout(self, query, consistency, write_type,
816816
required_responses, received_responses, retry_num):
817817
if retry_num != 0:
818818
return (self.RETHROW, None)
819-
elif write_type in (WriteType.SIMPLE, WriteType.BATCH, WriteType.COUNTER):
819+
elif write_type in (WriteType.SIMPLE, WriteType.BATCH, WriteType.COUNTER) and received_responses > 0:
820820
return (self.IGNORE, None)
821821
elif write_type == WriteType.UNLOGGED_BATCH:
822822
return self._pick_consistency(received_responses)

tests/unit/test_policies.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,14 @@ def test_write_timeout(self):
10521052
self.assertEqual(retry, RetryPolicy.RETHROW)
10531053
self.assertEqual(consistency, None)
10541054

1055+
# On these type of writes failures should not be ignored
1056+
# if received_responses is 0
1057+
for write_type in (WriteType.SIMPLE, WriteType.BATCH, WriteType.COUNTER):
1058+
retry, consistency = policy.on_write_timeout(
1059+
query=None, consistency=ONE, write_type=write_type,
1060+
required_responses=1, received_responses=0, retry_num=0)
1061+
self.assertEqual(retry, RetryPolicy.RETHROW)
1062+
10551063
# ignore failures on these types of writes
10561064
for write_type in (WriteType.SIMPLE, WriteType.BATCH, WriteType.COUNTER):
10571065
retry, consistency = policy.on_write_timeout(

0 commit comments

Comments
 (0)