view: Stop requiring experimental feature
We modify the requirements for using materialized views in tablet-based
keyspaces. Before, it was necessary to enable the configuration option
`rf_rack_valid_keyspaces`, having the cluster feature `VIEWS_WITH_TABLETS`
enabled, and using the experimental feature `views-with-tablets`.
We drop the last requirement.
We adjust code to that change and provide a new validation test.
We also update the user documentation to reflect the changes.
Fixes scylladb/scylladb#23030
(cherry picked from commit b409e85c20)
This commit is contained in:
committed by
GitHub Action
parent
2e2d1f17bb
commit
2bdf792f8e
@@ -113,8 +113,7 @@ future<std::tuple<::shared_ptr<cql_transport::event::schema_change>, utils::chun
|
||||
if (rs->uses_tablets()) {
|
||||
warnings.push_back(
|
||||
"Tables in this keyspace will be replicated using Tablets "
|
||||
"and will not support Materialized Views, Secondary Indexes and counters features. "
|
||||
"To use Materialized Views, Secondary Indexes or counters, drop this keyspace and re-create it "
|
||||
"and will not support counters features. To use counters, drop this keyspace and re-create it "
|
||||
"without tablets by adding AND TABLETS = {'enabled': false} to the CREATE KEYSPACE statement.");
|
||||
if (ksm->initial_tablets().value()) {
|
||||
warnings.push_back("Keyspace `initial` tablets option is deprecated. Use per-table tablet options instead.");
|
||||
|
||||
@@ -1756,7 +1756,7 @@ std::map<sstring, db::experimental_features_t::feature> 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}
|
||||
{"views-with-tablets", feature::UNUSED}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -136,8 +136,7 @@ struct experimental_features_t {
|
||||
UDF,
|
||||
ALTERNATOR_STREAMS,
|
||||
BROADCAST_TABLES,
|
||||
KEYSPACE_STORAGE_OPTIONS,
|
||||
VIEWS_WITH_TABLETS
|
||||
KEYSPACE_STORAGE_OPTIONS
|
||||
};
|
||||
static std::map<sstring, feature> map(); // See enum_option.
|
||||
static std::vector<enum_option<experimental_features_t>> all();
|
||||
|
||||
@@ -3728,8 +3728,8 @@ void validate_view_keyspace(const data_dictionary::database& db, std::string_vie
|
||||
|
||||
if (!required_config && uses_tablets) {
|
||||
throw std::logic_error("Materialized views and secondary indexes are not supported on base tables with tablets. "
|
||||
"To be able to use them, enable the experimental feature `views-with-tablets` and the configuration "
|
||||
"option `rf_rack_valid_keyspaces`.");
|
||||
"To be able to use them, enable the configuration option `rf_rack_valid_keyspaces` and make sure "
|
||||
"that the cluster feature `VIEWS_WITH_TABLETS` is enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -202,12 +202,9 @@ enabled. If you plan to use any of the features listed below, CREATE your keyspa
|
||||
:ref:`with tablets disabled <tablets-enable-tablets>`.
|
||||
|
||||
* Counters
|
||||
* Materialized Views (MV) ``*``
|
||||
* Secondary indexes (SI, as it depends on MV) ``*``
|
||||
|
||||
``*`` You can enable experimental support for MV and SI using
|
||||
the ``--experimental-features=views-with-tablets`` configuration option.
|
||||
See :ref:`Views with tablets <admin-views-with-tablets>` for details.
|
||||
To enable materialized views and secondary indexes for tablet keyspaces, use
|
||||
the `--rf-rack-valid-keyspaces` See :ref:`Views with tablets <admin-views-with-tablets>` for details.
|
||||
|
||||
Resharding in keyspaces with tablets enabled has the following limitations:
|
||||
|
||||
|
||||
@@ -341,17 +341,13 @@ credentials and endpoint.
|
||||
Views with Tablets
|
||||
------------------
|
||||
|
||||
By default, Materialized Views (MV) and Secondary Indexes (SI)
|
||||
are disabled in keyspaces that use tablets.
|
||||
|
||||
Support for MV and SI with tablets is experimental and must be explicitly
|
||||
enabled in the ``scylla.yaml`` configuration file by specifying
|
||||
the ``views-with-tablets`` option:
|
||||
Materialized Views (MV) and Secondary Indexes (SI) are enabled in keyspaces that use tablets
|
||||
only when :term:`RF-rack-valid keyspaces <RF-rack-valid keyspace>` are enforced. That can be
|
||||
done in the ``scylla.yaml`` configuration file by specifying
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
experimental_features:
|
||||
- views-with-tablets
|
||||
rf_rack_valid_keyspaces: true
|
||||
|
||||
|
||||
Monitoring
|
||||
|
||||
3
init.cc
3
init.cc
@@ -99,9 +99,6 @@ std::set<sstring> get_disabled_features_from_db_config(const db::config& cfg, st
|
||||
if (!cfg.check_experimental(db::experimental_features_t::feature::KEYSPACE_STORAGE_OPTIONS)) {
|
||||
disabled.insert("KEYSPACE_STORAGE_OPTIONS"s);
|
||||
}
|
||||
if (!cfg.check_experimental(db::experimental_features_t::feature::VIEWS_WITH_TABLETS)) {
|
||||
disabled.insert("VIEWS_WITH_TABLETS"s);
|
||||
}
|
||||
if (cfg.force_gossip_topology_changes()) {
|
||||
if (cfg.enable_tablets_by_default()) {
|
||||
throw std::runtime_error("Tablets cannot be enabled with gossip topology changes. Use either --tablets-mode-for-new-keyspaces=enabled|enforced or --force-gossip-topology-changes, but not both.");
|
||||
|
||||
@@ -3512,8 +3512,8 @@ void database::validate_tablet_views_indexes() const {
|
||||
|
||||
dblog.warn("Some of the existing keyspaces violate the requirements "
|
||||
"for using materialized views or secondary indexes. Those features require enabling "
|
||||
"the experimental feature `views-with-tablets` and the configuration option "
|
||||
"`rf_rack_valid_keyspaces`. The keyspaces that violate that condition: {}", ks_list);
|
||||
"the configuration option `rf_rack_valid_keyspaces` and the cluster feature "
|
||||
"`VIEWS_WITH_TABLETS`. The keyspaces that violate that condition: {}", ks_list);
|
||||
}
|
||||
|
||||
utils::chunked_vector<uint64_t> compute_random_sorted_ints(uint64_t max_value, uint64_t n_values) {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
||||
#
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import pytest
|
||||
|
||||
@@ -16,14 +17,15 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("schema_kind", ["view", "index"])
|
||||
# Views no longer depend on the experimental feature `views-with-tablets`,
|
||||
# but let's keep these test cases to make sure it's really not needed anymore.
|
||||
@pytest.mark.parametrize("views_with_tablets", [False, True])
|
||||
@pytest.mark.parametrize("rf_rack_valid_keyspaces", [False, True])
|
||||
async def test_mv_and_index_restrictions_in_tablet_keyspaces(manager: ManagerClient, schema_kind: str,
|
||||
views_with_tablets: bool, rf_rack_valid_keyspaces: bool):
|
||||
"""
|
||||
Verify that creating a materialized view or a secondary index in a tablet-based keyspace
|
||||
is only possible when both the experimental flag `views-with-tablets` and the configuration
|
||||
option `rf_rack_valid_keyspaces` are enabled.
|
||||
is only possible when both the configuration option `rf_rack_valid_keyspaces` is enabled.
|
||||
"""
|
||||
|
||||
async def create_mv_or_index(cql: CassandraSession):
|
||||
@@ -49,8 +51,8 @@ async def test_mv_and_index_restrictions_in_tablet_keyspaces(manager: ManagerCli
|
||||
|
||||
async def try_fail(cql: CassandraSession):
|
||||
err = "Materialized views and secondary indexes are not supported on base tables with tablets. " \
|
||||
"To be able to use them, enable the experimental feature `views-with-tablets` and the configuration " \
|
||||
"option `rf_rack_valid_keyspaces`."
|
||||
"To be able to use them, enable the configuration option `rf_rack_valid_keyspaces` and " \
|
||||
"make sure that the cluster feature `VIEWS_WITH_TABLETS` is enabled."
|
||||
with pytest.raises(InvalidRequest, match=err):
|
||||
await try_pass(cql)
|
||||
|
||||
@@ -68,9 +70,51 @@ async def test_mv_and_index_restrictions_in_tablet_keyspaces(manager: ManagerCli
|
||||
cql.cluster.max_schema_agreement_wait = 0
|
||||
logger.debug("Set max_schema_agreement_wait to 0")
|
||||
|
||||
if views_with_tablets and rf_rack_valid_keyspaces:
|
||||
if rf_rack_valid_keyspaces:
|
||||
await try_pass(cql)
|
||||
logger.debug("try_pass finished successfully")
|
||||
else:
|
||||
await try_fail(cql)
|
||||
logger.debug("try_fail finished successfully")
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("view_type", ["view", "index"])
|
||||
async def test_view_startup(manager: ManagerClient, view_type: str):
|
||||
"""
|
||||
Verify that starting a node with materialized views in a tablet-based
|
||||
keyspace when the configuration option `rf_rack_valid_keyspaces` is disabled
|
||||
leads to a warning.
|
||||
"""
|
||||
|
||||
srv = await manager.server_add(config={"rf_rack_valid_keyspaces": True})
|
||||
cql = manager.get_cql()
|
||||
|
||||
await cql.run_async("CREATE KEYSPACE ks WITH replication = "
|
||||
"{'class': 'NetworkTopologyStrategy', 'replication_factor': 1} "
|
||||
"AND tablets = {'enabled': true}")
|
||||
await cql.run_async("CREATE TABLE ks.t (p int PRIMARY KEY, v int)")
|
||||
|
||||
if view_type == "view":
|
||||
await cql.run_async("CREATE MATERIALIZED VIEW ks.mv "
|
||||
"AS SELECT * FROM ks.t "
|
||||
"WHERE p IS NOT NULL AND v IS NOT NULL "
|
||||
"PRIMARY KEY (v, p)")
|
||||
elif view_type == "index":
|
||||
await cql.run_async("CREATE INDEX i ON ks.t(v)")
|
||||
else:
|
||||
logger.error(f"Unexpected view type: {view_type}")
|
||||
assert False
|
||||
|
||||
await manager.server_stop(srv.server_id)
|
||||
await manager.server_update_config(srv.server_id, "rf_rack_valid_keyspaces", False)
|
||||
|
||||
log = await manager.server_open_log(srv.server_id)
|
||||
mark = await log.mark()
|
||||
|
||||
start_task = asyncio.create_task(manager.server_start(srv.server_id))
|
||||
err = "Some of the existing keyspaces violate the requirements for using materialized " \
|
||||
"views or secondary indexes. Those features require enabling the configuration " \
|
||||
"option `rf_rack_valid_keyspaces` and the cluster feature `VIEWS_WITH_TABLETS`. " \
|
||||
"The keyspaces that violate that condition: ks"
|
||||
await log.wait_for(err, from_mark=mark)
|
||||
await start_task
|
||||
|
||||
Reference in New Issue
Block a user