Repository: cassandra Updated Branches: refs/heads/trunk 76c1b5557 -> d3e6891ec
Clear view system metadata when dropping keyspace Patch by Zhao Yang; Reviewed by Paulo Motta for CASSANDRA-14646 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/d3e6891e Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/d3e6891e Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/d3e6891e Branch: refs/heads/trunk Commit: d3e6891ec33a6e65cf383ad346c452293cfe50ec Parents: 76c1b55 Author: Zhao Yang <[email protected]> Authored: Thu Aug 16 13:53:30 2018 +0800 Committer: Paulo Motta <[email protected]> Committed: Thu Aug 16 11:56:27 2018 -0300 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../apache/cassandra/db/view/ViewManager.java | 24 ++++++-------------- .../org/apache/cassandra/schema/Schema.java | 4 ++-- 3 files changed, 10 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/d3e6891e/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 4cd4cc5..d8aca56 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.0 + * Clear view system metadata when dropping keyspace (CASSANDRA-14646) * Allocate ReentrantLock on-demand in java11 AtomicBTreePartitionerBase (CASSANDRA-14637) * Make all existing virtual tables use LocalPartitioner (CASSANDRA-14640) * Revert 4.0 GC alg back to CMS (CASANDRA-14636) http://git-wip-us.apache.org/repos/asf/cassandra/blob/d3e6891e/src/java/org/apache/cassandra/db/view/ViewManager.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/view/ViewManager.java b/src/java/org/apache/cassandra/db/view/ViewManager.java index 0d565ae..000477d 100644 --- a/src/java/org/apache/cassandra/db/view/ViewManager.java +++ b/src/java/org/apache/cassandra/db/view/ViewManager.java @@ -104,12 +104,6 @@ public class ViewManager newViewsByName.put(definition.name(), definition); } - for (String viewName : viewsByName.keySet()) - { - if (!newViewsByName.containsKey(viewName)) - removeView(viewName); - } - for (Map.Entry<String, ViewMetadata> entry : newViewsByName.entrySet()) { if (!viewsByName.containsKey(entry.getKey())) @@ -157,28 +151,24 @@ public class ViewManager viewsByName.put(definition.name(), view); } - public void removeView(String name) + /** + * Stops the building of the specified view, no-op if it isn't building. + * + * @param name the name of the view + */ + public void dropView(String name) { View view = viewsByName.remove(name); if (view == null) return; + view.stopBuild(); forTable(view.getDefinition().baseTableId).removeByName(name); SystemKeyspace.setViewRemoved(keyspace.getName(), view.name); SystemDistributedKeyspace.setViewRemoved(keyspace.getName(), view.name); } - /** - * Stops the building of the specified view, no-op if it isn't building. - * - * @param name the name of the view - */ - public void stopBuild(String name) - { - viewsByName.get(name).stopBuild(); - } - public View getByName(String name) { return viewsByName.get(name); http://git-wip-us.apache.org/repos/asf/cassandra/blob/d3e6891e/src/java/org/apache/cassandra/schema/Schema.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/schema/Schema.java b/src/java/org/apache/cassandra/schema/Schema.java index fc09c24..e1353cd 100644 --- a/src/java/org/apache/cassandra/schema/Schema.java +++ b/src/java/org/apache/cassandra/schema/Schema.java @@ -660,7 +660,7 @@ public final class Schema delta.tables.altered.forEach(diff -> alterTable(diff.after)); delta.views.altered.forEach(diff -> alterView(diff.after)); - // deal with all removed, added, and altered views + // deal with all added, and altered views Keyspace.open(delta.after.name).viewManager.reload(true); // notify on everything dropped @@ -720,7 +720,7 @@ public final class Schema private void dropView(ViewMetadata metadata) { - Keyspace.open(metadata.keyspace()).viewManager.stopBuild(metadata.name()); + Keyspace.open(metadata.keyspace()).viewManager.dropView(metadata.name()); dropTable(metadata.metadata); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
