Skip to content

Commit

Permalink
api: Use built_views table in get_built_indexes API
Browse files Browse the repository at this point in the history
Somehow system."IndexInfo" table and column_family/built_indexes REST
API endpoint declare an index "built" at slightly different times:

The former a virtual table which declares an index completely built
when it appears on the system.built_views table.

The latter uses different data -- it takes the list of indexes in
the schema and eliminates indexes which are still listed in the
system.scylla_views_builds_in_progress table.

The mentioned system. tables are updated at different times, so API
notices the change a bit later. It's worth improving the consistency
of these two APIs by making the REST API endpoint piggy-back the
load_built_views() instead of load_view_build_progress(). With that
change the filtering of indexes should be negated.

Fixes scylladb#21587

Signed-off-by: Pavel Emelyanov <[email protected]>
  • Loading branch information
xemul committed Dec 24, 2024
1 parent a19ad3c commit 5eb3278
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions api/column_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -993,19 +993,21 @@ void set_column_family(http_context& ctx, routes& r, sharded<db::system_keyspace
auto ks_cf = parse_fully_qualified_cf_name(req->get_path_param("name"));
auto&& ks = std::get<0>(ks_cf);
auto&& cf_name = std::get<1>(ks_cf);
return sys_ks.local().load_view_build_progress().then([ks, cf_name, &ctx](const std::vector<db::system_keyspace_view_build_progress>& vb) mutable {
// Use of load_built_views() as filtering table should be in sync with
// built_indexes_virtual_reader filtering with BUILT_VIEWS table
return sys_ks.local().load_built_views().then([ks, cf_name, &ctx](const std::vector<db::system_keyspace::view_name>& vb) mutable {
std::set<sstring> vp;
for (auto b : vb) {
if (b.view.first == ks) {
vp.insert(b.view.second);
if (b.first == ks) {
vp.insert(b.second);
}
}
std::vector<sstring> res;
auto uuid = get_uuid(ks, cf_name, ctx.db.local());
replica::column_family& cf = ctx.db.local().find_column_family(uuid);
res.reserve(cf.get_index_manager().list_indexes().size());
for (auto&& i : cf.get_index_manager().list_indexes()) {
if (!vp.contains(secondary_index::index_table_name(i.metadata().name()))) {
if (vp.contains(secondary_index::index_table_name(i.metadata().name()))) {
res.emplace_back(i.metadata().name());
}
}
Expand Down
2 changes: 2 additions & 0 deletions index/built_indexes_virtual_reader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ public:
tracing::trace_state_ptr trace_state,
streamed_mutation::forwarding fwd,
mutation_reader::forwarding fwd_mr) {
// Use of BUILT_VIEWS as filtering table should be in sync with
// cf::get_built_indexes's filtering with load_built_views()
return make_mutation_reader<built_indexes_reader>(
_db,
s,
Expand Down

0 comments on commit 5eb3278

Please sign in to comment.