cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1024000 - in /cassandra/trunk: CHANGES.txt src/java/org/apache/cassandra/db/ColumnFamilyStore.java test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
Date Mon, 18 Oct 2010 20:41:46 GMT
Author: jbellis
Date: Mon Oct 18 20:41:46 2010
New Revision: 1024000

URL: http://svn.apache.org/viewvc?rev=1024000&view=rev
Log:
fix potential infinite loop in 2ary index queries
patch by jbellis; tested by Jason Tanner for CASSANDRA-1623

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1024000&r1=1023999&r2=1024000&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Mon Oct 18 20:41:46 2010
@@ -42,6 +42,7 @@ dev
  * Make memtable flush thresholds per-CF instead of global (CASSANDRA-1007)
  * add cli support for binary data without CfDef hints (CASSANDRA-1603)
  * fix building SSTable statistics post-stream (CASSANDRA-1620)
+ * fix potential infinite loop in 2ary index queries (CASSANDRA-1623)
 
 
 0.7-beta2

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1024000&r1=1023999&r2=1024000&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Mon Oct 18 20:41:46
2010
@@ -1353,9 +1353,9 @@ public class ColumnFamilyStore implement
                 if (rows.size() == clause.count)
                     break outer;
             }
-            startKey = dataKey;
-            if (n < clause.count)
+            if (n < clause.count || Arrays.equals(startKey, dataKey))
                 break;
+            startKey = dataKey;
         }
 
         return rows;

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=1024000&r1=1023999&r2=1024000&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java Mon Oct 18
20:41:46 2010
@@ -182,12 +182,20 @@ public class ColumnFamilyStoreTest exten
         assert rows.get(0).cf.getColumnCount() == 1 : rows.get(0).cf;
 
         // once more, this time with a slice rowset that needs to be expanded
-        SliceQueryFilter sqf = new SliceQueryFilter(ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY,
false, 0);
-        rows = Table.open("Keyspace1").getColumnFamilyStore("Indexed1").scan(clause, range,
sqf);
+        SliceQueryFilter emptyFilter = new SliceQueryFilter(ArrayUtils.EMPTY_BYTE_ARRAY,
ArrayUtils.EMPTY_BYTE_ARRAY, false, 0);
+        rows = Table.open("Keyspace1").getColumnFamilyStore("Indexed1").scan(clause, range,
emptyFilter);
 
         assert rows.size() == 1 : StringUtils.join(rows, ",");
         assert Arrays.equals("k3".getBytes(), rows.get(0).key.key);
         assert rows.get(0).cf.getColumnCount() == 0;
+
+        // query with index hit but rejected by secondary clause, with a small enough count
that just checking count
+        // doesn't tell the scan loop that it's done
+        IndexExpression expr3 = new IndexExpression("notbirthdate".getBytes("UTF8"), IndexOperator.EQ,
FBUtilities.toByteArray(-1L));
+        clause = new IndexClause(Arrays.asList(expr, expr3), ArrayUtils.EMPTY_BYTE_ARRAY,
1);
+        rows = Table.open("Keyspace1").getColumnFamilyStore("Indexed1").scan(clause, range,
filter);
+
+        assert rows.isEmpty();
     }
 
     @Test



Mime
View raw message