Merge branch 'cassandra-3.0' into trunk

This commit is contained in:
Sam Tunnicliffe 2015-10-28 11:37:08 +00:00
commit 7297b3ca22
5 changed files with 31 additions and 54 deletions

View File

@ -5,6 +5,7 @@
3.0
* Fix marking of indexes as built and removed (CASSANDRA-10601)
* Skip initialization of non-registered 2i instances, remove Index::getIndexName (CASSANDRA-10595)
* Fix batches on multiple tables (CASSANDRA-10554)
* Ensure compaction options are validated when updating KeyspaceMetadata (CASSANDRA-10569)

View File

@ -185,8 +185,8 @@ public class SecondaryIndexManager implements IndexRegistry
Index index = indexes.remove(indexName);
if (null != index)
{
markIndexRemoved(indexName);
executeBlocking(index.getInvalidateTask());
unregisterIndex(index);
}
}
@ -355,14 +355,14 @@ public class SecondaryIndexManager implements IndexRegistry
indexes.stream().map(i -> i.getIndexMetadata().name).collect(Collectors.joining(",")));
}
private void markIndexBuilt(String indexName)
public void markIndexBuilt(String indexName)
{
SystemKeyspace.setIndexBuilt(baseCfs.name, indexName);
SystemKeyspace.setIndexBuilt(baseCfs.keyspace.getName(), indexName);
}
private void markIndexRemoved(String indexName)
public void markIndexRemoved(String indexName)
{
SystemKeyspace.setIndexRemoved(baseCfs.name, indexName);
SystemKeyspace.setIndexRemoved(baseCfs.keyspace.getName(), indexName);
}
@ -410,6 +410,7 @@ public class SecondaryIndexManager implements IndexRegistry
*/
public void invalidateAllIndexesBlocking()
{
markAllIndexesRemoved();
executeAllBlocking(indexes.values().stream(), Index::getInvalidateTask);
}

View File

@ -176,7 +176,6 @@ public abstract class CassandraIndex implements Index
public Callable<?> getInvalidateTask()
{
return () -> {
markRemoved();
invalidate();
return null;
};
@ -632,16 +631,6 @@ public abstract class CassandraIndex implements Index
return SystemKeyspace.isIndexBuilt(baseCfs.keyspace.getName(), metadata.name);
}
private void markBuilt()
{
SystemKeyspace.setIndexBuilt(baseCfs.keyspace.getName(), metadata.name);
}
private void markRemoved()
{
SystemKeyspace.setIndexRemoved(baseCfs.keyspace.getName(), metadata.name);
}
private boolean isPrimaryKeyIndex()
{
return indexedColumn.isPrimaryKeyColumn();
@ -668,7 +657,7 @@ public abstract class CassandraIndex implements Index
baseCfs.metadata.ksName,
baseCfs.metadata.cfName,
metadata.name);
markBuilt();
baseCfs.indexManager.markIndexBuilt(metadata.name);
return;
}
@ -682,7 +671,7 @@ public abstract class CassandraIndex implements Index
Future<?> future = CompactionManager.instance.submitIndexBuild(builder);
FBUtilities.waitOnFuture(future);
indexCfs.forceBlockingFlush();
markBuilt();
baseCfs.indexManager.markIndexBuilt(metadata.name);
}
logger.info("Index build of {} complete", metadata.name);
}

View File

@ -468,6 +468,26 @@ public class CassandraIndexTest extends CQLTester
assertRows(execute("SELECT * FROM %s WHERE c = 3"), row(2, 3, 3));
}
@Test
public void indexCorrectlyMarkedAsBuildAndRemoved() throws Throwable
{
String indexName = "build_remove_test_idx";
String tableName = createTable("CREATE TABLE %s (a int, b int, c int, PRIMARY KEY (a, b))");
createIndex(String.format("CREATE INDEX %s ON %%s(c)", indexName));
waitForIndex(KEYSPACE, tableName, indexName);
// check that there are no other rows in the built indexes table
assertRows(execute(String.format("SELECT * FROM %s.\"%s\"", SystemKeyspace.NAME, SystemKeyspace.BUILT_INDEXES)),
row(KEYSPACE, indexName));
// rebuild the index and verify the built status table
getCurrentColumnFamilyStore().rebuildSecondaryIndex(indexName);
waitForIndex(KEYSPACE, tableName, indexName);
// check that there are no other rows in the built indexes table
assertRows(execute(String.format("SELECT * FROM %s.\"%s\"", SystemKeyspace.NAME, SystemKeyspace.BUILT_INDEXES)),
row(KEYSPACE, indexName));
}
// this is slightly annoying, but we cannot read rows from the methods in Util as
// ReadCommand#executeInternal uses metadata retrieved via the cfId, which the index
// CFS inherits from the base CFS. This has the 'wrong' partitioner (the index table

View File

@ -121,7 +121,6 @@ public class CustomCassandraIndex implements Index
public Callable<?> getInvalidateTask()
{
return () -> {
markRemoved();
invalidate();
return null;
};
@ -217,29 +216,6 @@ public class CustomCassandraIndex implements Index
public Index.Searcher searcherFor(ReadCommand command)
{
return null;
/*
Optional<RowFilter.Expression> target = getTargetExpression(command.rowFilter().getExpressions());
if (target.isPresent())
{
target.get().validateForIndexing();
switch (getIndexMetadata().indexType)
{
case COMPOSITES:
return new CompositesSearcher(command, target.get(), this);
case KEYS:
return new KeysSearcher(command, target.get(), this);
default:
throw new IllegalStateException(String.format("Unsupported index type %s for index %s on %s",
metadata.indexType,
metadata.name,
indexedColumn.name.toString()));
}
}
return null;
*/
}
public void validate(PartitionUpdate update) throws InvalidRequestException
@ -612,16 +588,6 @@ public class CustomCassandraIndex implements Index
return SystemKeyspace.isIndexBuilt(baseCfs.keyspace.getName(), metadata.name);
}
private void markBuilt()
{
SystemKeyspace.setIndexBuilt(baseCfs.keyspace.getName(), metadata.name);
}
private void markRemoved()
{
SystemKeyspace.setIndexRemoved(baseCfs.keyspace.getName(), metadata.name);
}
private boolean isPrimaryKeyIndex()
{
return indexedColumn.isPrimaryKeyColumn();
@ -648,7 +614,7 @@ public class CustomCassandraIndex implements Index
baseCfs.metadata.ksName,
baseCfs.metadata.cfName,
metadata.name);
markBuilt();
baseCfs.indexManager.markIndexBuilt(metadata.name);
return;
}
@ -662,7 +628,7 @@ public class CustomCassandraIndex implements Index
Future<?> future = CompactionManager.instance.submitIndexBuild(builder);
FBUtilities.waitOnFuture(future);
indexCfs.forceBlockingFlush();
markBuilt();
baseCfs.indexManager.markIndexBuilt(metadata.name);
}
logger.info("Index build of {} complete", metadata.name);
}