mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-20 00:20:47 +00:00
db: normalize index names in get_snapshot_details()
Snapshot details exposed backing secondary-index view names instead of logical index names. Normalize index entries in get_snapshot_details() so the REST API reports the user-facing name, and update the existing REST test to assert that behavior directly.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "index/secondary_index_manager.hh"
|
||||
#include "replica/database.hh"
|
||||
#include "replica/global_table_ptr.hh"
|
||||
#include "replica/schema_describe_helper.hh"
|
||||
#include "sstables/sstables_manager.hh"
|
||||
#include "service/storage_proxy.hh"
|
||||
|
||||
@@ -196,7 +197,26 @@ snapshot_ctl::get_snapshot_details() {
|
||||
using snapshot_map = std::unordered_map<sstring, db_snapshot_details>;
|
||||
|
||||
co_return co_await run_snapshot_list_operation(coroutine::lambda([this] () -> future<snapshot_map> {
|
||||
return _db.local().get_snapshot_details();
|
||||
auto details = co_await _db.local().get_snapshot_details();
|
||||
|
||||
for (auto& [snapshot_name, snapshot_details] : details) {
|
||||
for (auto& table : snapshot_details) {
|
||||
auto schema = _db.local().as_data_dictionary().try_find_table(
|
||||
table.ks, table.cf);
|
||||
if (!schema || !schema->schema()->is_view()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto helper = replica::make_schema_describe_helper(
|
||||
schema->schema(), _db.local().as_data_dictionary());
|
||||
if (helper.type == schema_describe_helper::type::index) {
|
||||
table.cf = secondary_index::index_name_from_table_name(
|
||||
table.cf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
co_return details;
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -420,11 +420,11 @@ def test_storage_service_snapshot_mv_si(cql, this_dc, rest_api):
|
||||
})
|
||||
|
||||
with new_secondary_index(cql, table, 'v', 'si') as si:
|
||||
named_index_desc = cql.execute(f"DESC INDEX {si}").one()
|
||||
with new_test_snapshot(rest_api, keyspace, named_index_desc.name) as snap:
|
||||
index_name = si.split('.')[1]
|
||||
with new_test_snapshot(rest_api, keyspace, index_name) as snap:
|
||||
verify_snapshot_details(rest_api, {
|
||||
'key': snap,
|
||||
'value': [{'ks': keyspace, 'cf': named_index_desc.name, 'total': 0, 'live': 0}]
|
||||
'value': [{'ks': keyspace, 'cf': index_name, 'total': 0, 'live': 0}]
|
||||
})
|
||||
|
||||
ks, cf = table.split('.')
|
||||
|
||||
Reference in New Issue
Block a user