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

Creating a SASI index after creating an SAI index breaks secondary index queries

    XMLWordPrintableJSON

Details

    Description

      In the 5.0 branch, HEAD is e45c1092f91edd63591f562b2120ea6a5fd3edd5, I was able to break secondary indexes by doing the following:

      cqlsh -e "create KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};"
      cqlsh -e "create table test.blah (id int primary key, val text);"
      cqlsh -e "create INDEX on test.blah (val) using 'sai';"
      
      bin/nodetool flush
      
      ❯ cqlsh -e "SELECT * from test.blah WHERE val = 'something';"
      
       id | val
      ----+-----
      
      (0 rows)
      
      cqlsh -e "create custom INDEX on test.blah (val) using 'org.apache.cassandra.index.sasi.SASIIndex';"
      
      Warnings :
      SASI indexes are experimental and are not recommended for production use.
      
      cqlsh -e "SELECT * from test.blah WHERE val = 'something';"
      <stdin>:1:ReadFailure: Error from server: code=1300 [Replica(s) failed to execute read] message="Operation failed - received 0 responses and 1 failures: UNKNOWN from localhost/127.0.0.1:7000" info={'consistency': 'ONE', 'required_responses': 1, 'received_responses': 0, 'failures': 1, 'error_code_map': {'127.0.0.1': '0x0000'}}
      

      Server throws an exception:

      ERROR [ReadStage-2] 2023-10-18 12:09:42,391 JVMStabilityInspector.java:70 - Exception in thread Thread[ReadStage-2,10,SharedPool]
      java.lang.RuntimeException: java.lang.ClassCastException: class org.apache.cassandra.index.sai.StorageAttachedIndex cannot be cast to class org.apache.cassandra.index.sasi.SASIIndex (org.apache.cassandra.index.sai.StorageAttachedIndex and org.apache.cassandra.index.sasi.SASIIndex are in unnamed module of loader 'app')
      	at org.apache.cassandra.service.StorageProxy$DroppableRunnable.run(StorageProxy.java:2585)
      	at org.apache.cassandra.concurrent.ExecutionFailure$2.run(ExecutionFailure.java:163)
      	at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:143)
      	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
      	at java.base/java.lang.Thread.run(Thread.java:829)
      Caused by: java.lang.ClassCastException: class org.apache.cassandra.index.sai.StorageAttachedIndex cannot be cast to class org.apache.cassandra.index.sasi.SASIIndex (org.apache.cassandra.index.sai.StorageAttachedIndex and org.apache.cassandra.index.sasi.SASIIndex are in unnamed module of loader 'app')
      	at org.apache.cassandra.index.sasi.plan.QueryController.getIndex(QueryController.java:96)
      	at org.apache.cassandra.index.sasi.plan.Operation.analyzeGroup(Operation.java:282)
      	at org.apache.cassandra.index.sasi.plan.Operation$Builder.complete(Operation.java:433)
      	at org.apache.cassandra.index.sasi.plan.SASIIndexSearcher.analyze(SASIIndexSearcher.java:65)
      	at org.apache.cassandra.index.sasi.plan.SASIIndexSearcher.search(SASIIndexSearcher.java:77)
      	at org.apache.cassandra.db.ReadCommand.executeLocally(ReadCommand.java:425)
      	at org.apache.cassandra.service.StorageProxy$LocalReadRunnable.runMayThrow(StorageProxy.java:2184)
      	at org.apache.cassandra.service
      

      Dropping the SASI index restores correct behavior.

      Attachments

        Activity

          People

            smiklosovic Stefan Miklosovic
            rustyrazorblade Jon Haddad
            Stefan Miklosovic
            Andres de la Peña, Caleb Rackliffe, Stefan Miklosovic
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 20m
                1h 20m