From d04f376227475c4dd72faf4729e805bc31bb6454 Mon Sep 17 00:00:00 2001 From: Wojciech Mitros Date: Mon, 2 Dec 2024 22:16:55 +0100 Subject: [PATCH] mv: add an experimental feature for creating views using tablets We still have a number of issues to be solved for views with tablets. Until they are fixed, we should prevent users from creating them, and use the vnode-based views instead. This patch prepares the feature for enabling views with tablets. The feature is disabled by default, but currently it has no effect. After all tests are adjusted to use the feature, we should depend on the feature for deciding whether we can create materialized views in tablet-enabled keyspaces. The unit tests are adjusted to enable this feature explicitly, and it's also added to the scylla sstable tool config - this tool treats all tables as if they were tablet-based (surprisingly, with SimpleStrategy), so for it to work on views, the new feature must be enabled. Refs scylladb/scylladb#21832 Closes scylladb/scylladb#21833 --- cql3/statements/create_view_statement.cc | 1 + db/config.cc | 1 + db/config.hh | 1 + gms/feature_service.cc | 3 +++ gms/feature_service.hh | 1 + test/cqlpy/run.py | 1 + test/cqlpy/suite.yaml | 1 + test/pylib/scylla_cluster.py | 3 ++- test/rest_api/suite.yaml | 1 + tools/schema_loader.cc | 2 ++ 10 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cql3/statements/create_view_statement.cc b/cql3/statements/create_view_statement.cc index da7f1ac40d..592a6da434 100644 --- a/cql3/statements/create_view_statement.cc +++ b/cql3/statements/create_view_statement.cc @@ -29,6 +29,7 @@ #include "gms/feature_service.hh" #include "db/view/view.hh" #include "service/migration_manager.hh" +#include "replica/database.hh" namespace cql3 { diff --git a/db/config.cc b/db/config.cc index 90c5e76679..481ec3c4e9 100644 --- a/db/config.cc +++ b/db/config.cc @@ -1447,6 +1447,7 @@ std::map db::experimental_feature {"broadcast-tables", feature::BROADCAST_TABLES}, {"keyspace-storage-options", feature::KEYSPACE_STORAGE_OPTIONS}, {"tablets", feature::UNUSED}, + {"views-with-tablets", feature::VIEWS_WITH_TABLETS} }; } diff --git a/db/config.hh b/db/config.hh index 64f9ffce3a..6e001c832a 100644 --- a/db/config.hh +++ b/db/config.hh @@ -109,6 +109,7 @@ struct experimental_features_t { ALTERNATOR_STREAMS, BROADCAST_TABLES, KEYSPACE_STORAGE_OPTIONS, + VIEWS_WITH_TABLETS }; static std::map map(); // See enum_option. static std::vector> all(); diff --git a/gms/feature_service.cc b/gms/feature_service.cc index 00f22866c1..009224591f 100644 --- a/gms/feature_service.cc +++ b/gms/feature_service.cc @@ -82,6 +82,9 @@ feature_config feature_config_from_db_config(const db::config& cfg, std::set do_load_schemas(const db::config& cfg, std::string_view gms::feature_service feature_service(gms::feature_config_from_db_config(cfg)); feature_service.enable(feature_service.supported_feature_set()).get(); + feature_service.views_with_tablets.enable(); + sharded token_metadata; auto my_address = gms::inet_address("localhost");