Skip to content

tablets, mv: create tablets for a new materialized view#16205

Closed
nyh wants to merge 1 commit intoscylladb:masterfrom
nyh:fix-16194
Closed

tablets, mv: create tablets for a new materialized view#16205
nyh wants to merge 1 commit intoscylladb:masterfrom
nyh:fix-16194

Conversation

@nyh
Copy link
Copy Markdown
Contributor

@nyh nyh commented Nov 28, 2023

Before this patch, trying to create a materialized view when tablets are enabled for a keyspace results in a failure: "Tablet map not found for table ", with uuid referring to the new view.

When a table schema is created, the handler on_before_create_column_family() is called - and this function creates the tablet map for the new table. The bug was that we forgot to do the same when creating a materialized view - which also a bona-fide table.

In this patch we call on_before_create_column_family() also when creating the materialized view. I decided not to create a new callback (e.g., on_before_create_view()) and rather call the existing on_before_create_column_family() callback - after all, a view is a column family too.

This patch also includes a test for this issue, which fails to create the view before this patch, and passes with the patch. The test is in the test/topology_experimental_raft suite, which runs Scylla with the tablets experimental feature, and will also allow me to create tests that need multiple nodes. However, the first test added here only needs a single node to reproduce the bug and validate its fix.

Fixes #16194.

Before this patch, trying to create a materialized view when tablets
are enabled for a keyspace results in a failure: "Tablet map not found
for table <uuid>", with uuid referring to the new view.

When a table schema is created, the handler on_before_create_column_family()
is called - and this function creates the tablet map for the new table.
The bug was that we forgot to do the same when creating a materialized
view - which also a bona-fide table.

In this patch we call on_before_create_column_family() also when
creating the materialized view. I decided *not* to create a new
callback (e.g., on_before_create_view()) and rather call the existing
on_before_create_column_family() callback - after all, a view is
a column family too.

This patch also includes a test for this issue, which fails to create
the view before this patch, and passes with the patch. The test is
in the test/topology_experimental_raft suite, which runs Scylla with
the tablets experimental feature, and will also allow me to create
tests that need multiple nodes. However, the first test added here
only needs a single node to reproduce the bug and validate its fix.

Fixes scylladb#16194.

Signed-off-by: Nadav Har'El <[email protected]>
@nyh nyh requested a review from eliransin November 28, 2023 14:56
@nyh nyh requested a review from tgrabiec as a code owner November 28, 2023 14:56
mlogger.info("Create new view: {}", view);
auto mutations = db::schema_tables::make_create_view_mutations(keyspace, std::move(view), ts);
co_return co_await include_keyspace(sp, *keyspace, std::move(mutations));
return seastar::async([&db, keyspace = std::move(keyspace), &sp, view = std::move(view), ts] {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you de-cooroutinizing this function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I had to add seastar::async (I forgot to explain this in the commit message - the on_* callbacks all require to be run in a Seastar thread). Since async() returns a future, it's easier to just return this future and be done with it, no need to do the "co_return co_await" song and dance. The only other co_return in this function was an exception return, and also was only made more complicated by by the coroutinization.

@scylladb-promoter
Copy link
Copy Markdown
Contributor

🟢 CI State: SUCCESS

✅ - Build
✅ - Sanity Tests
✅ - Unit Tests

Build Details:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CREATE MATERIALIZED VIEW fails if the keyspace is based on tablets

4 participants