diff --git a/CHANGES.txt b/CHANGES.txt index dfdad516f8..2dabbf9e68 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.0.15: + * Fix index selection during rebuild with certain table layouts (CASSANDRA-9281) * Fix partition-level-delete-only workload accounting (CASSANDRA-9194) * Allow scrub to handle corrupted compressed chunks (CASSANDRA-9140) * Fix assertion error when resetlocalschema is run during repair (CASSANDRA-9249) @@ -57,9 +58,11 @@ * Fix MT mismatch between empty and GC-able data (CASSANDRA-8979) * Fix incorrect validation when snapshotting single table (CASSANDRA-8056) + 2.0.14 * Bind JMX to localhost unless explicitly configured otherwise (CASSANDRA-9085) + 2.0.13: * Add offline tool to relevel sstables (CASSANDRA-8301) * Preserve stream ID for more protocol errors (CASSANDRA-8848) diff --git a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java index 1db7de6170..d5e88d0e1e 100644 --- a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java +++ b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java @@ -589,7 +589,7 @@ public class SecondaryIndexManager { for (ColumnDefinition column : baseCfs.metadata.allColumns()) { - if (candidate.indexes(column.name)) + if (candidate.getColumnDefs().contains(column)) { filtered.add(candidate.getIndexName()); break; diff --git a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java index 8f4a18f1b6..001f838c53 100644 --- a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java +++ b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java @@ -2177,14 +2177,16 @@ public class ColumnFamilyStoreTest extends SchemaLoader @Test public void testRebuildSecondaryIndex() throws IOException { + ByteBuffer indexedColumnName = ByteBufferUtil.bytes("indexed"); RowMutation rm; rm = new RowMutation("PerRowSecondaryIndex", ByteBufferUtil.bytes("k1")); - rm.add("Indexed1", ByteBufferUtil.bytes("indexed"), ByteBufferUtil.bytes("foo"), 1); + rm.add("Indexed1", indexedColumnName, ByteBufferUtil.bytes("foo"), 1); rm.apply(); assertTrue(Arrays.equals("k1".getBytes(), PerRowSecondaryIndexTest.TestIndex.LAST_INDEXED_KEY.array())); - Keyspace.open("PerRowSecondaryIndex").getColumnFamilyStore("Indexed1").forceBlockingFlush(); + ColumnFamilyStore cfs = Keyspace.open("PerRowSecondaryIndex").getColumnFamilyStore("Indexed1"); + cfs.forceBlockingFlush(); PerRowSecondaryIndexTest.TestIndex.reset(); @@ -2193,7 +2195,9 @@ public class ColumnFamilyStoreTest extends SchemaLoader PerRowSecondaryIndexTest.TestIndex.reset(); - PerRowSecondaryIndexTest.TestIndex.ACTIVE = false; + ColumnDefinition indexedColumnDef = cfs.metadata.getColumnDefinition(indexedColumnName); + cfs.indexManager.getIndexForColumn(indexedColumnName).getColumnDefs().remove(indexedColumnDef); + ColumnFamilyStore.rebuildSecondaryIndex("PerRowSecondaryIndex", "Indexed1", PerRowSecondaryIndexTest.TestIndex.class.getSimpleName()); assertNull(PerRowSecondaryIndexTest.TestIndex.LAST_INDEXED_KEY); diff --git a/test/unit/org/apache/cassandra/db/index/PerRowSecondaryIndexTest.java b/test/unit/org/apache/cassandra/db/index/PerRowSecondaryIndexTest.java index 6a6956cfb1..81173b2210 100644 --- a/test/unit/org/apache/cassandra/db/index/PerRowSecondaryIndexTest.java +++ b/test/unit/org/apache/cassandra/db/index/PerRowSecondaryIndexTest.java @@ -27,6 +27,7 @@ import org.junit.Before; import org.junit.Test; import org.apache.cassandra.SchemaLoader; +import org.apache.cassandra.config.ColumnDefinition; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.db.*; import org.apache.cassandra.db.filter.QueryFilter; @@ -115,23 +116,15 @@ public class PerRowSecondaryIndexTest extends SchemaLoader public static class TestIndex extends PerRowSecondaryIndex { - public static volatile boolean ACTIVE = true; public static ColumnFamily LAST_INDEXED_ROW; public static ByteBuffer LAST_INDEXED_KEY; public static void reset() { - ACTIVE = true; LAST_INDEXED_KEY = null; LAST_INDEXED_ROW = null; } - @Override - public boolean indexes(ByteBuffer name) - { - return ACTIVE; - } - @Override public void index(ByteBuffer rowKey, ColumnFamily cf) {