Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-13174

Indexing is allowed on Duration type when it should not be

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • 3.11.0, 4.0-alpha1, 4.0
    • Legacy/CQL
    • None
    • C* 3.10

    • Normal

    Description

      Looks like secondary indexing is allowed on duration type columns. Since comparisons are not possible for the duration type, indexing on it also should be invalid.

      1)

      CREATE TABLE duration_table (k int PRIMARY KEY, d duration);
      INSERT INTO duration_table (k, d) VALUES (0, 1s);
      SELECT * from duration_table WHERE d=1s ALLOW FILTERING;
      

      The above throws an error:

      WARN  [ReadStage-2] 2017-01-31 17:09:57,821 AbstractLocalAwareExecutorService.java:167 - Uncaught exception on thread Thread[ReadStage-2,10,main]: {}
      java.lang.RuntimeException: java.lang.UnsupportedOperationException
      	at org.apache.cassandra.service.StorageProxy$DroppableRunnable.run(StorageProxy.java:2591) ~[main/:na]
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_91]
      	at org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$FutureTask.run(AbstractLocalAwareExecutorService.java:162) ~[main/:na]
      	at org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$LocalSessionFutureTask.run(AbstractLocalAwareExecutorService.java:134) [main/:na]
      	at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:109) [main/:na]
      	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91]
      Caused by: java.lang.UnsupportedOperationException: null
      	at org.apache.cassandra.db.marshal.AbstractType.compareCustom(AbstractType.java:174) ~[main/:na]
      	at org.apache.cassandra.db.marshal.AbstractType.compare(AbstractType.java:160) ~[main/:na]
      	at org.apache.cassandra.db.marshal.AbstractType.compareForCQL(AbstractType.java:204) ~[main/:na]
      	at org.apache.cassandra.cql3.Operator.isSatisfiedBy(Operator.java:201) ~[main/:na]
      	at org.apache.cassandra.db.filter.RowFilter$SimpleExpression.isSatisfiedBy(RowFilter.java:719) ~[main/:na]
      	at org.apache.cassandra.db.filter.RowFilter$CQLFilter$1IsSatisfiedFilter.applyToRow(RowFilter.java:324) ~[main/:na]
      	at org.apache.cassandra.db.transform.BaseRows.applyOne(BaseRows.java:120) ~[main/:na]
      	at org.apache.cassandra.db.transform.BaseRows.add(BaseRows.java:110) ~[main/:na]
      	at org.apache.cassandra.db.transform.UnfilteredRows.add(UnfilteredRows.java:44) ~[main/:na]
      	at org.apache.cassandra.db.transform.Transformation.add(Transformation.java:174) ~[main/:na]
      	at org.apache.cassandra.db.transform.Transformation.apply(Transformation.java:140) ~[main/:na]
      	at org.apache.cassandra.db.filter.RowFilter$CQLFilter$1IsSatisfiedFilter.applyToPartition(RowFilter.java:307) ~[main/:na]
      	at org.apache.cassandra.db.filter.RowFilter$CQLFilter$1IsSatisfiedFilter.applyToPartition(RowFilter.java:292) ~[main/:na]
      	at org.apache.cassandra.db.transform.BasePartitions.hasNext(BasePartitions.java:96) ~[main/:na]
      	at org.apache.cassandra.db.partitions.UnfilteredPartitionIterators$Serializer.serialize(UnfilteredPartitionIterators.java:310) ~[main/:na]
      	at org.apache.cassandra.db.ReadResponse$LocalDataResponse.build(ReadResponse.java:145) ~[main/:na]
      	at org.apache.cassandra.db.ReadResponse$LocalDataResponse.<init>(ReadResponse.java:138) ~[main/:na]
      	at org.apache.cassandra.db.ReadResponse$LocalDataResponse.<init>(ReadResponse.java:134) ~[main/:na]
      	at org.apache.cassandra.db.ReadResponse.createDataResponse(ReadResponse.java:76) ~[main/:na]
      	at org.apache.cassandra.db.ReadCommand.createResponse(ReadCommand.java:333) ~[main/:na]
      	at org.apache.cassandra.service.StorageProxy$LocalReadRunnable.runMayThrow(StorageProxy.java:1884) ~[main/:na]
      	at org.apache.cassandra.service.StorageProxy$DroppableRunnable.run(StorageProxy.java:2587) ~[main/:na]
      	... 5 common frames omitted
      

      2)
      Similarly, if an index is created on the duration column:

      CREATE INDEX d_index ON simplex.duration_table (d);
      SELECT * from duration_table WHERE d=1s;
      

      results in:

      WARN  [ReadStage-2] 2017-01-31 17:12:00,623 AbstractLocalAwareExecutorService.java:167 - Uncaught exception on thread Thread[ReadStage-2,10,main]: {}
      java.lang.RuntimeException: org.apache.cassandra.index.IndexNotAvailableException: The secondary index 'd_index' is not yet available
      	at org.apache.cassandra.service.StorageProxy$DroppableRunnable.run(StorageProxy.java:2591) ~[main/:na]
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_91]
      	at org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$FutureTask.run(AbstractLocalAwareExecutorService.java:162) ~[main/:na]
      	at org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$LocalSessionFutureTask.run(AbstractLocalAwareExecutorService.java:134) [main/:na]
      	at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:109) [main/:na]
      	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91]
      Caused by: org.apache.cassandra.index.IndexNotAvailableException: The secondary index 'd_index' is not yet available
      	at org.apache.cassandra.db.ReadCommand.executeLocally(ReadCommand.java:400) ~[main/:na]
      	at org.apache.cassandra.service.StorageProxy$LocalReadRunnable.runMayThrow(StorageProxy.java:1882) ~[main/:na]
      	at org.apache.cassandra.service.StorageProxy$DroppableRunnable.run(StorageProxy.java:2587) ~[main/:na]
      	... 5 common frames omitted
      

      3)
      Finally, no further updates can be made to the table once the index has been created. Attempting to modify or insert a new row with a non-null value for "d" results in an error:

      ERROR [MutationStage-2] 2017-01-31 17:13:33,106 StorageProxy.java:1422 - Failed to apply mutation locally : {}
      java.lang.RuntimeException: null for ks: simplex, table: duration_table.d_index for ks: simplex, table: duration_table
      	at org.apache.cassandra.db.ColumnFamilyStore.apply(ColumnFamilyStore.java:1334) ~[main/:na]
      	at org.apache.cassandra.db.Keyspace.applyInternal(Keyspace.java:618) ~[main/:na]
      	at org.apache.cassandra.db.Keyspace.apply(Keyspace.java:462) ~[main/:na]
      	at org.apache.cassandra.db.Mutation.apply(Mutation.java:227) ~[main/:na]
      	at org.apache.cassandra.db.Mutation.apply(Mutation.java:232) ~[main/:na]
      	at org.apache.cassandra.db.Mutation.apply(Mutation.java:241) ~[main/:na]
      	at org.apache.cassandra.service.StorageProxy$8.runMayThrow(StorageProxy.java:1416) ~[main/:na]
      	at org.apache.cassandra.service.StorageProxy$LocalMutationRunnable.run(StorageProxy.java:2640) [main/:na]
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_91]
      	at org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$FutureTask.run(AbstractLocalAwareExecutorService.java:162) [main/:na]
      	at org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$LocalSessionFutureTask.run(AbstractLocalAwareExecutorService.java:134) [main/:na]
      	at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:109) [main/:na]
      	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91]
      Caused by: java.lang.RuntimeException: null for ks: simplex, table: duration_table.d_index
      	at org.apache.cassandra.db.ColumnFamilyStore.apply(ColumnFamilyStore.java:1334) ~[main/:na]
      	at org.apache.cassandra.index.internal.CassandraIndex.insert(CassandraIndex.java:531) ~[main/:na]
      	at org.apache.cassandra.index.internal.CassandraIndex.access$100(CassandraIndex.java:72) ~[main/:na]
      	at org.apache.cassandra.index.internal.CassandraIndex$1.indexCell(CassandraIndex.java:444) ~[main/:na]
      	at org.apache.cassandra.index.internal.CassandraIndex$1.insertRow(CassandraIndex.java:388) ~[main/:na]
      	at org.apache.cassandra.index.SecondaryIndexManager$WriteTimeTransaction.onInserted(SecondaryIndexManager.java:914) ~[main/:na]
      	at org.apache.cassandra.db.partitions.AtomicBTreePartition$RowUpdater.apply(AtomicBTreePartition.java:333) ~[main/:na]
      	at org.apache.cassandra.db.partitions.AtomicBTreePartition$RowUpdater.apply(AtomicBTreePartition.java:295) ~[main/:na]
      	at org.apache.cassandra.utils.btree.BTree.buildInternal(BTree.java:139) ~[main/:na]
      	at org.apache.cassandra.utils.btree.BTree.build(BTree.java:121) ~[main/:na]
      	at org.apache.cassandra.utils.btree.BTree.update(BTree.java:178) ~[main/:na]
      	at org.apache.cassandra.db.partitions.AtomicBTreePartition.addAllWithSizeDelta(AtomicBTreePartition.java:156) ~[main/:na]
      	at org.apache.cassandra.db.Memtable.put(Memtable.java:284) ~[main/:na]
      	at org.apache.cassandra.db.ColumnFamilyStore.apply(ColumnFamilyStore.java:1316) ~[main/:na]
      	... 12 common frames omitted
      Caused by: java.lang.UnsupportedOperationException: null
      	at org.apache.cassandra.db.marshal.AbstractType.compareCustom(AbstractType.java:174) ~[main/:na]
      	at org.apache.cassandra.db.marshal.AbstractType.compare(AbstractType.java:160) ~[main/:na]
      	at org.apache.cassandra.dht.LocalPartitioner$LocalToken.compareTo(LocalPartitioner.java:156) ~[main/:na]
      	at org.apache.cassandra.dht.LocalPartitioner$LocalToken.compareTo(LocalPartitioner.java:132) ~[main/:na]
      	at org.apache.cassandra.db.DecoratedKey.compareTo(DecoratedKey.java:85) ~[main/:na]
      	at org.apache.cassandra.db.DecoratedKey.compareTo(DecoratedKey.java:39) ~[main/:na]
      	at java.util.concurrent.ConcurrentSkipListMap.cpr(ConcurrentSkipListMap.java:655) ~[na:1.8.0_91]
      	at java.util.concurrent.ConcurrentSkipListMap.findPredecessor(ConcurrentSkipListMap.java:682) ~[na:1.8.0_91]
      	at java.util.concurrent.ConcurrentSkipListMap.doGet(ConcurrentSkipListMap.java:781) ~[na:1.8.0_91]
      	at java.util.concurrent.ConcurrentSkipListMap.get(ConcurrentSkipListMap.java:1546) ~[na:1.8.0_91]
      	at org.apache.cassandra.db.Memtable.put(Memtable.java:264) ~[main/:na]
      	at org.apache.cassandra.db.ColumnFamilyStore.apply(ColumnFamilyStore.java:1316) ~[main/:na]
      	... 25 common frames omitted
      

      Similar errors/inconsistencies exist for materialized views.

      Attachments

        Issue Links

          Activity

            People

              blerer Benjamin Lerer
              kishkaru Kishan Karunaratne
              Benjamin Lerer
              Tom Hobbs
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: