[
https://issues.apache.org/jira/browse/CASSANDRA-8206?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sylvain Lebresne updated CASSANDRA-8206:
----------------------------------------
Attachment: 8206-v2.txt
We indeed should not delete index entry unless the whole CQL row is deleted,
which means we don't really have a good way to do it on update but that's ok
since we'll rely on the index entry being removed on read (which is already
what we do for any range/partition level deletion). So making {{delete}} be a
no-op for {{CompositesIndexOnClusteringKey}} and
{{CompositesIndexOnPartitionKey}} is imo the right fix. One special case though
is {{SecondaryIndexManager.deleteFromIndexes}}: we call that only on cleanup
when we know the whole partition has been deleted, so it's ok to clean the
index in that case. So I've added a new {{deleteForCleanup}} method which is
called in that case.
I've pushed a
[dtest|https://github.com/riptano/cassandra-dtest/commit/c98340d1291395df6c97fa36e9c7bcf914d84451]
for this too.
> Deleting columns breaks secondary index on clustering column
> ------------------------------------------------------------
>
> Key: CASSANDRA-8206
> URL: https://issues.apache.org/jira/browse/CASSANDRA-8206
> Project: Cassandra
> Issue Type: Bug
> Components: Core
> Reporter: Tuukka Mustonen
> Assignee: Tyler Hobbs
> Priority: Critical
> Fix For: 2.0.12, 2.1.2
>
> Attachments: 8206-WIP.txt, 8206-v2.txt
>
>
> Removing items from a set breaks index for field {{id}}:
> {noformat}
> 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)
> {noformat}
> Re-building the index fixes the issue:
> {noformat}
> 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)
> {noformat}
> Adding items does not cause similar failure, only delete. Also didn't test if
> other collections are also affected(?)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)