After that we alter Type of UDTs to rename the field without change on index.
The UDTs can change the name BUT the console show error "schema is invalid" e.g.,
cqlsh:keyspace>
CREATE TYPE address (
city2 text,
zip int
);
cqlsh:keyspace> CREATE CUSTOM INDEX test_idx ON test () USING 'com.stratio.cassandra.lucene.Index' WITH OPTIONS = {'refresh_seconds': '1', 'schema': '{ fields: { "address.city2" : {type: "string"} } }'};
cqlsh:keyspace> alter type address rename city2 to city;
ConfigurationException: 'schema' is invalid : No column definition 'address.city2' for field 'address.city2'
cqlsh:keyspace> desc type address;
CREATE TYPE address (
city text,
zip int
);
After this error found the system still working.
However, when sometime we need to restart Cassandra DB.
The startup is Error with this message:
ERROR [main] 2017-11-23 10:03:36,769 CassandraDaemon.java:706 - Exception encountered during startup
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.apache.cassandra.index.SecondaryIndexManager.createInstance(SecondaryIndexManager.java:432) ~[apache-cassandra-3.11.0.jar:3.11.0]
at org.apache.cassandra.index.SecondaryIndexManager.createIndex(SecondaryIndexManager.java:166) ~[apache-cassandra-3.11.0.jar:3.11.0]
at org.apache.cassandra.index.SecondaryIndexManager.addIndex(SecondaryIndexManager.java:192) ~[apache-cassandra-3.11.0.jar:3.11.0]
at org.apache.cassandra.db.ColumnFamilyStore.<init>(ColumnFamilyStore.java:446) ~[apache-cassandra-3.11.0.jar:3.11.0]
at org.apache.cassandra.db.ColumnFamilyStore.createColumnFamilyStore(ColumnFamilyStore.java:618) ~[apache-cassandra-3.11.0.jar:3.11.0]
at org.apache.cassandra.db.ColumnFamilyStore.createColumnFamilyStore(ColumnFamilyStore.java:592) ~[apache-cassandra-3.11.0.jar:3.11.0]
at org.apache.cassandra.db.ColumnFamilyStore.createColumnFamilyStore(ColumnFamilyStore.java:583) ~[apache-cassandra-3.11.0.jar:3.11.0]
at org.apache.cassandra.db.Keyspace.initCf(Keyspace.java:409) ~[apache-cassandra-3.11.0.jar:3.11.0]
at org.apache.cassandra.db.Keyspace.<init>(Keyspace.java:322) ~[apache-cassandra-3.11.0.jar:3.11.0]
at org.apache.cassandra.db.Keyspace.open(Keyspace.java:127) ~[apache-cassandra-3.11.0.jar:3.11.0]
at org.apache.cassandra.db.Keyspace.open(Keyspace.java:104) ~[apache-cassandra-3.11.0.jar:3.11.0]
at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:292) [apache-cassandra-3.11.0.jar:3.11.0]
at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:600) [apache-cassandra-3.11.0.jar:3.11.0]
at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:689) [apache-cassandra-3.11.0.jar:3.11.0]
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_131]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_131]
at org.apache.cassandra.index.SecondaryIndexManager.createInstance(SecondaryIndexManager.java:428) ~[apache-cassandra-3.11.0.jar:3.11.0]
... 13 common frames omitted
Caused by: com.stratio.cassandra.lucene.IndexException: null
at com.stratio.cassandra.lucene.Index.liftedTree1$1(Index.scala:56) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.Index.<init>(Index.scala:55) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
... 18 common frames omitted
Caused by: com.stratio.cassandra.lucene.IndexException: 'schema' is invalid : No column definition 'address.city2' for field 'address.city2'
at com.stratio.cassandra.lucene.IndexOptions$.$anonfun$parseSchema$1(IndexOptions.scala:181) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at scala.Option.map(Option.scala:146) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.IndexOptions$.parseSchema(IndexOptions.scala:175) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.IndexOptions.<init>(IndexOptions.scala:63) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.IndexService.<init>(IndexService.scala:58) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.IndexServiceSkinny.<init>(IndexServiceSkinny.scala:37) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.IndexService$.build(IndexService.scala:434) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.Index.liftedTree1$1(Index.scala:55) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
... 19 common frames omitted
Caused by: com.stratio.cassandra.lucene.IndexException: No column definition 'address.city2' for field 'address.city2'
at com.stratio.cassandra.lucene.util.SchemaValidator$.$anonfun$validate$3(SchemaValidator.scala:94) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at scala.collection.immutable.Range.foreach$mVc$sp(Range.scala:156) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.util.SchemaValidator$.validate(SchemaValidator.scala:90) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.util.SchemaValidator$.$anonfun$validate$2(SchemaValidator.scala:49) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.util.SchemaValidator$.$anonfun$validate$2$adapted(SchemaValidator.scala:48) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at scala.collection.AbstractIterator.foreach(Iterator.scala:932) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at scala.collection.AbstractIterable.foreach(Iterable.scala:54) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.util.SchemaValidator$.$anonfun$validate$1(SchemaValidator.scala:48) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.util.SchemaValidator$.$anonfun$validate$1$adapted(SchemaValidator.scala:48) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at scala.collection.AbstractIterator.foreach(Iterator.scala:932) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at scala.collection.AbstractIterable.foreach(Iterable.scala:54) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.util.SchemaValidator$.validate(SchemaValidator.scala:48) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
at com.stratio.cassandra.lucene.IndexOptions$.$anonfun$parseSchema$1(IndexOptions.scala:177) ~[cassandra-lucene-index-plugin-3.11.0.1.jar:na]
... 26 common frames omitted
We modify plugin to ignore schema validation for User Define Type in SchemaValidator.scala#validate. and comment here:
/
val cellType = cellDefinition.type
cellType.isCollection
val udtNames = Column.parseUdtNames(column)
if (udtNames.isEmpty) {
checkSupported(cellType, cellName, supportsCollections)
} else {
var column = Column.apply(cellName)
var currentType = cellType
for (i <- udtNames.indices) {
column = column.withUDTName(udtNames(i))
childType(currentType, udtNames(i)) match {
case None => throw new IndexException(
s"No column definition '${column.mapper}' for field '$field'")
case Some(n) if i == udtNames.indices.last => checkSupported(n, column.mapper, supportsCollections)
case Some(n) => currentType = n
}
}
}/
}
On the 2'nd ways is working for temporary to make DB can start and drop the problem index.
However, the plug-in still need to be Fixed for this case. (It's look like a BUG).
We use cassandra and plugin version 3.11.0.0
We try to do indexing field that type is UDTs following https://github.com/Stratio/cassandra-lucene-index/blob/branch-3.11.0/doc/documentation.rst#collections
After that we alter Type of UDTs to rename the field without change on index.
The UDTs can change the name BUT the console show error "schema is invalid" e.g.,
After this error found the system still working. However, when sometime we need to restart Cassandra DB. The startup is Error with this message:
The solution: we try two ways and it's working.
we do delete index metadata file in system schema and restart DB following https://github.com/Stratio/cassandra-lucene-index/issues/108
We modify plugin to ignore schema validation for User Define Type in SchemaValidator.scala#validate. and comment here: / val cellType = cellDefinition.
type
cellType.isCollection val udtNames = Column.parseUdtNames(column) if (udtNames.isEmpty) { checkSupported(cellType, cellName, supportsCollections) } else { var column = Column.apply(cellName) var currentType = cellType for (i <- udtNames.indices) { column = column.withUDTName(udtNames(i)) childType(currentType, udtNames(i)) match { case None => throw new IndexException( s"No column definition '${column.mapper}' for field '$field'") case Some(n) if i == udtNames.indices.last => checkSupported(n, column.mapper, supportsCollections) case Some(n) => currentType = n } } }/ }On the 2'nd ways is working for temporary to make DB can start and drop the problem index. However, the plug-in still need to be Fixed for this case. (It's look like a BUG).