Jeff Jirsa created CASSANDRA-10503:
--------------------------------------

             Summary: NPE in MVs
                 Key: CASSANDRA-10503
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-10503
             Project: Cassandra
          Issue Type: Bug
            Reporter: Jeff Jirsa
            Priority: Critical


While working on a wildly unrelated feature, I've stumbled upon an NPE in MVs. 
This script will reproduce 100% on trunk from {{Date:   Sat Oct 10 09:23:15 
2015 +0100}}

{code}
ERROR [SharedPool-Worker-3] 2015-10-10 21:35:01,867 Keyspace.java:487 - Unknown 
exception caught while attempting to update MaterializedView! 
test.test_with_cluster
java.lang.NullPointerException: null
        at 
org.apache.cassandra.db.view.TemporalRow.clusteringValue(TemporalRow.java:381) 
~[main/:na]
        at 
org.apache.cassandra.db.view.View.createUpdatesForInserts(View.java:355) 
~[main/:na]
        at org.apache.cassandra.db.view.View.createMutations(View.java:664) 
~[main/:na]
        at 
org.apache.cassandra.db.view.ViewManager.pushViewReplicaUpdates(ViewManager.java:130)
 ~[main/:na]
        at org.apache.cassandra.db.Keyspace.apply(Keyspace.java:482) [main/:na]
        at org.apache.cassandra.db.Keyspace.apply(Keyspace.java:387) [main/:na]
        at org.apache.cassandra.db.Mutation.apply(Mutation.java:205) [main/:na]
        at 
org.apache.cassandra.service.StorageProxy$$Lambda$149/1333013217.run(Unknown 
Source) [main/:na]
        at 
org.apache.cassandra.service.StorageProxy$7.runMayThrow(StorageProxy.java:1247) 
[main/:na]
        at 
org.apache.cassandra.service.StorageProxy$LocalMutationRunnable.run(StorageProxy.java:2399)
 [main/:na]
        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)
 [main/:na]
        at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:105) 
[main/:na]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
{code}

And the script to trigger:

{code}
ccm remove test; 
ccm create test --install-dir=/Users/jeff/Desktop/Dev/cassandra/ -s -n 1 ; 
echo "create keyspace test WITH replication = {'class': 'SimpleStrategy', 
'replication_factor': 1}; use test; create table test ( id text primary key, 
last text, first text, high int, low int); insert into 
test(id,last,first,high,low) values ('a', 'a', 'a', 1, 1); insert into 
test(id,last,first,high,low) values ('a', 'b', 'b', 2, 2); insert into 
test(id,last,first,high,low) values ('a', 'c', 'c', 3, 3); insert into 
test(id,last,first,high,low) values ('a', 'e', 'e', 5, 5); insert into 
test(id,last,first,high,low) values ('a', 'd', 'd', 4, 4); select * from test 
where id='a';" | ccm node1 cqlsh

echo "Creating MV test_by_high on test"
echo "use test; create materialized view test_by_high as select id, high from 
test where high is not null primary key(high, id);" | ccm node1 cqlsh

echo "Insert high score 6"
echo "use test; insert into test(id,last,first,high,low) values ('a', 'f', 'f', 
6, 6); " | ccm node1 cqlsh 

sleep 1

echo "Select from MV where score = 6"
echo "use test; select * from test_by_high where high=6; " | ccm node1 cqlsh

echo "Create a larger table with clustering key"
echo "use test; create table test_with_cluster(part text, clus text, last text, 
first text, high int, low int, primary key (part, clus));" | ccm node1 cqlsh

echo "use test; create materialized view high_view as select part, clus, high 
from test_with_cluster where part is not null and clus is not null and high is 
not null primary key(high, part, clus);" | ccm node1 cqlsh

echo "Populate test_with_cluster, this will break"
echo "use test; insert into test_with_cluster(part, clus,last,first,high,low) 
values ('a', 'a', 'a', 'a', 1, 1); " | ccm node1 cqlsh
{code}




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

Reply via email to