cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject cassandra git commit: Add ks and table to err log about large collections
Date Fri, 08 May 2015 18:36:32 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 917068dcb -> 15235ee63


Add ks and table to err log about large collections

Patch by Carl Yeksigian; reviewed by Tyler Hobbs for CASSANDRA-9286


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

Branch: refs/heads/cassandra-2.0
Commit: 15235ee63be2d8f39486ff97dbbdd8ed24bb9812
Parents: 917068d
Author: Tyler Hobbs <tylerhobbs@apache.org>
Authored: Fri May 8 13:28:33 2015 -0500
Committer: Tyler Hobbs <tylerhobbs@apache.org>
Committed: Fri May 8 13:28:33 2015 -0500

----------------------------------------------------------------------
 CHANGES.txt                                              |  2 ++
 .../cassandra/cql3/statements/SelectStatement.java       |  2 +-
 .../org/apache/cassandra/db/marshal/CollectionType.java  | 11 +++++++----
 src/java/org/apache/cassandra/db/marshal/ListType.java   |  5 +++--
 src/java/org/apache/cassandra/db/marshal/MapType.java    |  5 +++--
 src/java/org/apache/cassandra/db/marshal/SetType.java    |  5 +++--
 6 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/15235ee6/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1540d28..d3715c4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.0.15:
+ * Include keyspace and table name in error log for collections over the size
+   limit (CASSANDRA-9286)
  * Avoid potential overlap in LCS with single-partition sstables (CASSANDRA-9322)
  * Log warning message when a table is queried before the schema has fully
    propagated (CASSANDRA-9136)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/15235ee6/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index 6b3c781..8a4deb6 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -1399,7 +1399,7 @@ public class SelectStatement implements CQLStatement, MeasurableForPreparedCache
         if (name.type.isCollection())
         {
             List<Pair<ByteBuffer, Column>> collection = group.getCollection(name.name.key);
-            result.add(collection == null ? null : ((CollectionType)name.type).serialize(collection));
+            result.add(collection == null ? null : ((CollectionType)name.type).serialize(name,
collection));
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/15235ee6/src/java/org/apache/cassandra/db/marshal/CollectionType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/CollectionType.java b/src/java/org/apache/cassandra/db/marshal/CollectionType.java
index 29b77a0..d1ae130 100644
--- a/src/java/org/apache/cassandra/db/marshal/CollectionType.java
+++ b/src/java/org/apache/cassandra/db/marshal/CollectionType.java
@@ -23,6 +23,7 @@ import java.util.List;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.cassandra.cql3.CFDefinition;
 import org.apache.cassandra.cql3.CQL3Type;
 import org.apache.cassandra.db.Column;
 import org.apache.cassandra.serializers.MarshalException;
@@ -58,7 +59,7 @@ public abstract class CollectionType<T> extends AbstractType<T>
 
     protected abstract void appendToStringBuilder(StringBuilder sb);
 
-    public abstract ByteBuffer serialize(List<Pair<ByteBuffer, Column>> columns);
+    public abstract ByteBuffer serialize(CFDefinition.Name name, List<Pair<ByteBuffer,
Column>> columns);
 
     @Override
     public String toString()
@@ -108,13 +109,15 @@ public abstract class CollectionType<T> extends AbstractType<T>
         return (ByteBuffer)result.flip();
     }
 
-    protected List<Pair<ByteBuffer, Column>> enforceLimit(List<Pair<ByteBuffer,
Column>> columns)
+    protected List<Pair<ByteBuffer, Column>> enforceLimit(CFDefinition.Name name,
List<Pair<ByteBuffer, Column>> columns)
     {
         if (columns.size() <= MAX_ELEMENTS)
             return columns;
 
-        logger.error("Detected collection with {} elements, more than the {} limit. Only
the first {} elements will be returned to the client. "
-                   + "Please see http://cassandra.apache.org/doc/cql3/CQL.html#collections
for more details.", columns.size(), MAX_ELEMENTS, MAX_ELEMENTS);
+        logger.error("Detected collection for table {}.{} with {} elements, more than the
{} limit. Only the first {}"
+                     + "elements will be returned to the client. Please see "
+                     + "http://cassandra.apache.org/doc/cql3/CQL.html#collections for more
details.",
+                     name.ksName, name.cfName, columns.size(), MAX_ELEMENTS, MAX_ELEMENTS);
         return columns.subList(0, MAX_ELEMENTS);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/15235ee6/src/java/org/apache/cassandra/db/marshal/ListType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/ListType.java b/src/java/org/apache/cassandra/db/marshal/ListType.java
index 4b45bd7..dff98b7 100644
--- a/src/java/org/apache/cassandra/db/marshal/ListType.java
+++ b/src/java/org/apache/cassandra/db/marshal/ListType.java
@@ -20,6 +20,7 @@ package org.apache.cassandra.db.marshal;
 import java.nio.ByteBuffer;
 import java.util.*;
 
+import org.apache.cassandra.cql3.CFDefinition;
 import org.apache.cassandra.db.Column;
 import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.exceptions.SyntaxException;
@@ -115,9 +116,9 @@ public class ListType<T> extends CollectionType<List<T>>
         sb.append(getClass().getName()).append(TypeParser.stringifyTypeParameters(Collections.<AbstractType<?>>singletonList(elements)));
     }
 
-    public ByteBuffer serialize(List<Pair<ByteBuffer, Column>> columns)
+    public ByteBuffer serialize(CFDefinition.Name name, List<Pair<ByteBuffer, Column>>
columns)
     {
-        columns = enforceLimit(columns);
+        columns = enforceLimit(name, columns);
 
         List<ByteBuffer> bbs = new ArrayList<ByteBuffer>(columns.size());
         int size = 0;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/15235ee6/src/java/org/apache/cassandra/db/marshal/MapType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/MapType.java b/src/java/org/apache/cassandra/db/marshal/MapType.java
index 08f795f..f6883ee 100644
--- a/src/java/org/apache/cassandra/db/marshal/MapType.java
+++ b/src/java/org/apache/cassandra/db/marshal/MapType.java
@@ -20,6 +20,7 @@ package org.apache.cassandra.db.marshal;
 import java.nio.ByteBuffer;
 import java.util.*;
 
+import org.apache.cassandra.cql3.CFDefinition;
 import org.apache.cassandra.db.Column;
 import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.exceptions.SyntaxException;
@@ -123,9 +124,9 @@ public class MapType<K, V> extends CollectionType<Map<K, V>>
     /**
      * Creates the same output than serialize, but from the internal representation.
      */
-    public ByteBuffer serialize(List<Pair<ByteBuffer, Column>> columns)
+    public ByteBuffer serialize(CFDefinition.Name name, List<Pair<ByteBuffer, Column>>
columns)
     {
-        columns = enforceLimit(columns);
+        columns = enforceLimit(name, columns);
 
         List<ByteBuffer> bbs = new ArrayList<ByteBuffer>(2 * columns.size());
         int size = 0;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/15235ee6/src/java/org/apache/cassandra/db/marshal/SetType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/SetType.java b/src/java/org/apache/cassandra/db/marshal/SetType.java
index 614ecc7..b43c9b6 100644
--- a/src/java/org/apache/cassandra/db/marshal/SetType.java
+++ b/src/java/org/apache/cassandra/db/marshal/SetType.java
@@ -20,6 +20,7 @@ package org.apache.cassandra.db.marshal;
 import java.nio.ByteBuffer;
 import java.util.*;
 
+import org.apache.cassandra.cql3.CFDefinition;
 import org.apache.cassandra.db.Column;
 import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.exceptions.SyntaxException;
@@ -88,9 +89,9 @@ public class SetType<T> extends CollectionType<Set<T>>
         sb.append(getClass().getName()).append(TypeParser.stringifyTypeParameters(Collections.<AbstractType<?>>singletonList(elements)));
     }
 
-    public ByteBuffer serialize(List<Pair<ByteBuffer, Column>> columns)
+    public ByteBuffer serialize(CFDefinition.Name name, List<Pair<ByteBuffer, Column>>
columns)
     {
-        columns = enforceLimit(columns);
+        columns = enforceLimit(name, columns);
 
         List<ByteBuffer> bbs = new ArrayList<ByteBuffer>(columns.size());
         int size = 0;


Mime
View raw message