You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by bd...@apache.org on 2017/10/26 21:07:09 UTC
[3/6] cassandra git commit: Add flag to disable materialized views,
and warnings on creation
Add flag to disable materialized views, and warnings on creation
Patch by Blake Eggleston; Reviewed by Aleksey Yeschenko for CASSANDRA-13959
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b8697441
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b8697441
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b8697441
Branch: refs/heads/trunk
Commit: b8697441d7a051e7ff68def6aa9cf14bd92ace9e
Parents: 8fad4cd
Author: Blake Eggleston <bd...@gmail.com>
Authored: Mon Oct 9 16:40:04 2017 -0700
Committer: Blake Eggleston <bd...@gmail.com>
Committed: Thu Oct 26 13:54:37 2017 -0700
----------------------------------------------------------------------
CHANGES.txt | 2 +-
NEWS.txt | 8 ++++++++
conf/cassandra.yaml | 4 ++++
src/java/org/apache/cassandra/config/Config.java | 3 +++
.../apache/cassandra/config/DatabaseDescriptor.java | 5 +++++
.../cql3/statements/CreateViewStatement.java | 16 ++++++++++++++++
6 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b8697441/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 75f2c29..935931c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,10 +1,10 @@
3.0.16
+ * Add flag to disable materialized views, and warnings on creation (CASSANDRA-13959)
* Don't let user drop or generally break tables in system_distributed (CASSANDRA-13813)
* Provide a JMX call to sync schema with local storage (CASSANDRA-13954)
* Mishandling of cells for removed/dropped columns when reading legacy files (CASSANDRA-13939)
* Deserialise sstable metadata in nodetool verify (CASSANDRA-13922)
-
3.0.15
* Improve TRUNCATE performance (CASSANDRA-13909)
* Implement short read protection on partition boundaries (CASSANDRA-13595)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b8697441/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index 944857b..60cf77c 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -21,6 +21,14 @@ Upgrading
- Nothing specific to this release, but please see previous upgrading sections,
especially if you are upgrading from 2.2.
+Materialized Views
+-------------------
+ - Following a discussion regarding concerns about the design and safety of Materialized Views, the C* development
+ community no longer recommends them for production use, and considers them experimental. Warnings messages will
+ now be logged when they are created. (See https://www.mail-archive.com/dev@cassandra.apache.org/msg11511.html)
+ - An 'enable_materialized_views' flag has been added to cassandra.yaml to allow operators to prevent creation of
+ views
+
3.0.15
=====
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b8697441/conf/cassandra.yaml
----------------------------------------------------------------------
diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml
index d77d27a..b783090 100644
--- a/conf/cassandra.yaml
+++ b/conf/cassandra.yaml
@@ -952,6 +952,10 @@ enable_user_defined_functions: false
# This option has no effect, if enable_user_defined_functions is false.
enable_scripted_user_defined_functions: false
+# Enables materialized view creation on this node.
+# Materialized views are considered experimental and are not recommended for production use.
+enable_materialized_views: true
+
# The default Windows kernel timer and scheduling resolution is 15.6ms for power conservation.
# Lowering this value on Windows can provide much tighter latency and better throughput, however
# some virtualized environments may see a negative performance impact from changing this setting
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b8697441/src/java/org/apache/cassandra/config/Config.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/Config.java b/src/java/org/apache/cassandra/config/Config.java
index 6a99cd3..64d41bb 100644
--- a/src/java/org/apache/cassandra/config/Config.java
+++ b/src/java/org/apache/cassandra/config/Config.java
@@ -308,6 +308,9 @@ public class Config
public boolean enable_user_defined_functions = false;
public boolean enable_scripted_user_defined_functions = false;
+
+ public boolean enable_materialized_views = true;
+
/**
* Optionally disable asynchronous UDF execution.
* Disabling asynchronous UDF execution also implicitly disables the security-manager!
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b8697441/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index 029db89..efc71ef 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -2043,6 +2043,11 @@ public class DatabaseDescriptor
conf.user_defined_function_warn_timeout = userDefinedFunctionWarnTimeout;
}
+ public static boolean enableMaterializedViews()
+ {
+ return conf.enable_materialized_views;
+ }
+
public static long getUserDefinedFunctionFailTimeout()
{
return conf.user_defined_function_fail_timeout;
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b8697441/src/java/org/apache/cassandra/cql3/statements/CreateViewStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateViewStatement.java b/src/java/org/apache/cassandra/cql3/statements/CreateViewStatement.java
index 47304b6..778a3f4 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateViewStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateViewStatement.java
@@ -23,9 +23,13 @@ import java.util.stream.Collectors;
import com.google.common.collect.Iterables;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.apache.cassandra.auth.Permission;
import org.apache.cassandra.config.CFMetaData;
import org.apache.cassandra.config.ColumnDefinition;
+import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.config.Schema;
import org.apache.cassandra.config.ViewDefinition;
import org.apache.cassandra.cql3.*;
@@ -49,6 +53,8 @@ import org.apache.cassandra.transport.Event;
public class CreateViewStatement extends SchemaAlteringStatement
{
+ private static final Logger logger = LoggerFactory.getLogger(CreateViewStatement.class);
+
private final CFName baseName;
private final List<RawSelector> selectClause;
private final WhereClause whereClause;
@@ -114,6 +120,11 @@ public class CreateViewStatement extends SchemaAlteringStatement
public Event.SchemaChange announceMigration(QueryState queryState, boolean isLocalOnly) throws RequestValidationException
{
+ if (!DatabaseDescriptor.enableMaterializedViews())
+ {
+ throw new InvalidRequestException("Materialized views are disabled. Enable in cassandra.yaml to use.");
+ }
+
// We need to make sure that:
// - primary key includes all columns in base table's primary key
// - make sure that the select statement does not have anything other than columns
@@ -303,8 +314,13 @@ public class CreateViewStatement extends SchemaAlteringStatement
whereClauseText,
viewCfm);
+ logger.warn("Creating materialized view {} for {}.{}. " +
+ "Materialized views are experimental and are not recommended for production use.",
+ definition.viewName, cfm.ksName, cfm.cfName);
+
try
{
+ ClientWarn.instance.warn("Materialized views are experimental and are not recommended for production use.");
MigrationManager.announceNewView(definition, isLocalOnly);
return new Event.SchemaChange(Event.SchemaChange.Change.CREATED, Event.SchemaChange.Target.TABLE, keyspace(), columnFamily());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org