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

Deleting columns breaks secondary index on clustering column

    XMLWordPrintableJSON

    Details

    • Severity:
      Critical
    • Since Version:

      Description

      Removing items from a set breaks index for field id:

      cqlsh:cs> CREATE TABLE buckets (
            ...   tenant int,
            ...   id int,
            ...   items set<text>,
            ...   PRIMARY KEY (tenant, id)
            ... );
      cqlsh:cs> CREATE INDEX buckets_ids ON buckets(id);
      cqlsh:cs> INSERT INTO buckets (tenant, id, items) VALUES (1, 1, {'foo', 'bar'});
      cqlsh:cs> SELECT * FROM buckets;
      
       tenant | id | items
      --------+----+----------------
            1 |  1 | {'bar', 'foo'}
      
      (1 rows)
      
      cqlsh:cs> SELECT * FROM buckets WHERE id = 1;
      
       tenant | id | items
      --------+----+----------------
            1 |  1 | {'bar', 'foo'}
      
      (1 rows)
      
      cqlsh:cs> UPDATE buckets SET items=items-{'foo'} WHERE tenant=1 AND id=1;
      cqlsh:cs> SELECT * FROM buckets;
      
       tenant | id | items
      --------+----+---------
            1 |  1 | {'bar'}
      
      (1 rows)
      
      cqlsh:cs> SELECT * FROM buckets WHERE id = 1;
      
      (0 rows)
      

      Re-building the index fixes the issue:

      cqlsh:cs> DROP INDEX buckets_ids;
      cqlsh:cs> CREATE INDEX buckets_ids ON buckets(id);
      cqlsh:cs> SELECT * FROM buckets WHERE id = 1;
      
       tenant | id | items
      --------+----+---------
            1 |  1 | {'bar'}
      
      (1 rows)
      

      Adding items does not cause similar failure, only delete. Also didn't test if other collections are also affected

        Attachments

        1. 8206-v2.txt
          6 kB
          Sylvain Lebresne
        2. 8206-WIP.txt
          3 kB
          Tyler Hobbs

          Issue Links

            Activity

              People

              • Assignee:
                slebresne Sylvain Lebresne
                Reporter:
                tuukka.mustonen Tuukka Mustonen
                Authors:
                Sylvain Lebresne
                Reviewers:
                Tyler Hobbs
                Tester:
                Philip Thompson
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: