Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 'Allow materialized views to by synchronous' from Piotr Sarna
This pull request introduces a "synchronous mode" for global views. In this mode, all view updates are applied synchronously as if the view was local. Marking view as a synchronous one can be done using `CREATE MATERIALIZED VIEW` and `ALTER MATERIALIZED VIEW`. E.g.: ```cql ALTER MATERIALIZED VIEW ks.v WITH synchronous_updates = true; ``` Marking view as a synchronous one was done using tags (originally used by alternator). No big modifications in the view's code were needed. Fixes: #10545 Closes #11013 * github.com:scylladb/scylla: cql-pytest: extend synchronous mv test with new cases cql-pytest: allow extra parameters in new_materialized_view docs: add a paragraph on view synchronous updates test/boost/cql_query_test: add test setting synchronous updates property test: cql-pytest: add a test for synchronous mode materialized views db: view: react to synchronous updates tag cql3: statements: cf_prop_defs: apply synchronous updates tag alternator, db: move the tag code to db/tags cql3: statements: add a synchronous_updates property
- Loading branch information
Showing
20 changed files
with
319 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ resources | |
.pytest_cache | ||
/expressions.tokens | ||
tags | ||
!db/tags/ | ||
testlog | ||
test/*/*.reject | ||
.vscode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2022-present ScyllaDB | ||
*/ | ||
|
||
/* | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
#include "db/tags/utils.hh" | ||
|
||
#include "db/tags/extension.hh" | ||
#include "schema_builder.hh" | ||
#include "schema_registry.hh" | ||
|
||
namespace db { | ||
|
||
const std::map<sstring, sstring>* get_tags_of_table(schema_ptr schema) { | ||
auto it = schema->extensions().find(tags_extension::NAME); | ||
if (it == schema->extensions().end()) { | ||
return nullptr; | ||
} | ||
auto tags_ext = static_pointer_cast<tags_extension>(it->second); | ||
return &tags_ext->tags(); | ||
} | ||
|
||
std::optional<std::string> find_tag(const schema& s, const sstring& tag) { | ||
auto it1 = s.extensions().find(tags_extension::NAME); | ||
if (it1 == s.extensions().end()) { | ||
return std::nullopt; | ||
} | ||
const std::map<sstring, sstring>& tags_map = | ||
static_pointer_cast<tags_extension>(it1->second)->tags(); | ||
auto it2 = tags_map.find(tag); | ||
if (it2 == tags_map.end()) { | ||
return std::nullopt; | ||
} else { | ||
return it2->second; | ||
} | ||
} | ||
|
||
future<> update_tags(service::migration_manager& mm, schema_ptr schema, std::map<sstring, sstring>&& tags_map) { | ||
co_await mm.container().invoke_on(0, [s = global_schema_ptr(std::move(schema)), tags_map = std::move(tags_map)] (service::migration_manager& mm) -> future<> { | ||
// FIXME: the following needs to be in a loop. If mm.announce() below | ||
// fails, we need to retry the whole thing. | ||
auto group0_guard = co_await mm.start_group0_operation(); | ||
|
||
schema_builder builder(s); | ||
builder.add_extension(tags_extension::NAME, ::make_shared<tags_extension>(tags_map)); | ||
|
||
auto m = co_await mm.prepare_column_family_update_announcement(builder.build(), false, std::vector<view_ptr>(), group0_guard.write_timestamp()); | ||
|
||
co_await mm.announce(std::move(m), std::move(group0_guard)); | ||
}); | ||
} | ||
|
||
} |
Oops, something went wrong.