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

Unexpected NullPointerException in ANN+WHERE when adding rows in another partition

    XMLWordPrintableJSON

Details

    Description

      • Bug observed on the Docker image 5.0-beta1
      • Bug also observed on latest head of Cassandra repo (as of 2024-02-15)
      • (working fine on vsearch branch of datastax/cassandra, commit hash 80c2f8b9ad5b89efee0645977a5ca53943717c0d)

      Summary: A query with ann + where clause on a map + where clause on the partition key starts erroring once there are other partitions in the table.

      There are three SELECT statements in the repro minimal code below - the third is where the error is triggered.

      // reproduced with Dockerized Cassandra 5.0-beta1 on 2024-02-15
      
      /////////
      // SCHEMA
      /////////
      
      CREATE TABLE ks.v_table (
          pk int,
          row_v vector<float, 2>,
          metadata map<text, text>,
          PRIMARY KEY (pk)
      );
      CREATE CUSTOM INDEX v_md
          ON ks.v_table (entries(metadata))
          USING 'StorageAttachedIndex';
      CREATE CUSTOM INDEX v_idx
          ON ks.v_table (row_v)
          USING 'StorageAttachedIndex';
      
      
      /////////////////////////////
      // SELECT WORKS (empty table)
      /////////////////////////////
      
      SELECT * FROM ks.v_table
          WHERE metadata['map_k'] = 'map_v'
              AND pk = 0
          ORDER BY row_v ANN OF [0.1, 0.2]
          LIMIT 4;
      
      
      //////////////
      // ADD ONE ROW
      //////////////
      
      INSERT INTO ks.v_table (pk, metadata, row_v)
      VALUES
          (0, {'map_k': 'map_v'}, [0.11, 0.19]);
      
      
      
      /////////////////////////////////////////////
      // SELECT WORKS (table has queried partition)
      /////////////////////////////////////////////
      
      SELECT * FROM ks.v_table
          WHERE metadata['map_k'] = 'map_v'
              AND pk = 0
          ORDER BY row_v ANN OF [0.1, 0.2]
          LIMIT 4;
      
      
      //////////////////////////////////
      // ADD ONE ROW (another partition)
      //////////////////////////////////
      
      INSERT INTO ks.v_table (pk, metadata, row_v)
      VALUES
          (10, {'map_k': 'map_v'}, [0.11, 0.19]);
      
      
      /////////////////////////////////////////////////
      // SELECT BREAKS (table gained another partition)
      /////////////////////////////////////////////////
      
      SELECT * FROM ks.v_table
          WHERE metadata['map_k'] = 'map_v'
              AND pk = 0
          ORDER BY row_v ANN OF [0.1, 0.2]
          LIMIT 4; 

      The error has this appearance in CQL Console:

      ReadFailure: Error from server: code=1300 [Replica(s) failed to execute read] message="Operation failed - received 0 responses and 1 failures: UNKNOWN from /172.17.0.2:7000" info={'consistency': 'ONE', 'required_responses': 1, 'received_responses': 0, 'failures': 1, 'error_code_map': {'172.17.0.2': '0x0000'}} 

      And the Cassandra logs have this to say:

      java.lang.NullPointerException: Cannot invoke "org.apache.cassandra.index.sai.iterators.KeyRangeIterator.skipTo(org.apache.cassandra.index.sai.utils.PrimaryKey)" because "this.nextIterator" is null 

       

      Attachments

        Issue Links

          Activity

            People

              e.dimitrova Ekaterina Dimitrova
              stefano_lottini Stefano Lottini
              Ekaterina Dimitrova
              Andres de la Peña
              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 - 50m
                  50m