Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 605AB1763A for ; Wed, 29 Oct 2014 23:31:34 +0000 (UTC) Received: (qmail 23263 invoked by uid 500); 29 Oct 2014 23:31:34 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 23226 invoked by uid 500); 29 Oct 2014 23:31:34 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 23213 invoked by uid 99); 29 Oct 2014 23:31:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Oct 2014 23:31:34 +0000 Date: Wed, 29 Oct 2014 23:31:34 +0000 (UTC) From: "Tyler Hobbs (JIRA)" To: commits@cassandra.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CASSANDRA-8206) Deleting columns breaks secondary index on clustering column MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CASSANDRA-8206?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Tyler Hobbs updated CASSANDRA-8206: ----------------------------------- Attachment: 8206-WIP.txt So, the root of the issue is that {{CompositesIndexOnClusteringKey}} returns {{true}} for any column name in {{indexes()}}. Any time an individual column is deleted, {{delete()}} gets called and the index entry for the whole row is deleted. I've attached a WIP patch that overrides {{delete()}} in {{CompositesIndexOnClusteringKey}} to make it do nothing, since the row should only be removed from the index when the full row is deleted. However, I'm not at all familiar with the other ways that the secondary index is updated, so I believe there's more work to be done (or maybe a better approach). Additionally, we definitely need some test coverage around deletions for secondary indexes on partition keys and clustering keys. There are a couple of dtests that could be expanded (clustering_index_test, edge_2i_on_complex_pk_test). [~slebresne] or [~beobal], would one of you two like to take over this ticket? > 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 > > > Removing items from a set breaks index for field {{id}}: > {noformat} > cqlsh:cs> CREATE TABLE buckets ( > ... tenant int, > ... id int, > ... items set, > ... 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)