You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Joshua McKenzie (JIRA)" <ji...@apache.org> on 2016/05/16 14:41:12 UTC

[jira] [Commented] (CASSANDRA-11803) Creating a materialized view on a table with "token" column breaks the cluster

    [ https://issues.apache.org/jira/browse/CASSANDRA-11803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15284661#comment-15284661 ] 

Joshua McKenzie commented on CASSANDRA-11803:
---------------------------------------------

Given that 'token' is a [reserved keyword|https://github.com/apache/cassandra/blob/trunk/src/antlr/Lexer.g#L164], we could validate on MV creation that we don't have any of those keywords in use as column names. Maybe in [CreateViewStatement.announceMigration|https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/cql3/statements/CreateViewStatement.java#L114], maybe in [Parser.g createMaterializedViewStatement|https://github.com/apache/cassandra/blob/trunk/src/antlr/Parser.g#L714-L732].

Alternatively, we could try to preserve the quoting so it doesn't blow up, but I'm personally of the opinion that it's best to avoid the rat's nest of nested escaping of strings. Would perhaps be inconsistent to reject on MV but not on base table however.

> Creating a materialized view on a table with "token" column breaks the cluster
> ------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-11803
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-11803
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL
>         Environment: Kernel:
> Linux 4.4.8-20.46.amzn1.x86_64
> Java:
> Java OpenJDK Runtime Environment (build 1.8.0_91-b14)
> OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
> Cassandra: 
> datastax-ddc-3.3.0-1.noarch
> datastax-ddc-tools-3.3.0-1.noarch
>            Reporter: Victor Trac
>             Fix For: 3.x
>
>
> On a new Cassandra cluster, if we create a table with a field called "token" (with quotes) and then create a materialized view that uses "token", the cluster breaks. A ServerError is returned, and no further nodetool operations on the sstables work. Restarting the Cassandra server will also fail. It seems like the entire cluster is hosed.
> We tried this on Cassandra 3.3 and 3.5. 
> Here's how to produce (on an new, empty cassandra 3.5 docker container):
> {code}
> [cqlsh 5.0.1 | Cassandra 3.5 | CQL spec 3.4.0 | Native protocol v4]
> Use HELP for help.
> cqlsh> CREATE KEYSPACE account WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
> cqlsh> CREATE TABLE account.session  (
>    ...   "token" blob,
>    ...   account_id uuid,
>    ...   PRIMARY KEY("token")
>    ... )WITH compaction={'class': 'LeveledCompactionStrategy'} AND
>    ...   compression={'sstable_compression': 'LZ4Compressor'};
> cqlsh> CREATE MATERIALIZED VIEW account.account_session AS
>    ...        SELECT account_id,"token" FROM account.session
>    ...        WHERE "token" IS NOT NULL and account_id IS NOT NULL
>    ...        PRIMARY KEY (account_id, "token");
> ServerError: <ErrorMessage code=0000 [Server error] message="java.lang.RuntimeException: java.util.concurrent.ExecutionException: org.apache.cassandra.exceptions.SyntaxException: line 1:25 no viable alternative at input 'FROM' (SELECT account_id, token [FROM]...)">
> cqlsh> drop table account.session;
> ServerError: <ErrorMessage code=0000 [Server error] message="java.lang.RuntimeException: java.util.concurrent.ExecutionException: org.apache.cassandra.exceptions.SyntaxException: line 1:25 no viable alternative at input 'FROM' (SELECT account_id, token [FROM]...)">
> {code}
> When any sstable*, nodetool, or when the Cassandra process is restarted, this is emitted on startup and Cassandra exits (copied from a server w/ data):
> {code}
> INFO  [main] 2016-05-12 23:25:30,074 ColumnFamilyStore.java:395 - Initializing system_schema.indexes
> DEBUG [SSTableBatchOpen:1] 2016-05-12 23:25:30,075 SSTableReader.java:480 - Opening /mnt/cassandra/data/system_schema/indexes-0feb57ac311f382fba6d9024d305702f/ma-4-big (91 bytes)
> ERROR [main] 2016-05-12 23:25:30,143 CassandraDaemon.java:697 - Exception encountered during startup
> org.apache.cassandra.exceptions.SyntaxException: line 1:59 no viable alternative at input 'FROM' (..., expire_at, last_used, token [FROM]...)
>         at org.apache.cassandra.cql3.ErrorCollector.throwFirstSyntaxError(ErrorCollector.java:101) ~[apache-cassandra-3.5.0.jar:3.5.0]
>         at org.apache.cassandra.cql3.CQLFragmentParser.parseAnyUnhandled(CQLFragmentParser.java:80) ~[apache-cassandra-3.5.0.jar:3.5.0]
>         at org.apache.cassandra.cql3.QueryProcessor.parseStatement(QueryProcessor.java:512) ~[apache-cassandra-3.5.0.jar:3.5.0]
>         at org.apache.cassandra.schema.SchemaKeyspace.fetchView(SchemaKeyspace.java:1128) ~[apache-cassandra-3.5.0.jar:3.5.0]
>         at org.apache.cassandra.schema.SchemaKeyspace.fetchViews(SchemaKeyspace.java:1092) ~[apache-cassandra-3.5.0.jar:3.5.0]
>         at org.apache.cassandra.schema.SchemaKeyspace.fetchKeyspace(SchemaKeyspace.java:903) ~[apache-cassandra-3.5.0.jar:3.5.0]
>         at org.apache.cassandra.schema.SchemaKeyspace.fetchKeyspacesWithout(SchemaKeyspace.java:879) ~[apache-cassandra-3.5.0.jar:3.5.0]
>         at org.apache.cassandra.schema.SchemaKeyspace.fetchNonSystemKeyspaces(SchemaKeyspace.java:867) ~[apache-cassandra-3.5.0.jar:3.5.0]
>         at org.apache.cassandra.config.Schema.loadFromDisk(Schema.java:134) ~[apache-cassandra-3.5.0.jar:3.5.0]
>         at org.apache.cassandra.config.Schema.loadFromDisk(Schema.java:124) ~[apache-cassandra-3.5.0.jar:3.5.0]
>         at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:229) [apache-cassandra-3.5.0.jar:3.5.0]
>         at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:551) [apache-cassandra-3.5.0.jar:3.5.0]
>         at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:680) [apache-cassandra-3.5.0.jar:3.5.0]
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)