diff --git a/CHANGES.txt b/CHANGES.txt index 37105f3a1e..91cac4f265 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -15,6 +15,7 @@ Merged from 1.2: * Fix availability validation for LOCAL_ONE CL (CASSANDRA-7319) * Use LOCAL_ONE for non-superuser auth queries (CASSANDRA-7328) + * Fix handling of empty counter replication mutations (CASSANDRA-7144) 2.0.8 diff --git a/src/java/org/apache/cassandra/db/CounterMutation.java b/src/java/org/apache/cassandra/db/CounterMutation.java index fb363c2746..3caeda5f71 100644 --- a/src/java/org/apache/cassandra/db/CounterMutation.java +++ b/src/java/org/apache/cassandra/db/CounterMutation.java @@ -104,7 +104,8 @@ public class CounterMutation implements IMutation ColumnFamily cf = row.cf; replicationMutation.add(cf); } - return replicationMutation; + + return replicationMutation.isEmpty() ? null : replicationMutation; } private void addReadCommandFromColumnFamily(String keyspaceName, ByteBuffer key, ColumnFamily columnFamily, long timestamp, List commands) diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java index 2bf8e7fdb3..59834cf539 100644 --- a/src/java/org/apache/cassandra/service/StorageProxy.java +++ b/src/java/org/apache/cassandra/service/StorageProxy.java @@ -1077,8 +1077,18 @@ public class StorageProxy implements StorageProxyMBean { public void runMayThrow() throws OverloadedException { - // send mutation to other replica - sendToHintedEndpoints(cm.makeReplicationMutation(), remotes, responseHandler, localDataCenter); + // send the mutation to other replicas, if not null (see CASSANDRA-7144 for details) + RowMutation replicationMutation = cm.makeReplicationMutation(); + if (replicationMutation != null) + { + sendToHintedEndpoints(replicationMutation, remotes, responseHandler, localDataCenter); + } + else + { + // simulate the rest of the responses to avoid the timeout + for (int i = 0; i < remotes.size(); i++) + responseHandler.response(null); + } } }); }