cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject git commit: Log USING TTL/TIMESTAMP in a counter update warning
Date Tue, 11 Feb 2014 22:40:33 GMT
Updated Branches:
  refs/heads/cassandra-1.2 1b8b7b540 -> 7787deab7


Log USING TTL/TIMESTAMP in a counter update warning

patch by Aleksey Yeschenko; reviewed by Sylvain Lebresne for
CASSANDRA-6649


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7787deab
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7787deab
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7787deab

Branch: refs/heads/cassandra-1.2
Commit: 7787deab72fe5772170c0cf6b6712ed2211158ed
Parents: 1b8b7b5
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Wed Feb 12 01:39:40 2014 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Wed Feb 12 01:39:40 2014 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cql3/statements/ModificationStatement.java  | 27 ++++++++++++++++++++
 2 files changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7787deab/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 82783f8..56059a1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -3,6 +3,7 @@
  * Fix partition and range deletes not triggering flush (CASSANDRA-6655)
  * Fix mean cells and mean row size per sstable calculations (CASSANDRA-6667)
  * Compact hints after partial replay to clean out tombstones (CASSANDRA-6666)
+ * Log USING TTL/TIMESTAMP in a counter update warning (CASSANDRA-6649)
 
 
 1.2.15

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7787deab/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
index bfbf511..1b4dc37 100644
--- a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
@@ -20,6 +20,9 @@ package org.apache.cassandra.cql3.statements;
 import java.nio.ByteBuffer;
 import java.util.*;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.cassandra.auth.Permission;
 import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.db.*;
@@ -45,6 +48,11 @@ public abstract class ModificationStatement extends CFStatement implements
CQLSt
         LOGGED, UNLOGGED, COUNTER
     }
 
+    private static final Logger logger = LoggerFactory.getLogger(ModificationStatement.class);
+
+    private static boolean loggedCounterTTL = false;
+    private static boolean loggedCounterTimestamp = false;
+
     protected Type type;
 
     private Long timestamp;
@@ -74,6 +82,25 @@ public abstract class ModificationStatement extends CFStatement implements
CQLSt
 
         if (timeToLive > ExpiringColumn.MAX_TTL)
             throw new InvalidRequestException(String.format("ttl is too large. requested
(%d) maximum (%d)", timeToLive, ExpiringColumn.MAX_TTL));
+
+        if (type == Type.COUNTER)
+        {
+            if (timestamp != null && !loggedCounterTimestamp)
+            {
+                logger.warn("Detected use of 'USING TIMESTAMP' in a counter UPDATE. 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;
+            }
+
+            if (timeToLive != 0 && !loggedCounterTTL)
+            {
+                logger.warn("Detected use of 'USING TTL' in a counter UPDATE. This is invalid
" +
+                            "because counter tables do not support TTL, and the TTL value
has been ignored. " +
+                            "Such queries will be rejected in Cassandra 2.1+ - please fix
your queries before then.");
+                loggedCounterTTL = true;
+            }
+        }
     }
 
     protected abstract void validateConsistency(ConsistencyLevel cl) throws InvalidRequestException;


Mime
View raw message