Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to drop keyspace or table if there are active secondary indexes #3202

Closed
penberg opened this issue Feb 11, 2018 · 1 comment
Closed
Assignees
Milestone

Comments

@penberg
Copy link
Contributor

penberg commented Feb 11, 2018

Installation details
Scylla version (or git commit hash): 2.1-rc3

Apache Cassandra lets users run DROP KEYSPACE and DROP TABLE even if there are secondary indexes but Scylla trips over materialized views validation (that SI uses under the hood) and refuses that.

@slivne slivne added this to the 2.3 milestone Feb 18, 2018
psarna added a commit to psarna/scylla that referenced this issue May 22, 2018
Previously dropping a table with secondary indexes failed, because
SI are internally backed by materialized views.
This commit triggers dropping dependent secondary indexes before
dropping a table.

Fixes scylladb#3202
psarna added a commit to psarna/scylla that referenced this issue May 22, 2018
Previously dropping a table with secondary indexes failed, because
SI are internally backed by materialized views.
This commit triggers dropping dependent secondary indexes before
dropping a table.

Fixes scylladb#3202
psarna added a commit to psarna/scylla that referenced this issue May 22, 2018
This commit adds a test case for dropping a table with dependent
secondary indexes. Dependent materialized views prohibit the table
from being dropped, but dropping a table with dependent SI is legal.

References scylladb#3202
psarna added a commit to psarna/scylla that referenced this issue May 22, 2018
This commit adds a test case for dropping a table with dependent
secondary indexes. Dependent materialized views prohibit the table
from being dropped, but dropping a table with dependent SI is legal.

References scylladb#3202
@psarna
Copy link
Contributor

psarna commented May 22, 2018

There are two separate issues here, I think they should be split.

  1. Dropping a table with secondary indexes - I'll send a patch series for that soon. The issue is that dropping a table should be allowed even if it has secondary indexes.

  2. Dropping a keyspace with any materialized views present, not just secondary indexes.
    Here's a reproduction:

CREATE KEYSPACE demodb WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
use demodb;
CREATE TABLE tbl (a int, b int, c float, PRIMARY KEY (a));
CREATE MATERIALIZED VIEW tbl_view AS SELECT c FROM tbl WHERE c IS NOT NULL PRIMARY KEY (c, a);

cqlsh:demodb> drop keyspace demodb;
ServerError: Can't find a column family with UUID 75728b10-5da8-11e8-9297-000000000000
cqlsh:demodb> drop keyspace demodb;

If any materialized views are present, first attempt to drop this keyspace will fail with ServerError: Can't find a column family with UUID. Still, all tables and views are dropped from it and the second attempt succeeds without any problems. I think it should be moved to a separate issue, it's not directly related to secondary indexes.

psarna added a commit to psarna/scylla that referenced this issue May 22, 2018
This commit makes truncate_views() function acknowledge the case
when some materialized view tables were already removed.
It may happen when 'DROP KEYSPACE' is called on a keyspace
with any materialized views present and also if 'DROP TABLE'
with any secondary indexes is called.

References scylladb#3202
psarna added a commit to psarna/scylla that referenced this issue May 22, 2018
Previously dropping a table with secondary indexes failed, because
SI are internally backed by materialized views.
This commit triggers dropping dependent secondary indexes before
dropping a table.

Fixes scylladb#3202
psarna added a commit to psarna/scylla that referenced this issue May 22, 2018
This commit adds a test case for dropping a table with dependent
secondary indexes. Dependent materialized views prohibit the table
from being dropped, but dropping a table with dependent SI is legal.

References scylladb#3202
psarna added a commit to psarna/scylla that referenced this issue May 22, 2018
This commit adds a test case for dropping a table with dependent
secondary indexes. Dependent materialized views prohibit the table
from being dropped, but dropping a table with dependent SI is legal.

References scylladb#3202
psarna added a commit to psarna/scylla that referenced this issue May 22, 2018
This commit clears table's views before truncating it
in drop_column_family function. The only case when
views are not empty during drop is when they're backing secondary
indexes of a base table and they are all atomically dropped
in the same go as the base table itself.
This change will prevent trying to truncate views that were
already dropped, which used to result in no_such_column_family error.

References scylladb#3202
psarna added a commit to psarna/scylla that referenced this issue May 22, 2018
This commit adds a test case for dropping a table with dependent
secondary indexes. Dependent materialized views prohibit the table
from being dropped, but dropping a table with dependent SI is legal.

References scylladb#3202
duarten added a commit that referenced this issue May 22, 2018
"
This series addresses issue #3202 about dropping a table with secondary
indexes present. Previously dropping such tables was impossible due to
materialized view restrictions (which is an implementation detail
of Scylla's secondary indexes).

Implemented:
 * fixing 'DROP KEYSPACE' with active materialized views
 * adapting schema_builder to make it easy to drop indexes
 * dropping all dependent SI before dropping a table
 * a test case for dropping a table with secondary indexes
"

* 'drop_si_before_drop_table_3' of https://github.com/psarna/scylla:
  tests: add test for dropping a table with secondary indexes
  migration_manager: allow dropping table with secondary indexes
  schema: add clearing indexes to schema builder
  database: do not truncate already removed views
nyh pushed a commit to nyh/scylla that referenced this issue May 27, 2018
This commit clears table's views before truncating it
in drop_column_family function. The only case when
views are not empty during drop is when they're backing secondary
indexes of a base table and they are all atomically dropped
in the same go as the base table itself.
This change will prevent trying to truncate views that were
already dropped, which used to result in no_such_column_family error.

References scylladb#3202

(cherry picked from commit f8237dd)
nyh pushed a commit to nyh/scylla that referenced this issue May 27, 2018
Previously dropping a table with secondary indexes failed, because
SI are internally backed by materialized views.
This commit triggers dropping dependent secondary indexes before
dropping a table.

Fixes scylladb#3202

(cherry picked from commit 7e4813a)
nyh pushed a commit to nyh/scylla that referenced this issue May 27, 2018
This commit adds a test case for dropping a table with dependent
secondary indexes. Dependent materialized views prohibit the table
from being dropped, but dropping a table with dependent SI is legal.

References scylladb#3202

(cherry picked from commit 76848fb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants