Cassandra可能因服务器内存不足而被杀。重新启动后,Cassandra无法使用java.lang.ClassCastException构建AsciiType二级索引。这是cassandra日志输出:
INFO 16:31:37,109 Creating new index : ColumnDefinition {
name=666f6c6c6f7754797065,
validator=org.apache.cassandra.db.marshal.AsciiType,
index_type=KEYS,
index_name='mySecondaryIndexField'
}
INFO 16:31:37,115 reading saved cache /var/lib/cassandra/saved_caches/MyProject-MyCF.mySecondaryIndexField-KeyCache
INFO 16:31:37,117 Opening /var/lib/cassandra/data/MyProject/MyCF/MyProject-MyCF.mySecondaryIndexField-hd-1 (399 bytes)
ERROR 16:31:37,121 Exception in thread Thread[SSTableBatchOpen:1,5,main]
**java.lang.ClassCastException: [B cannot be cast to java.nio.ByteBuffer**
at org.apache.cassandra.db.marshal.AsciiType.compare(AsciiType.java:28)
at org.apache.cassandra.dht.LocalToken.compareTo(LocalToken.java:45)
at org.apache.cassandra.db.DecoratedKey.compareTo(DecoratedKey.java:89)
at org.apache.cassandra.db.DecoratedKey.compareTo(DecoratedKey.java:38)
at java.util.TreeMap.getEntry(TreeMap.java:345)
at java.util.TreeMap.containsKey(TreeMap.java:226)
at java.util.TreeSet.contains(TreeSet.java:234)
at org.apache.cassandra.io.sstable.SSTableReader.load(SSTableReader.java:396)
at org.apache.cassandra.io.sstable.SSTableReader.open(SSTableReader.java:187)
at org.apache.cassandra.io.sstable.SSTableReader$1.run(SSTableReader.java:225)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
使用此辅助索引的查询仅返回结果集的一小部分作为结果。然后Cassnadra再次重新启动第二次,不抛出此异常并正确重建二级索引并且所有查询都已恢复并按预期返回结果。
我的辅助索引字段“mySecondaryIndexField”只有2个可能的字符串值。
以下是我的Column Family的配置:
Column Type - Standard
Comparator Type - org.apache.cassandra.db.marshal.AsciiType
Read Repair Chance - 1
Index Options - name: mySecondaryIndexField
validation_class: org.apache.cassandra.db.marshal.AsciiType
index_type: 0
index_name: mySecondaryIndexField
index_options:
Gc Grace Seconds - 864000
Default Validation Class - org.apache.cassandra.db.marshal.BytesType
Id - 1023
Min Compaction Threshold - 4
Max Compaction Threshold - 32
Replicate On Write - 1
Key Validation Class - org.apache.cassandra.db.marshal.BytesType
Compaction Strategy - org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy
Compaction Strategy Options - None
Sstable Compression -org.apache.cassandra.io.compress.SnappyCompressor
Caching - KEYS_ONLY
有没有人遇到过类似的问题? Cassandra版本是1.1.1。