cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sylvain Lebresne (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CASSANDRA-11069) Materialised views require all collections to be selected.
Date Fri, 05 Feb 2016 16:35:40 GMT

     [ https://issues.apache.org/jira/browse/CASSANDRA-11069?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sylvain Lebresne updated CASSANDRA-11069:
-----------------------------------------
    Assignee: Carl Yeksigian

> Materialised views require all collections to be selected.
> ----------------------------------------------------------
>
>                 Key: CASSANDRA-11069
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-11069
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Vassil Lunchev
>            Assignee: Carl Yeksigian
>              Labels: materializedviews
>
> Running Cassandra 3.0.2
> Using the official example from: 
> http://www.datastax.com/dev/blog/new-in-cassandra-3-0-materialized-views
> The only difference is that I have added a map column to the base table.
> {code}
> CREATE TABLE scores
> (
>   user TEXT,
>   game TEXT,
>   year INT,
>   month INT,
>   day INT,
>   score INT,
>   a_map map<int, text>,
>   PRIMARY KEY (user, game, year, month, day)
> );
> CREATE MATERIALIZED VIEW alltimehigh AS
>        SELECT user FROM scores
>        WHERE game IS NOT NULL AND score IS NOT NULL AND user IS NOT NULL AND year IS
NOT NULL AND month IS NOT NULL AND day IS NOT NULL
>        PRIMARY KEY (game, score, user, year, month, day)
>        WITH CLUSTERING ORDER BY (score desc);
> INSERT INTO scores (user, game, year, month, day, score) VALUES ('pcmanus', 'Coup', 2015,
06, 02, 2000);
> SELECT * FROM scores;
> SELECT * FROM alltimehigh;
> {code}
> All of the above works perfectly fine. Until you insert a row where the 'a_map' column
is not null.
> {code}
> INSERT INTO scores (user, game, year, month, day, score, a_map) VALUES ('pcmanus_2',
'Coup', 2015, 06, 02, 2000, {1: 'text'});
> {code}
> This results in:
> {code}
> Traceback (most recent call last):
>   File "/Users/vassil/apache-cassandra-3.0.2/bin/cqlsh.py", line 1258, in perform_simple_statement
>     result = future.result()
>   File "/Users/vassil/apache-cassandra-3.0.2/bin/../lib/cassandra-driver-internal-only-3.0.0-6af642d.zip/cassandra-driver-3.0.0-6af642d/cassandra/cluster.py",
line 3122, in result
>     raise self._final_exception
> WriteFailure: code=1500 [Replica(s) failed to execute write] message="Operation failed
- received 0 responses and 1 failures" info={'failures': 1, 'received_responses': 0, 'required_responses':
1, 'consistency': 'ONE'}
> {code}
> Selecting the base table and the materialised view is also interesting:
> {code}
> SELECT * FROM scores;
> SELECT * FROM alltimehigh;
> {code}
> The result is:
> {code}
> cqlsh:tests> SELECT * FROM scores;
>  user    | game | year | month | day | a_map | score
> ---------+------+------+-------+-----+-------+-------
>  pcmanus | Coup | 2015 |     6 |   2 |  null |  2000
> (1 rows)
> cqlsh:tests> SELECT * FROM alltimehigh;
>  game | score | user      | year | month | day
> ------+-------+-----------+------+-------+-----
>  Coup |  2000 |   pcmanus | 2015 |     6 |   2
>  Coup |  2000 | pcmanus_2 | 2015 |     6 |   2
> (2 rows)
> {code}
> In the logs you can see:
> {code:java}
> ERROR [SharedPool-Worker-2] 2016-01-26 03:25:27,456 Keyspace.java:484 - Unknown exception
caught while attempting to update MaterializedView! tests.scores
> java.lang.IllegalStateException: [ColumnDefinition{name=a_map, type=org.apache.cassandra.db.marshal.MapType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type),
kind=REGULAR, position=-1}] is not a subset of []
> 	at org.apache.cassandra.db.Columns$Serializer.encodeBitmap(Columns.java:531) ~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Columns$Serializer.serializedSubsetSize(Columns.java:483)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.rows.UnfilteredSerializer.serializedRowBodySize(UnfilteredSerializer.java:275)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.rows.UnfilteredSerializer.serializedSize(UnfilteredSerializer.java:247)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.rows.UnfilteredSerializer.serializedSize(UnfilteredSerializer.java:234)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.rows.UnfilteredSerializer.serializedSize(UnfilteredSerializer.java:227)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.rows.UnfilteredRowIteratorSerializer.serializedSize(UnfilteredRowIteratorSerializer.java:169)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.partitions.PartitionUpdate$PartitionUpdateSerializer.serializedSize(PartitionUpdate.java:683)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Mutation$MutationSerializer.serializedSize(Mutation.java:354)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.commitlog.CommitLog.add(CommitLog.java:259) ~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Keyspace.apply(Keyspace.java:461) [apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Keyspace.apply(Keyspace.java:384) [apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Mutation.apply(Mutation.java:210) [apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.service.StorageProxy.mutateMV(StorageProxy.java:703) ~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.view.ViewManager.pushViewReplicaUpdates(ViewManager.java:149)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Keyspace.apply(Keyspace.java:479) [apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Keyspace.apply(Keyspace.java:384) [apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Mutation.apply(Mutation.java:205) [apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.service.StorageProxy$$Lambda$159/501076283.run(Unknown Source)
[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.service.StorageProxy$7.runMayThrow(StorageProxy.java:1275) [apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.service.StorageProxy$LocalMutationRunnable.run(StorageProxy.java:2412)
[apache-cassandra-3.0.2.jar:3.0.2]
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_45]
> 	at org.apache.cassandra.concurrent.AbstractTracingAwareExecutorService$FutureTask.run(AbstractTracingAwareExecutorService.java:164)
[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:105) [apache-cassandra-3.0.2.jar:3.0.2]
> 	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
> ERROR [SharedPool-Worker-2] 2016-01-26 03:25:27,457 StorageProxy.java:1281 - Failed to
apply mutation locally : {}
> java.lang.IllegalStateException: [ColumnDefinition{name=a_map, type=org.apache.cassandra.db.marshal.MapType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type),
kind=REGULAR, position=-1}] is not a subset of []
> 	at org.apache.cassandra.db.Columns$Serializer.encodeBitmap(Columns.java:531) ~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Columns$Serializer.serializedSubsetSize(Columns.java:483)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.rows.UnfilteredSerializer.serializedRowBodySize(UnfilteredSerializer.java:275)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.rows.UnfilteredSerializer.serializedSize(UnfilteredSerializer.java:247)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.rows.UnfilteredSerializer.serializedSize(UnfilteredSerializer.java:234)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.rows.UnfilteredSerializer.serializedSize(UnfilteredSerializer.java:227)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.rows.UnfilteredRowIteratorSerializer.serializedSize(UnfilteredRowIteratorSerializer.java:169)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.partitions.PartitionUpdate$PartitionUpdateSerializer.serializedSize(PartitionUpdate.java:683)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Mutation$MutationSerializer.serializedSize(Mutation.java:354)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.commitlog.CommitLog.add(CommitLog.java:259) ~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Keyspace.apply(Keyspace.java:461) ~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Keyspace.apply(Keyspace.java:384) ~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Mutation.apply(Mutation.java:210) ~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.service.StorageProxy.mutateMV(StorageProxy.java:703) ~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.view.ViewManager.pushViewReplicaUpdates(ViewManager.java:149)
~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Keyspace.apply(Keyspace.java:479) ~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Keyspace.apply(Keyspace.java:384) ~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.db.Mutation.apply(Mutation.java:205) ~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.service.StorageProxy$$Lambda$159/501076283.run(Unknown Source)
~[na:na]
> 	at org.apache.cassandra.service.StorageProxy$7.runMayThrow(StorageProxy.java:1275) ~[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.service.StorageProxy$LocalMutationRunnable.run(StorageProxy.java:2412)
[apache-cassandra-3.0.2.jar:3.0.2]
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_45]
> 	at org.apache.cassandra.concurrent.AbstractTracingAwareExecutorService$FutureTask.run(AbstractTracingAwareExecutorService.java:164)
[apache-cassandra-3.0.2.jar:3.0.2]
> 	at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:105) [apache-cassandra-3.0.2.jar:3.0.2]
> 	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
> {code}
> As the logs say, ColumnDefinition 'a_map' is not a subset of [] (which is all non-primary
key columns of the materialised view. There are no such column in this example).
> And if you drop this materialised view and create a new one where the 'a_map' is being
selected, it all works.
> {code}
> cqlsh:tests> drop MATERIALIZED VIEW alltimehigh ;
> cqlsh:tests> CREATE MATERIALIZED VIEW alltimehigh AS
>          ...        SELECT user, a_map FROM scores
>          ...        WHERE game IS NOT NULL AND score IS NOT NULL AND user IS NOT NULL
AND year IS NOT NULL AND month IS NOT NULL AND day IS NOT NULL
>          ...        PRIMARY KEY (game, score, user, year, month, day)
>          ...        WITH CLUSTERING ORDER BY (score desc);
> cqlsh:tests> INSERT INTO scores (user, game, year, month, day, score, a_map) VALUES
('pcmanus_2', 'Coup', 2015, 06, 02, 2000, {1: 'text'});
> cqlsh:tests> SELECT * FROM scores;
>  user      | game | year | month | day | a_map       | score
> -----------+------+------+-------+-----+-------------+-------
>    pcmanus | Coup | 2015 |     6 |   2 |        null |  2000
>  pcmanus_2 | Coup | 2015 |     6 |   2 | {1: 'text'} |  2000
> (2 rows)
> cqlsh:tests> SELECT * FROM alltimehigh;
>  game | score | user      | year | month | day | a_map
> ------+-------+-----------+------+-------+-----+-------------
>  Coup |  2000 |   pcmanus | 2015 |     6 |   2 |        null
>  Coup |  2000 | pcmanus_2 | 2015 |     6 |   2 | {1: 'text'}
> (2 rows)
> {code}
> Is this a documented limitation or a bug? I was trying to find a documentation that says
"all collection columns must be selected in a materialised view", but I could not find such
a thing. I tested it with sets in addition to maps and it is pretty much the same.



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

Mime
View raw message