From 32e1b16b81af5afb244860af9dad368575d69988 Mon Sep 17 00:00:00 2001 From: Sylvain Lebresne Date: Wed, 7 May 2014 10:27:04 +0200 Subject: [PATCH 1/2] Warn when timestamps are provided on CAS batch patch by slebresne; reviewed by iamaleksey for CASSANDRA-7067 --- CHANGES.txt | 4 ++++ .../cql3/statements/BatchStatement.java | 24 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 517f0ab74a..1e60fc370a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +2.0.9 + * Warn when 'USING TIMESTAMP' is used on a CAS BATCH (CASSANDRA-7067) + + 2.0.8 * Correctly delete scheduled range xfers (CASSANDRA-7143) * Make batchlog replica selection rack-aware (CASSANDRA-6551) diff --git a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java index 8e61ae52ea..c03548bb4e 100644 --- a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java @@ -41,6 +41,9 @@ import org.apache.cassandra.transport.messages.ResultMessage; */ public class BatchStatement implements CQLStatement, MeasurableForPreparedCache { + private static boolean loggedCASTimestamp = false; + private static boolean loggedCounterTimestamp = false; + public static enum Type { LOGGED, UNLOGGED, COUNTER @@ -102,9 +105,28 @@ public class BatchStatement implements CQLStatement, MeasurableForPreparedCache if (attrs.isTimeToLiveSet()) throw new InvalidRequestException("Global TTL on the BATCH statement is not supported."); + boolean timestampSet = attrs.isTimestampSet(); + if (timestampSet) + { + if (hasConditions && !loggedCASTimestamp) + { + logger.warn("Detected use of 'USING TIMESTAMP' on a BATCH with conditions. This is invalid, " + + "custom timestamps are not allowed when conditions are used and the timestamp has been ignored. " + + "Such queries will be rejected in Cassandra 2.1+ - please fix your queries before then."); + loggedCASTimestamp = true; + } + if (type == Type.COUNTER && !loggedCounterTimestamp) + { + logger.warn("Detected use of 'USING TIMESTAMP' in a counter BATCH. This is invalid " + + "because counters do not use timestamps, and the timestamp has been ignored. " + + "Such queries will be rejected in Cassandra 2.1+ - please fix your queries before then."); + loggedCounterTimestamp = true; + } + } + for (ModificationStatement statement : statements) { - if (attrs.isTimestampSet() && statement.isTimestampSet()) + if (timestampSet && statement.isTimestampSet()) throw new InvalidRequestException("Timestamp must be set either on BATCH or individual statements"); } } From 19ff1932cd3275f114a8820d3a5d0cdf176aa261 Mon Sep 17 00:00:00 2001 From: Sylvain Lebresne Date: Wed, 7 May 2014 10:30:14 +0200 Subject: [PATCH 2/2] Remove duplicate entries in changelog --- CHANGES.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 1e60fc370a..fc192eff0c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -39,10 +39,6 @@ Merged from 1.2: 2.0.7 * Put nodes in hibernate when join_ring is false (CASSANDRA-6961) - * Continue assassinating even if the endpoint vanishes (CASSANDRA-6787) - * Non-droppable verbs shouldn't be dropped from OTC (CASSANDRA-6980) - * Shutdown batchlog executor in SS#drain() (CASSANDRA-7025) - * Schedule schema pulls on change (CASSANDRA-6971) * Avoid early loading of non-system keyspaces before compaction-leftovers cleanup at startup (CASSANDRA-6913) * Restrict Windows to parallel repairs (CASSANDRA-6907)