[ https://issues.apache.org/jira/browse/CASSANDRA-13346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15985783#comment-15985783 ]
Lerh Chuan Low edited comment on CASSANDRA-13346 at 4/27/17 12:13 AM: ---------------------------------------------------------------------- This is quite easily reproduced, we just have to create a materialized view and try to drop keyspace. {code} CREATE KEYSPACE mvtest WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor': 1 }; CREATE TABLE mvtest.tobedropped ( foo int, bar text, baz text, PRIMARY KEY (foo, bar) ); CREATE MATERIALIZED VIEW mvtest.explosion AS SELECT foo, bar, baz FROM mvtest.tobedropped WHERE foo IS NOT NULL AND bar IS NOT NULL AND baz IS NOT NULL PRIMARY KEY (foo, bar, baz); INSERT INTO mvtest.tobedropped (foo, bar, baz) VALUES (1, 'baz', 'bokusapp'); INSERT INTO mvtest.tobedropped (foo, bar, baz) VALUES (2, 'baz', 'vitamin'); INSERT INTO mvtest.tobedropped (foo, bar, baz) VALUES (2, 'backgammon', 'gin'); DROP KEYSPACE mvtest; {code} As [~Andrew Efimov] mentioned, this seems to be because {{ViewLockReadTime}} and {{ViewLockAcquireTime}} are both set to null for materialized views (they don't make sense for materialized views and was decided to be that way based on [CASSANDRA-10323|https://issues.apache.org/jira/browse/CASSANDRA-10323]). So the call to {{Metrics.getMetrics().get(name.getMetricName())}} returns null, which throws the Exception as the {{remove}} method does not allow {{null}} values (For the implementation of the set in {{allTableMetrics}}. I've attached a patch for both 3.0.X and 3.X since it's a relatively small change - it looks like it's just a case of trying to unregister a metric from the registry that doesn't exist so we should just ignore it when it's `null` (which is only when it's releasing view metrics). I've retested it on my local and it works...Any feedbacks are welcome! ([~carlyeks]...?), or guidance on writing tests if necessary (It doesn't seem like there are any metrics tests though there are metrics dtests, I'll try taking a look at dtests). was (Author: lerh low): This is quite easily reproduced, we just have to create a materialized view and try to drop keyspace. {code} CREATE KEYSPACE mvtest WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor': 1 }; CREATE TABLE mvtest.tobedropped ( foo int, bar text, baz text, PRIMARY KEY (foo, bar) ); CREATE MATERIALIZED VIEW mvtest.explosion AS SELECT foo, bar, baz FROM mvtest.tobedropped WHERE foo IS NOT NULL AND bar IS NOT NULL AND baz IS NOT NULL PRIMARY KEY (foo, bar, baz); INSERT INTO mvtest.tobedropped (foo, bar, baz) VALUES (1, 'baz', 'bokusapp'); INSERT INTO mvtest.tobedropped (foo, bar, baz) VALUES (2, 'baz', 'vitamin'); INSERT INTO mvtest.tobedropped (foo, bar, baz) VALUES (2, 'backgammon', 'gin'); DROP KEYSPACE mvtest; {code} As [~Andrew Efimov] mentioned, this seems to be because `ViewLockReadTime` and `ViewLockAcquireTime` are both set to null for materialized views (they don't make sense for materialized views and was decided to be that way based on https://issues.apache.org/jira/browse/CASSANDRA-10323). So the call to `Metrics.getMetrics().get(name.getMetricName())` returns null, which throws the Exception as the `remove` method does not allow `null` values (For the implementation of the set in `allTableMetrics`. I've attached a patch for both 3.0.X and 3.X since it's a relatively small change - it looks like it's just a case of trying to unregister a metric from the registry that doesn't exist so we should just ignore it when it's `null` (which is only when it's releasing view metrics). I've retested it on my local and it works...Any feedbacks are welcome! ([~carlyeks]...?), or guidance on writing tests if necessary (It doesn't seem like there are any metrics tests though there are metrics dtests, I'll try taking a look at dtests). > Failed unregistering mbean during drop keyspace > ----------------------------------------------- > > Key: CASSANDRA-13346 > URL: https://issues.apache.org/jira/browse/CASSANDRA-13346 > Project: Cassandra > Issue Type: Bug > Components: Materialized Views > Environment: Cassandra 3.9 > Reporter: Gábor Auth > Priority: Minor > Labels: lhf > Fix For: 3.0.x, 3.11.x > > Attachments: 13346-3.0.X.txt, 13346-3.X.txt > > > All node throw exceptions about materialized views during drop keyspace: > {code} > WARN [MigrationStage:1] 2017-03-16 16:54:25,016 ColumnFamilyStore.java:535 - > Failed unregistering mbean: > org.apache.cassandra.db:type=Tables,keyspace=test20160810,table=unit_by_account > java.lang.NullPointerException: null > at > java.util.concurrent.ConcurrentHashMap.replaceNode(ConcurrentHashMap.java:1106) > ~[na:1.8.0_121] > at > java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1097) > ~[na:1.8.0_121] > at > java.util.concurrent.ConcurrentHashMap$KeySetView.remove(ConcurrentHashMap.java:4569) > ~[na:1.8.0_121] > at > org.apache.cassandra.metrics.TableMetrics.release(TableMetrics.java:712) > ~[apache-cassandra-3.9.0.jar:3.9.0] > at > org.apache.cassandra.db.ColumnFamilyStore.unregisterMBean(ColumnFamilyStore.java:570) > [apache-cassandra-3.9.0.jar:3.9.0] > at > org.apache.cassandra.db.ColumnFamilyStore.invalidate(ColumnFamilyStore.java:527) > [apache-cassandra-3.9.0.jar:3.9.0] > at > org.apache.cassandra.db.ColumnFamilyStore.invalidate(ColumnFamilyStore.java:517) > [apache-cassandra-3.9.0.jar:3.9.0] > at org.apache.cassandra.db.Keyspace.unloadCf(Keyspace.java:365) > [apache-cassandra-3.9.0.jar:3.9.0] > at org.apache.cassandra.db.Keyspace.dropCf(Keyspace.java:358) > [apache-cassandra-3.9.0.jar:3.9.0] > at org.apache.cassandra.config.Schema.dropView(Schema.java:744) > [apache-cassandra-3.9.0.jar:3.9.0] > at > org.apache.cassandra.schema.SchemaKeyspace.lambda$mergeSchema$373(SchemaKeyspace.java:1287) > [apache-cassandra-3.9.0.jar:3.9.0] > at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_121] > at > org.apache.cassandra.schema.SchemaKeyspace.mergeSchema(SchemaKeyspace.java:1287) > [apache-cassandra-3.9.0.jar:3.9.0] > at > org.apache.cassandra.schema.SchemaKeyspace.mergeSchemaAndAnnounceVersion(SchemaKeyspace.java:1256) > [apache-cassandra-3.9.0.jar:3.9.0] > at > org.apache.cassandra.db.DefinitionsUpdateVerbHandler$1.runMayThrow(DefinitionsUpdateVerbHandler.java:51) > ~[apache-cassandra-3.9.0.jar:3.9.0] > at > org.apache.cassandra.utils.WrappedRunnable.run(WrappedRunnable.java:28) > ~[apache-cassandra-3.9.0.jar:3.9.0] > at > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) > ~[na:1.8.0_121] > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > ~[na:1.8.0_121] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > ~[na:1.8.0_121] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > ~[na:1.8.0_121] > at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_121] > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)