From 257d74bb3441c6d8d0988d004f727e5fa4bfbe53 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Thu, 4 Aug 2022 13:31:19 +0300 Subject: [PATCH] schema, everywhere: define and use table_id as a strong type Define table_id as a distinct utils::tagged_uuid modeled after raft tagged_id, so it can be differentiated from other uuid-class types, in particular from table_schema_version. Fixes #11207 Signed-off-by: Benny Halevy --- alternator/streams.cc | 15 +++--- api/column_family.cc | 12 ++--- api/column_family.hh | 4 +- api/compaction_manager.cc | 2 +- api/storage_service.cc | 8 ++-- canonical_mutation.cc | 2 +- canonical_mutation.hh | 6 +-- cdc/generation.cc | 2 +- cdc/log.cc | 4 +- cql3/statements/cf_prop_defs.cc | 4 +- cql3/statements/cf_prop_defs.hh | 2 +- cql3/statements/create_table_statement.cc | 2 +- cql3/statements/create_table_statement.hh | 4 +- data_dictionary/data_dictionary.cc | 10 ++-- data_dictionary/data_dictionary.hh | 12 ++--- data_dictionary/impl.hh | 2 +- db/commitlog/commitlog_replayer.cc | 4 +- db/commitlog/replay_position.hh | 4 +- db/legacy_schema_migrator.cc | 2 +- db/schema_tables.cc | 58 +++++++++++------------ db/schema_tables.hh | 6 +-- db/system_keyspace.cc | 36 +++++++------- db/system_keyspace.hh | 16 +++---- db/view/view.cc | 14 +++--- db/view/view_builder.hh | 12 ++--- frozen_mutation.cc | 2 +- frozen_mutation.hh | 2 +- idl/mutation.idl.hh | 4 +- idl/partition_checksum.idl.hh | 4 +- idl/read_command.idl.hh | 2 +- idl/streaming.idl.hh | 2 +- idl/uuid.idl.hh | 5 ++ message/messaging_service.cc | 12 ++--- message/messaging_service.hh | 9 ++-- mutation.hh | 2 +- querier.cc | 2 +- querier.hh | 2 +- query-request.hh | 6 +-- repair/repair.cc | 14 +++--- repair/repair.hh | 12 ++--- repair/row_level.cc | 10 ++-- repair/row_level.hh | 7 ++- replica/data_dictionary_impl.hh | 2 +- replica/database.cc | 34 ++++++------- replica/database.hh | 30 ++++++------ replica/distributed_loader.cc | 6 +-- replica/distributed_loader.hh | 2 +- schema.cc | 24 +++++----- schema.hh | 20 ++++---- schema_builder.hh | 10 ++-- schema_fwd.hh | 4 ++ service/cache_hitrate_calculator.hh | 4 +- service/migration_manager.cc | 2 +- service/migration_manager.hh | 2 +- service/misc_services.cc | 10 ++-- sstables_loader.cc | 4 +- sstables_loader.hh | 4 +- streaming/stream_detail.hh | 7 ++- streaming/stream_manager.cc | 2 +- streaming/stream_manager.hh | 2 +- streaming/stream_receive_task.cc | 2 +- streaming/stream_receive_task.hh | 2 +- streaming/stream_session.cc | 10 ++-- streaming/stream_session.hh | 10 ++-- streaming/stream_summary.hh | 7 ++- streaming/stream_task.cc | 2 +- streaming/stream_task.hh | 7 ++- streaming/stream_transfer_task.cc | 4 +- streaming/stream_transfer_task.hh | 3 +- test/boost/batchlog_manager_test.cc | 2 +- test/boost/column_mapping_test.cc | 4 +- test/boost/commitlog_test.cc | 52 ++++++++++---------- test/boost/database_test.cc | 2 +- test/lib/cql_test_env.cc | 2 +- test/manual/hint_test.cc | 2 +- test/perf/perf_commitlog.cc | 2 +- thrift/handler.cc | 2 +- tombstone_gc.cc | 8 ++-- tombstone_gc.hh | 2 +- tools/schema_loader.cc | 2 +- utils/UUID.hh | 4 ++ view_info.hh | 2 +- 82 files changed, 327 insertions(+), 315 deletions(-) diff --git a/alternator/streams.cc b/alternator/streams.cc index 250b2c0776..5d5afc9ea8 100644 --- a/alternator/streams.cc +++ b/alternator/streams.cc @@ -74,8 +74,8 @@ struct rapidjson::internal::TypeHelper : public from_string_helper {}; -static db_clock::time_point as_timepoint(const utils::UUID& uuid) { - return db_clock::time_point{utils::UUID_gen::unix_timestamp(uuid)}; +static db_clock::time_point as_timepoint(const table_id& tid) { + return db_clock::time_point{utils::UUID_gen::unix_timestamp(tid.uuid())}; } /** @@ -106,6 +106,9 @@ public: stream_arn(const UUID& uuid) : UUID(uuid) {} + stream_arn(const table_id& tid) + : UUID(tid.uuid()) + {} stream_arn(std::string_view v) : UUID(v.substr(1)) { @@ -155,7 +158,7 @@ future alternator::executor::list_str // and we can probably expect this to be a single call. if (streams_start) { i = std::find_if(i, e, [&](data_dictionary::table t) { - return t.schema()->id() == streams_start + return t.schema()->id().uuid() == streams_start && cdc::get_base_table(db.real_database(), *t.schema()) && is_alternator_keyspace(t.schema()->ks_name()) ; @@ -430,7 +433,7 @@ future executor::describe_stream(client_state& cl auto db = _proxy.data_dictionary(); try { - auto cf = db.find_column_family(stream_arn); + auto cf = db.find_column_family(table_id(stream_arn)); schema = cf.schema(); bs = cdc::get_base_table(db.real_database(), *schema); } catch (...) { @@ -717,7 +720,7 @@ future executor::get_shard_iterator(client_state& std::optional sid; try { - auto cf = db.find_column_family(stream_arn); + auto cf = db.find_column_family(table_id(stream_arn)); schema = cf.schema(); sid = rjson::get(request, "ShardId"); } catch (...) { @@ -802,7 +805,7 @@ future executor::get_records(client_state& client auto db = _proxy.data_dictionary(); schema_ptr schema, base; try { - auto log_table = db.find_column_family(iter.table); + auto log_table = db.find_column_family(table_id(iter.table)); schema = log_table.schema(); base = cdc::get_base_table(db.real_database(), *schema); } catch (...) { diff --git a/api/column_family.cc b/api/column_family.cc index 1ecbeab9b2..2458ada1fd 100644 --- a/api/column_family.cc +++ b/api/column_family.cc @@ -43,7 +43,7 @@ std::tuple parse_fully_qualified_cf_name(sstring name) { return std::make_tuple(name.substr(0, pos), name.substr(end)); } -const utils::UUID& get_uuid(const sstring& ks, const sstring& cf, const replica::database& db) { +const table_id& get_uuid(const sstring& ks, const sstring& cf, const replica::database& db) { try { return db.find_uuid(ks, cf); } catch (replica::no_such_column_family& e) { @@ -51,7 +51,7 @@ const utils::UUID& get_uuid(const sstring& ks, const sstring& cf, const replica: } } -const utils::UUID& get_uuid(const sstring& name, const replica::database& db) { +const table_id& get_uuid(const sstring& name, const replica::database& db) { auto [ks, cf] = parse_fully_qualified_cf_name(name); return get_uuid(ks, cf, db); } @@ -110,7 +110,7 @@ static future get_cf_stats_count(http_context& ctx, static future get_cf_histogram(http_context& ctx, const sstring& name, utils::timed_rate_moving_average_and_histogram replica::column_family_stats::*f) { - utils::UUID uuid = get_uuid(name, ctx.db.local()); + auto uuid = get_uuid(name, ctx.db.local()); return ctx.db.map_reduce0([f, uuid](const replica::database& p) { return (p.find_column_family(uuid).get_stats().*f).hist;}, utils::ihistogram(), @@ -122,7 +122,7 @@ static future get_cf_histogram(http_context& ctx, const static future get_cf_histogram(http_context& ctx, const sstring& name, utils::timed_rate_moving_average_summary_and_histogram replica::column_family_stats::*f) { - utils::UUID uuid = get_uuid(name, ctx.db.local()); + auto uuid = get_uuid(name, ctx.db.local()); return ctx.db.map_reduce0([f, uuid](const replica::database& p) { return (p.find_column_family(uuid).get_stats().*f).hist;}, utils::ihistogram(), @@ -149,7 +149,7 @@ static future get_cf_histogram(http_context& ctx, utils: static future get_cf_rate_and_histogram(http_context& ctx, const sstring& name, utils::timed_rate_moving_average_summary_and_histogram replica::column_family_stats::*f) { - utils::UUID uuid = get_uuid(name, ctx.db.local()); + auto uuid = get_uuid(name, ctx.db.local()); return ctx.db.map_reduce0([f, uuid](const replica::database& p) { return (p.find_column_family(uuid).get_stats().*f).rate();}, utils::rate_moving_average_and_histogram(), @@ -855,7 +855,7 @@ void set_column_family(http_context& ctx, routes& r) { }); cf::get_auto_compaction.set(r, [&ctx] (const_req req) { - const utils::UUID& uuid = get_uuid(req.param["name"], ctx.db.local()); + auto uuid = get_uuid(req.param["name"], ctx.db.local()); replica::column_family& cf = ctx.db.local().find_column_family(uuid); return !cf.is_auto_compaction_disabled_by_user(); }); diff --git a/api/column_family.hh b/api/column_family.hh index db51fcce75..e1efde9325 100644 --- a/api/column_family.hh +++ b/api/column_family.hh @@ -18,7 +18,7 @@ namespace api { void set_column_family(http_context& ctx, routes& r); -const utils::UUID& get_uuid(const sstring& name, const replica::database& db); +const table_id& get_uuid(const sstring& name, const replica::database& db); future<> foreach_column_family(http_context& ctx, const sstring& name, std::function f); @@ -63,7 +63,7 @@ struct map_reduce_column_families_locally { std::function(std::unique_ptr, std::unique_ptr)> reducer; future> operator()(replica::database& db) const { auto res = seastar::make_lw_shared>(std::make_unique(init)); - return do_for_each(db.get_column_families(), [res, this](const std::pair>& i) { + return do_for_each(db.get_column_families(), [res, this](const std::pair>& i) { *res = reducer(std::move(*res), mapper(*i.second.get())); }).then([res] { return std::move(*res); diff --git a/api/compaction_manager.cc b/api/compaction_manager.cc index 3e0fe669f8..0c049e2c9e 100644 --- a/api/compaction_manager.cc +++ b/api/compaction_manager.cc @@ -68,7 +68,7 @@ void set_compaction_manager(http_context& ctx, routes& r) { cm::get_pending_tasks_by_table.set(r, [&ctx] (std::unique_ptr req) { return ctx.db.map_reduce0([&ctx](replica::database& db) { return do_with(std::unordered_map, uint64_t, utils::tuple_hash>(), [&ctx, &db](std::unordered_map, uint64_t, utils::tuple_hash>& tasks) { - return do_for_each(db.get_column_families(), [&tasks](const std::pair>& i) { + return do_for_each(db.get_column_families(), [&tasks](const std::pair>& i) { replica::table& cf = *i.second.get(); tasks[std::make_pair(cf.schema()->ks_name(), cf.schema()->cf_name())] = cf.get_compaction_strategy().estimated_pending_compactions(cf.as_table_state()); return make_ready_future<>(); diff --git a/api/storage_service.cc b/api/storage_service.cc index 04f755dcbe..5dedd23506 100644 --- a/api/storage_service.cc +++ b/api/storage_service.cc @@ -611,11 +611,11 @@ void set_storage_service(http_context& ctx, routes& r, shardedcf_meta_data()); } return ctx.db.invoke_on_all([keyspace, column_families] (replica::database& db) -> future<> { - auto table_ids = boost::copy_range>(column_families | boost::adaptors::transformed([&] (auto& cf_name) { + auto table_ids = boost::copy_range>(column_families | boost::adaptors::transformed([&] (auto& cf_name) { return db.find_uuid(keyspace, cf_name); })); // major compact smaller tables first, to increase chances of success if low on space. - std::ranges::sort(table_ids, std::less<>(), [&] (const utils::UUID& id) { + std::ranges::sort(table_ids, std::less<>(), [&] (const table_id& id) { return db.find_column_family(id).get_stats().live_disk_space_used; }); // as a table can be dropped during loop below, let's find it before issuing major compaction request. @@ -641,11 +641,11 @@ void set_storage_service(http_context& ctx, routes& r, sharded future<> { - auto table_ids = boost::copy_range>(column_families | boost::adaptors::transformed([&] (auto& table_name) { + auto table_ids = boost::copy_range>(column_families | boost::adaptors::transformed([&] (auto& table_name) { return db.find_uuid(keyspace, table_name); })); // cleanup smaller tables first, to increase chances of success if low on space. - std::ranges::sort(table_ids, std::less<>(), [&] (const utils::UUID& id) { + std::ranges::sort(table_ids, std::less<>(), [&] (const table_id& id) { return db.find_column_family(id).get_stats().live_disk_space_used; }); auto& cm = db.get_compaction_manager(); diff --git a/canonical_mutation.cc b/canonical_mutation.cc index 0d08e8f1a8..9f058a8724 100644 --- a/canonical_mutation.cc +++ b/canonical_mutation.cc @@ -37,7 +37,7 @@ canonical_mutation::canonical_mutation(const mutation& m) }).end_canonical_mutation(); } -utils::UUID canonical_mutation::column_family_id() const { +table_id canonical_mutation::column_family_id() const { auto in = ser::as_input_stream(_data); auto mv = ser::deserialize(in, boost::type()); return mv.table_id(); diff --git a/canonical_mutation.hh b/canonical_mutation.hh index 327f7c0079..07349447ab 100644 --- a/canonical_mutation.hh +++ b/canonical_mutation.hh @@ -14,10 +14,6 @@ #include "bytes_ostream.hh" #include -namespace utils { - class UUID; -} // namespace utils - // Immutable mutation form which can be read using any schema version of the same table. // Safe to access from other shards via const&. // Safe to pass serialized across nodes. @@ -39,7 +35,7 @@ public: // is not intended, user should sync the schema first. mutation to_mutation(schema_ptr) const; - utils::UUID column_family_id() const; + table_id column_family_id() const; const bytes_ostream& representation() const { return _data; } diff --git a/cdc/generation.cc b/cdc/generation.cc index f328b8bd02..a145a8e7c0 100644 --- a/cdc/generation.cc +++ b/cdc/generation.cc @@ -607,7 +607,7 @@ future<> generation_service::maybe_rewrite_streams_descriptions() { continue; } - times_and_ttls.push_back(time_and_ttl{as_timepoint(s.id()), cdc_opts.ttl()}); + times_and_ttls.push_back(time_and_ttl{as_timepoint(s.id().uuid()), cdc_opts.ttl()}); } if (times_and_ttls.empty()) { diff --git a/cdc/log.cc b/cdc/log.cc index aeddc403ef..11832f6845 100644 --- a/cdc/log.cc +++ b/cdc/log.cc @@ -59,7 +59,7 @@ using namespace std::chrono_literals; logging::logger cdc_log("cdc"); namespace cdc { -static schema_ptr create_log_schema(const schema&, std::optional = {}, schema_ptr = nullptr); +static schema_ptr create_log_schema(const schema&, std::optional = {}, schema_ptr = nullptr); } static constexpr auto cdc_group_name = "cdc"; @@ -485,7 +485,7 @@ bytes log_data_column_deleted_elements_name_bytes(const bytes& column_name) { return to_bytes(cdc_deleted_elements_column_prefix) + column_name; } -static schema_ptr create_log_schema(const schema& s, std::optional uuid, schema_ptr old) { +static schema_ptr create_log_schema(const schema& s, std::optional uuid, schema_ptr old) { schema_builder b(s.ks_name(), log_name(s.cf_name())); b.with_partitioner(cdc::cdc_partitioner::classname); b.set_compaction_strategy(sstables::compaction_strategy_type::time_window); diff --git a/cql3/statements/cf_prop_defs.cc b/cql3/statements/cf_prop_defs.cc index 0d6f9a4acf..79e777bb51 100644 --- a/cql3/statements/cf_prop_defs.cc +++ b/cql3/statements/cf_prop_defs.cc @@ -189,10 +189,10 @@ int32_t cf_prop_defs::get_paxos_grace_seconds() const { return get_int(KW_PAXOSGRACESECONDS, DEFAULT_GC_GRACE_SECONDS); } -std::optional cf_prop_defs::get_id() const { +std::optional cf_prop_defs::get_id() const { auto id = get_simple(KW_ID); if (id) { - return utils::UUID(*id); + return std::make_optional(utils::UUID(*id)); } return std::nullopt; diff --git a/cql3/statements/cf_prop_defs.hh b/cql3/statements/cf_prop_defs.hh index c0c5ef9090..0f6f7e4e09 100644 --- a/cql3/statements/cf_prop_defs.hh +++ b/cql3/statements/cf_prop_defs.hh @@ -100,7 +100,7 @@ public: int32_t get_default_time_to_live() const; int32_t get_gc_grace_seconds() const; int32_t get_paxos_grace_seconds() const; - std::optional get_id() const; + std::optional get_id() const; bool get_synchronous_updates_flag() const; void apply_to_builder(schema_builder& builder, schema::extensions_map schema_extensions) const; diff --git a/cql3/statements/create_table_statement.cc b/cql3/statements/create_table_statement.cc index 9077f5f600..dbc6b5f7a6 100644 --- a/cql3/statements/create_table_statement.cc +++ b/cql3/statements/create_table_statement.cc @@ -41,7 +41,7 @@ create_table_statement::create_table_statement(cf_name name, ::shared_ptr properties, bool if_not_exists, column_set_type static_columns, - const std::optional& id) + const std::optional& id) : schema_altering_statement{name} , _use_compact_storage(false) , _static_columns{static_columns} diff --git a/cql3/statements/create_table_statement.hh b/cql3/statements/create_table_statement.hh index abc6595aec..9f2646cc32 100644 --- a/cql3/statements/create_table_statement.hh +++ b/cql3/statements/create_table_statement.hh @@ -60,13 +60,13 @@ class create_table_statement : public schema_altering_statement { column_set_type _static_columns; const ::shared_ptr _properties; const bool _if_not_exists; - std::optional _id; + std::optional _id; public: create_table_statement(cf_name name, ::shared_ptr properties, bool if_not_exists, column_set_type static_columns, - const std::optional& id); + const std::optional& id); virtual future<> check_access(query_processor& qp, const service::client_state& state) const override; diff --git a/data_dictionary/data_dictionary.cc b/data_dictionary/data_dictionary.cc index a1692fabce..05bdbf1e37 100644 --- a/data_dictionary/data_dictionary.cc +++ b/data_dictionary/data_dictionary.cc @@ -100,12 +100,12 @@ database::find_table(std::string_view ks, std::string_view table) const { } std::optional -database::try_find_table(utils::UUID id) const { +database::try_find_table(table_id id) const { return _ops->try_find_table(*this, id); } table -database::find_column_family(utils::UUID uuid) const { +database::find_column_family(table_id uuid) const { auto t = try_find_table(uuid); if (!t) { throw no_such_column_family(uuid); @@ -119,7 +119,7 @@ database::find_schema(std::string_view ks, std::string_view table) const { } schema_ptr -database::find_schema(utils::UUID uuid) const { +database::find_schema(table_id uuid) const { return find_column_family(uuid).schema(); } @@ -326,7 +326,7 @@ no_such_keyspace::no_such_keyspace(std::string_view ks_name) { } -no_such_column_family::no_such_column_family(const utils::UUID& uuid) +no_such_column_family::no_such_column_family(const table_id& uuid) : runtime_error{format("Can't find a column family with UUID {}", uuid)} { } @@ -336,7 +336,7 @@ no_such_column_family::no_such_column_family(std::string_view ks_name, std::stri { } -no_such_column_family::no_such_column_family(std::string_view ks_name, const utils::UUID& uuid) +no_such_column_family::no_such_column_family(std::string_view ks_name, const table_id& uuid) : runtime_error{format("Can't find a column family with UUID {} in keyspace {}", uuid, ks_name)} { } diff --git a/data_dictionary/data_dictionary.hh b/data_dictionary/data_dictionary.hh index 1f59c9474e..3b664e6e1f 100644 --- a/data_dictionary/data_dictionary.hh +++ b/data_dictionary/data_dictionary.hh @@ -14,7 +14,7 @@ #include #include #include "seastarx.hh" -#include "utils/UUID.hh" +#include "schema_fwd.hh" namespace replica { class database; // For transition; remove @@ -62,9 +62,9 @@ public: class no_such_column_family : public std::runtime_error { public: - no_such_column_family(const utils::UUID& uuid); + no_such_column_family(const table_id& uuid); no_such_column_family(std::string_view ks_name, std::string_view cf_name); - no_such_column_family(std::string_view ks_name, const utils::UUID& uuid); + no_such_column_family(std::string_view ks_name, const table_id& uuid); }; class table { @@ -105,13 +105,13 @@ public: std::vector get_keyspaces() const; std::vector
get_tables() const; table find_table(std::string_view ks, std::string_view table) const; // throws no_such_column_family - table find_column_family(utils::UUID uuid) const; // throws no_such_column_family + table find_column_family(table_id uuid) const; // throws no_such_column_family schema_ptr find_schema(std::string_view ks, std::string_view table) const; // throws no_such_column_family - schema_ptr find_schema(utils::UUID uuid) const; // throws no_such_column_family + schema_ptr find_schema(table_id uuid) const; // throws no_such_column_family table find_column_family(schema_ptr s) const; bool has_schema(std::string_view ks_name, std::string_view cf_name) const; std::optional
try_find_table(std::string_view ks, std::string_view table) const; - std::optional
try_find_table(utils::UUID id) const; + std::optional
try_find_table(table_id id) const; const db::config& get_config() const; std::set existing_index_names(std::string_view ks_name, std::string_view cf_to_exclude = sstring()) const; schema_ptr find_indexed_table(std::string_view ks_name, std::string_view index_name) const; diff --git a/data_dictionary/impl.hh b/data_dictionary/impl.hh index de4d21d1dd..7eabc5a3be 100644 --- a/data_dictionary/impl.hh +++ b/data_dictionary/impl.hh @@ -21,7 +21,7 @@ public: virtual std::vector get_keyspaces(database db) const = 0; virtual std::vector
get_tables(database db) const = 0; virtual std::optional
try_find_table(database db, std::string_view ks, std::string_view tab) const = 0; - virtual std::optional
try_find_table(database db, utils::UUID id) const = 0; + virtual std::optional
try_find_table(database db, table_id id) const = 0; virtual const secondary_index::secondary_index_manager& get_index_manager(table t) const = 0; virtual schema_ptr get_table_schema(table t) const = 0; virtual lw_shared_ptr get_keyspace_metadata(keyspace ks) const = 0; diff --git a/db/commitlog/commitlog_replayer.cc b/db/commitlog/commitlog_replayer.cc index 11157f922a..b9f82bb1da 100644 --- a/db/commitlog/commitlog_replayer.cc +++ b/db/commitlog/commitlog_replayer.cc @@ -84,7 +84,7 @@ public: future<> process(stats*, commitlog::buffer_and_replay_position buf_rp) const; future recover(sstring file, const sstring& fname_prefix) const; - typedef std::unordered_map rp_map; + typedef std::unordered_map rp_map; typedef std::unordered_map shard_rpm_map; typedef std::unordered_map shard_rp_map; @@ -92,7 +92,7 @@ public: auto i = _min_pos.find(shard); return i != _min_pos.end() ? i->second : replay_position(); } - replay_position cf_min_pos(const utils::UUID& uuid, unsigned shard) const { + replay_position cf_min_pos(const table_id& uuid, unsigned shard) const { auto i = _rpm.find(shard); if (i == _rpm.end()) { return replay_position(); diff --git a/db/commitlog/replay_position.hh b/db/commitlog/replay_position.hh index 4dfa35449c..8fe5f73279 100644 --- a/db/commitlog/replay_position.hh +++ b/db/commitlog/replay_position.hh @@ -11,7 +11,7 @@ #include #include -#include "utils/UUID.hh" +#include "schema_fwd.hh" #include "utils/hash.hh" #include "sstables/version.hh" @@ -72,7 +72,7 @@ struct replay_position { class commitlog; class cf_holder; -using cf_id_type = utils::UUID; +using cf_id_type = table_id; class rp_handle { public: diff --git a/db/legacy_schema_migrator.cc b/db/legacy_schema_migrator.cc index 6147bfdf0b..ca27ecf5de 100644 --- a/db/legacy_schema_migrator.cc +++ b/db/legacy_schema_migrator.cc @@ -147,7 +147,7 @@ public: auto ks_name = td.get_as("keyspace_name"); auto cf_name = td.get_as("columnfamily_name"); - auto id = td.get_or("cf_id", generate_legacy_id(ks_name, cf_name)); + auto id = table_id(td.get_or("cf_id", generate_legacy_id(ks_name, cf_name).uuid())); schema_builder builder(dst.name, cf_name, id); diff --git a/db/schema_tables.cc b/db/schema_tables.cc index 9c9456e0f8..316daa17b0 100644 --- a/db/schema_tables.cc +++ b/db/schema_tables.cc @@ -138,10 +138,10 @@ struct qualified_name { static future read_table_mutations(distributed& proxy, const qualified_name& table, schema_ptr s); static future<> merge_tables_and_views(distributed& proxy, - std::map&& tables_before, - std::map&& tables_after, - std::map&& views_before, - std::map&& views_after); + std::map&& tables_before, + std::map&& tables_after, + std::map&& views_before, + std::map&& views_after); struct [[nodiscard]] user_types_to_drop final { seastar::noncopyable_function ()> drop; @@ -967,17 +967,17 @@ static read_table_names_of_keyspace(distributed& proxy, })); } -static utils::UUID table_id_from_mutations(const schema_mutations& sm) { +static table_id table_id_from_mutations(const schema_mutations& sm) { auto table_rs = query::result_set(sm.columnfamilies_mutation()); query::result_set_row table_row = table_rs.row(0); - return table_row.get_nonnull("id"); + return table_id(table_row.get_nonnull("id")); } static -future> +future> read_tables_for_keyspaces(distributed& proxy, const std::set& keyspace_names, schema_ptr s) { - std::map result; + std::map result; for (auto&& keyspace_name : keyspace_names) { for (auto&& table_name : co_await read_table_names_of_keyspace(proxy, keyspace_name, s)) { auto qn = qualified_name(keyspace_name, table_name); @@ -1063,7 +1063,7 @@ future<> store_column_mapping(distributed& proxy, schema // Insert the new column mapping for a given schema version (without TTL) std::vector muts; - partition_key pk = partition_key::from_exploded(*history_tbl, {uuid_type->decompose(s->id())}); + partition_key pk = partition_key::from_exploded(*history_tbl, {uuid_type->decompose(s->id().uuid())}); ttl_opt ttl; if (with_ttl) { @@ -1087,7 +1087,7 @@ static future<> do_merge_schema(distributed& proxy, std: schema_ptr s = keyspaces(); // compare before/after schemas of the affected keyspaces only std::set keyspaces; - std::set column_families; + std::set column_families; for (auto&& mutation : mutations) { keyspaces.emplace(value_cast(utf8_type->deserialize(mutation.key().get_component(*s, 0)))); column_families.emplace(mutation.column_family_id()); @@ -1112,7 +1112,7 @@ static future<> do_merge_schema(distributed& proxy, std: if (do_flush) { auto& db = proxy.local().get_db(); - co_await coroutine::parallel_for_each(column_families, [&db] (const utils::UUID& id) -> future<> { + co_await coroutine::parallel_for_each(column_families, [&db] (const table_id& id) -> future<> { return replica::database::flush_table_on_all_shards(db, id); }); } @@ -1236,8 +1236,8 @@ enum class schema_diff_side { }; static schema_diff diff_table_or_view(distributed& proxy, - std::map&& before, - std::map&& after, + std::map&& before, + std::map&& after, noncopyable_function create_schema) { schema_diff d; @@ -1267,10 +1267,10 @@ static schema_diff diff_table_or_view(distributed& proxy // upon an alter table or alter type statement), then they are published together // as well, without any deferring in-between. static future<> merge_tables_and_views(distributed& proxy, - std::map&& tables_before, - std::map&& tables_after, - std::map&& views_before, - std::map&& views_after) + std::map&& tables_before, + std::map&& tables_after, + std::map&& views_before, + std::map&& views_after) { auto tables_diff = diff_table_or_view(proxy, std::move(tables_before), std::move(tables_after), [&] (schema_mutations sm, schema_diff_side) { return create_table_from_mutations(proxy, std::move(sm)); @@ -2356,7 +2356,7 @@ static schema_mutations make_table_mutations(schema_ptr table, api::timestamp_ty auto pkey = partition_key::from_singular(*s, table->ks_name()); mutation m{s, pkey}; auto ckey = clustering_key::from_singular(*s, table->cf_name()); - m.set_clustered_cell(ckey, "id", table->id(), timestamp); + m.set_clustered_cell(ckey, "id", table->id().uuid(), timestamp); auto scylla_tables_mutation = make_scylla_tables_mutation(table, timestamp); @@ -2804,7 +2804,7 @@ schema_ptr create_table_from_mutations(const schema_ctxt& ctxt, schema_mutations auto ks_name = table_row.get_nonnull("keyspace_name"); auto cf_name = table_row.get_nonnull("table_name"); - auto id = table_row.get_nonnull("id"); + auto id = table_id(table_row.get_nonnull("id")); schema_builder builder{ks_name, cf_name, id}; auto cf = cf_type::standard; @@ -3081,7 +3081,7 @@ view_ptr create_view_from_mutations(const schema_ctxt& ctxt, schema_mutations sm auto ks_name = row.get_nonnull("keyspace_name"); auto cf_name = row.get_nonnull("view_name"); - auto id = row.get_nonnull("id"); + auto id = table_id(row.get_nonnull("id")); schema_builder builder{ks_name, cf_name, id}; prepare_builder_from_table_row(ctxt, builder, row); @@ -3104,7 +3104,7 @@ view_ptr create_view_from_mutations(const schema_ctxt& ctxt, schema_mutations sm builder.with_version(sm.digest()); } - auto base_id = row.get_nonnull("base_table_id"); + auto base_id = table_id(row.get_nonnull("base_table_id")); auto base_name = row.get_nonnull("base_table_name"); auto include_all_columns = row.get_nonnull("include_all_columns"); auto where_clause = row.get_nonnull("where_clause"); @@ -3149,12 +3149,12 @@ static schema_mutations make_view_mutations(view_ptr view, api::timestamp_type t mutation m{s, pkey}; auto ckey = clustering_key::from_singular(*s, view->cf_name()); - m.set_clustered_cell(ckey, "base_table_id", view->view_info()->base_id(), timestamp); + m.set_clustered_cell(ckey, "base_table_id", view->view_info()->base_id().uuid(), timestamp); m.set_clustered_cell(ckey, "base_table_name", view->view_info()->base_name(), timestamp); m.set_clustered_cell(ckey, "where_clause", view->view_info()->where_clause(), timestamp); m.set_clustered_cell(ckey, "bloom_filter_fp_chance", view->bloom_filter_fp_chance(), timestamp); m.set_clustered_cell(ckey, "include_all_columns", view->view_info()->include_all_columns(), timestamp); - m.set_clustered_cell(ckey, "id", view->id(), timestamp); + m.set_clustered_cell(ckey, "id", view->id().uuid(), timestamp); add_table_params_to_mutations(m, ckey, view, timestamp); @@ -3471,11 +3471,11 @@ future read_table_mutations(distributed get_column_mapping(utils::UUID table_id, table_schema_version version) { +future get_column_mapping(::table_id table_id, table_schema_version version) { shared_ptr results = co_await qctx->qp().execute_internal( GET_COLUMN_MAPPING_QUERY, db::consistency_level::LOCAL_ONE, - {table_id, version}, + {table_id.uuid(), version}, cql3::query_processor::cache_internal::no ); if (results->empty()) { @@ -3512,24 +3512,24 @@ future get_column_mapping(utils::UUID table_id, table_schema_ver co_return std::move(cm); } -future column_mapping_exists(utils::UUID table_id, table_schema_version version) { +future column_mapping_exists(table_id table_id, table_schema_version version) { shared_ptr results = co_await qctx->qp().execute_internal( GET_COLUMN_MAPPING_QUERY, db::consistency_level::LOCAL_ONE, - {table_id, version}, + {table_id.uuid(), version}, cql3::query_processor::cache_internal::yes ); co_return !results->empty(); } -future<> drop_column_mapping(utils::UUID table_id, table_schema_version version) { +future<> drop_column_mapping(table_id table_id, table_schema_version version) { const static sstring DEL_COLUMN_MAPPING_QUERY = format("DELETE FROM system.{} WHERE cf_id = ? and schema_version = ?", db::schema_tables::SCYLLA_TABLE_SCHEMA_HISTORY); co_await qctx->qp().execute_internal( DEL_COLUMN_MAPPING_QUERY, db::consistency_level::LOCAL_ONE, - {table_id, version}, + {table_id.uuid(), version}, cql3::query_processor::cache_internal::no); } diff --git a/db/schema_tables.hh b/db/schema_tables.hh index d9e8b963cb..7ee5ac6db1 100644 --- a/db/schema_tables.hh +++ b/db/schema_tables.hh @@ -285,11 +285,11 @@ std::optional> get_map(const query::result_set_row& row, const ss /// overwriting an existing column mapping to garbage collect obsolete entries. future<> store_column_mapping(distributed& proxy, schema_ptr s, bool with_ttl); /// Query column mapping for a given version of the table locally. -future get_column_mapping(utils::UUID table_id, table_schema_version version); +future get_column_mapping(table_id table_id, table_schema_version version); /// Check that column mapping exists for a given version of the table -future column_mapping_exists(utils::UUID table_id, table_schema_version version); +future column_mapping_exists(table_id table_id, table_schema_version version); /// Delete matching column mapping entries from the `system.scylla_table_schema_history` table -future<> drop_column_mapping(utils::UUID table_id, table_schema_version version); +future<> drop_column_mapping(table_id table_id, table_schema_version version); } // namespace schema_tables } // namespace db diff --git a/db/system_keyspace.cc b/db/system_keyspace.cc index 5cf073587d..1a336b5afc 100644 --- a/db/system_keyspace.cc +++ b/db/system_keyspace.cc @@ -85,7 +85,7 @@ api::timestamp_type system_keyspace::schema_creation_timestamp() { // FIXME: Make automatic by calculating from schema structure. static const uint16_t version_sequence_number = 1; -table_schema_version system_keyspace::generate_schema_version(utils::UUID table_id, uint16_t offset) { +table_schema_version system_keyspace::generate_schema_version(::table_id table_id, uint16_t offset) { md5_hasher h; feed_hash(h, table_id); feed_hash(h, version_sequence_number + offset); @@ -1388,13 +1388,13 @@ typedef std::unordered_map truncation_map; static constexpr uint8_t current_version = 1; -future system_keyspace::get_truncation_record(utils::UUID cf_id) { +future system_keyspace::get_truncation_record(table_id cf_id) { if (qctx->qp().db().get_config().ignore_truncation_record.is_set()) { truncation_record r{truncation_record::current_magic}; return make_ready_future(std::move(r)); } sstring req = format("SELECT * from system.{} WHERE table_uuid = ?", TRUNCATED); - return qctx->qp().execute_internal(req, {cf_id}, cql3::query_processor::cache_internal::yes).then([](::shared_ptr rs) { + return qctx->qp().execute_internal(req, {cf_id.uuid()}, cql3::query_processor::cache_internal::yes).then([](::shared_ptr rs) { truncation_record r{truncation_record::current_magic}; for (const cql3::untyped_result_set_row& row : *rs) { @@ -1418,7 +1418,7 @@ future<> system_keyspace::cache_truncation_record() { sstring req = format("SELECT DISTINCT table_uuid, truncated_at from system.{}", TRUNCATED); return execute_cql(req).then([this] (::shared_ptr rs) { return parallel_for_each(rs->begin(), rs->end(), [this] (const cql3::untyped_result_set_row& row) { - auto table_uuid = row.get_as("table_uuid"); + auto table_uuid = table_id(row.get_as("table_uuid")); auto ts = row.get_as("truncated_at"); return _db.invoke_on_all([table_uuid, ts] (replica::database& db) mutable { @@ -1433,9 +1433,9 @@ future<> system_keyspace::cache_truncation_record() { }); } -future<> system_keyspace::save_truncation_record(utils::UUID id, db_clock::time_point truncated_at, db::replay_position rp) { +future<> system_keyspace::save_truncation_record(table_id id, db_clock::time_point truncated_at, db::replay_position rp) { sstring req = format("INSERT INTO system.{} (table_uuid, shard, position, segment_id, truncated_at) VALUES(?,?,?,?,?)", TRUNCATED); - return qctx->qp().execute_internal(req, {id, int32_t(rp.shard_id()), int32_t(rp.pos), int64_t(rp.base_id()), truncated_at}, cql3::query_processor::cache_internal::yes).discard_result().then([] { + return qctx->qp().execute_internal(req, {id.uuid(), int32_t(rp.shard_id()), int32_t(rp.pos), int64_t(rp.base_id()), truncated_at}, cql3::query_processor::cache_internal::yes).discard_result().then([] { return force_blocking_flush(TRUNCATED); }); } @@ -1444,7 +1444,7 @@ future<> system_keyspace::save_truncation_record(const replica::column_family& c return save_truncation_record(cf.schema()->id(), truncated_at, rp); } -future system_keyspace::get_truncated_position(utils::UUID cf_id, uint32_t shard) { +future system_keyspace::get_truncated_position(table_id cf_id, uint32_t shard) { return get_truncated_position(std::move(cf_id)).then([shard](replay_positions positions) { for (auto& rp : positions) { if (shard == rp.shard_id()) { @@ -1455,13 +1455,13 @@ future system_keyspace::get_truncated_position(utils::UUID }); } -future system_keyspace::get_truncated_position(utils::UUID cf_id) { +future system_keyspace::get_truncated_position(table_id cf_id) { return get_truncation_record(cf_id).then([](truncation_record e) { return make_ready_future(e.positions); }); } -future system_keyspace::get_truncated_at(utils::UUID cf_id) { +future system_keyspace::get_truncated_at(table_id cf_id) { return get_truncation_record(cf_id).then([](truncation_record e) { return make_ready_future(e.time_stamp); }); @@ -2633,7 +2633,7 @@ public: }; // Map from table's schema ID to table itself. Helps avoiding accidental duplication. -static thread_local std::map> virtual_tables; +static thread_local std::map> virtual_tables; void register_virtual_tables(distributed& dist_db, distributed& dist_ss, sharded& dist_gossiper, db::config& cfg) { auto add_table = [] (std::unique_ptr&& tbl) { @@ -2867,15 +2867,15 @@ future<> system_keyspace::get_compaction_history(compaction_history_consumer&& f future<> system_keyspace::update_repair_history(repair_history_entry entry) { sstring req = format("INSERT INTO system.{} (table_uuid, repair_time, repair_uuid, keyspace_name, table_name, range_start, range_end) VALUES (?, ?, ?, ?, ?, ?, ?)", REPAIR_HISTORY); - co_await execute_cql(req, entry.table_uuid, entry.ts, entry.id, entry.ks, entry.cf, entry.range_start, entry.range_end).discard_result(); + co_await execute_cql(req, entry.table_uuid.uuid(), entry.ts, entry.id, entry.ks, entry.cf, entry.range_start, entry.range_end).discard_result(); } -future<> system_keyspace::get_repair_history(utils::UUID table_id, repair_history_consumer f) { +future<> system_keyspace::get_repair_history(::table_id table_id, repair_history_consumer f) { sstring req = format("SELECT * from system.{} WHERE table_uuid = {}", REPAIR_HISTORY, table_id); co_await _qp.local().query_internal(req, [&f] (const cql3::untyped_result_set::row& row) mutable -> future { repair_history_entry ent; ent.id = row.get_as("repair_uuid"); - ent.table_uuid = row.get_as("table_uuid"); + ent.table_uuid = ::table_id(row.get_as("table_uuid")); ent.range_start = row.get_as("range_start"); ent.range_end = row.get_as("range_end"); ent.ks = row.get_as("keyspace_name"); @@ -3027,7 +3027,7 @@ future system_keyspace::load_paxos_state(partition_ static auto cql = format("SELECT * FROM system.{} WHERE row_key = ? AND cf_id = ?", PAXOS); // FIXME: we need execute_cql_with_now() (void)now; - auto f = qctx->execute_cql_with_timeout(cql, timeout, to_legacy(*key.get_compound_type(*s), key.representation()), s->id()); + auto f = qctx->execute_cql_with_timeout(cql, timeout, to_legacy(*key.get_compound_type(*s), key.representation()), s->id().uuid()); return f.then([s, key = std::move(key)] (shared_ptr results) mutable { if (results->empty()) { return service::paxos::paxos_state(); @@ -3072,7 +3072,7 @@ future<> system_keyspace::save_paxos_promise(const schema& s, const partition_ke paxos_ttl_sec(s), ballot, to_legacy(*key.get_compound_type(s), key.representation()), - s.id() + s.id().uuid() ).discard_result(); } @@ -3087,7 +3087,7 @@ future<> system_keyspace::save_paxos_proposal(const schema& s, const service::pa proposal.ballot, ser::serialize_to_buffer(proposal.update), to_legacy(*key.get_compound_type(s), key.representation()), - s.id() + s.id().uuid() ).discard_result(); } @@ -3108,7 +3108,7 @@ future<> system_keyspace::save_paxos_decision(const schema& s, const service::pa decision.ballot, ser::serialize_to_buffer(decision.update), to_legacy(*key.get_compound_type(s), key.representation()), - s.id() + s.id().uuid() ).discard_result(); } @@ -3122,7 +3122,7 @@ future<> system_keyspace::delete_paxos_decision(const schema& s, const partition timeout, utils::UUID_gen::micros_timestamp(ballot), to_legacy(*key.get_compound_type(s), key.representation()), - s.id() + s.id().uuid() ).discard_result(); } diff --git a/db/system_keyspace.hh b/db/system_keyspace.hh index cbdda74665..6f95bb19cd 100644 --- a/db/system_keyspace.hh +++ b/db/system_keyspace.hh @@ -220,7 +220,7 @@ public: static schema_ptr group0_history(); static schema_ptr discovery(); - static table_schema_version generate_schema_version(utils::UUID table_id, uint16_t offset = 0); + static table_schema_version generate_schema_version(table_id table_id, uint16_t offset = 0); future<> setup(sharded& ms); future<> update_schema_version(utils::UUID version); @@ -308,7 +308,7 @@ public: struct repair_history_entry { utils::UUID id; - utils::UUID table_uuid; + table_id table_uuid; db_clock::time_point ts; sstring ks; sstring cf; @@ -318,16 +318,16 @@ public: future<> update_repair_history(repair_history_entry); using repair_history_consumer = noncopyable_function(const repair_history_entry&)>; - future<> get_repair_history(utils::UUID table_id, repair_history_consumer f); + future<> get_repair_history(table_id, repair_history_consumer f); typedef std::vector replay_positions; - static future<> save_truncation_record(utils::UUID, db_clock::time_point truncated_at, db::replay_position); + static future<> save_truncation_record(table_id, db_clock::time_point truncated_at, db::replay_position); static future<> save_truncation_record(const replica::column_family&, db_clock::time_point truncated_at, db::replay_position); - static future get_truncated_position(utils::UUID); - static future get_truncated_position(utils::UUID, uint32_t shard); - static future get_truncated_at(utils::UUID); - static future get_truncation_record(utils::UUID cf_id); + static future get_truncated_position(table_id); + static future get_truncated_position(table_id, uint32_t shard); + static future get_truncated_at(table_id); + static future get_truncation_record(table_id cf_id); /** * Return a map of stored tokens to IP addresses diff --git a/db/view/view.cc b/db/view/view.cc index 8bb25be10b..b17a00f2f1 100644 --- a/db/view/view.cc +++ b/db/view/view.cc @@ -1486,7 +1486,7 @@ future<> view_builder::drain() { }).handle_exception_type([] (const semaphore_timed_out&) { // ignored }).finally([this] { - return parallel_for_each(_base_to_build_step, [] (std::pair& p) { + return parallel_for_each(_base_to_build_step, [] (std::pair& p) { return p.second.reader.close(); }); }); @@ -1498,7 +1498,7 @@ future<> view_builder::stop() { return drain(); } -view_builder::build_step& view_builder::get_or_create_build_step(utils::UUID base_id) { +view_builder::build_step& view_builder::get_or_create_build_step(table_id base_id) { auto it = _base_to_build_step.find(base_id); if (it == _base_to_build_step.end()) { auto base = _db.find_column_family(base_id).shared_from_this(); @@ -1526,7 +1526,7 @@ future<> view_builder::initialize_reader_at_current_token(build_step& step) { }); } -void view_builder::load_view_status(view_builder::view_build_status status, std::unordered_set& loaded_views) { +void view_builder::load_view_status(view_builder::view_build_status status, std::unordered_set& loaded_views) { if (!status.next_token) { // No progress was made on this view, so we'll treat it as new. return; @@ -1544,14 +1544,14 @@ void view_builder::load_view_status(view_builder::view_build_status status, std: void view_builder::reshard( std::vector> view_build_status_per_shard, - std::unordered_set& loaded_views) { + std::unordered_set& loaded_views) { // We must reshard. We aim for a simple algorithm, a step above not starting from scratch. // Shards build entries at different paces, so both first and last tokens will differ. We // want to be conservative when selecting the range that has been built. To do that, we // select the intersection of all the previous shard's ranges for each view. struct view_ptr_hash { std::size_t operator()(const view_ptr& v) const noexcept { - return std::hash()(v->id()); + return std::hash()(v->id()); } }; struct view_ptr_equals { @@ -1646,7 +1646,7 @@ void view_builder::setup_shard_build_step( return view_ptr(nullptr); }; - vbi.built_views = boost::copy_range>(built + vbi.built_views = boost::copy_range>(built | boost::adaptors::transformed(maybe_fetch_view) | boost::adaptors::filtered([] (const view_ptr& v) { return bool(v); }) | boost::adaptors::transformed([] (const view_ptr& v) { return v->id(); })); @@ -1683,7 +1683,7 @@ future<> view_builder::calculate_shard_build_step(view_builder_init_state& vbi) return false; } }; - std::unordered_set loaded_views; + std::unordered_set loaded_views; if (vbi.status_per_shard.size() != smp::count) { reshard(std::move(vbi.status_per_shard), loaded_views); } else if (!vbi.status_per_shard.empty()) { diff --git a/db/view/view_builder.hh b/db/view/view_builder.hh index d7a695c119..2a25e0bb26 100644 --- a/db/view/view_builder.hh +++ b/db/view/view_builder.hh @@ -144,7 +144,7 @@ class view_builder final : public service::migration_listener::only_view_notific } }; - using base_to_build_step_type = std::unordered_map; + using base_to_build_step_type = std::unordered_map; replica::database& _db; db::system_distributed_keyspace& _sys_dist_ks; @@ -160,7 +160,7 @@ class view_builder final : public service::migration_listener::only_view_notific seastar::abort_source _as; future<> _started = make_ready_future<>(); // Used to coordinate between shards the conclusion of the build process for a particular view. - std::unordered_set _built_views; + std::unordered_set _built_views; // Counter and promise (both on shard 0 only!) allowing to wait for all // shards to have read the view build statuses unsigned _shards_finished_read = 0; @@ -173,7 +173,7 @@ class view_builder final : public service::migration_listener::only_view_notific struct view_builder_init_state { std::vector> bookkeeping_ops; std::vector> status_per_shard; - std::unordered_set built_views; + std::unordered_set built_views; }; public: @@ -215,10 +215,10 @@ public: future> view_build_statuses(sstring keyspace, sstring view_name) const; private: - build_step& get_or_create_build_step(utils::UUID); + build_step& get_or_create_build_step(table_id); future<> initialize_reader_at_current_token(build_step&); - void load_view_status(view_build_status, std::unordered_set&); - void reshard(std::vector>, std::unordered_set&); + void load_view_status(view_build_status, std::unordered_set&); + void reshard(std::vector>, std::unordered_set&); void setup_shard_build_step(view_builder_init_state& vbi, std::vector, std::vector); future<> calculate_shard_build_step(view_builder_init_state& vbi); future<> add_new_view(view_ptr, build_step&); diff --git a/frozen_mutation.cc b/frozen_mutation.cc index ec9c066219..b65f3e14c5 100644 --- a/frozen_mutation.cc +++ b/frozen_mutation.cc @@ -36,7 +36,7 @@ ser::mutation_view frozen_mutation::mutation_view() const { return ser::deserialize(in, boost::type()); } -utils::UUID +table_id frozen_mutation::column_family_id() const { return mutation_view().table_id(); } diff --git a/frozen_mutation.hh b/frozen_mutation.hh index f34b8eda9a..9269459b95 100644 --- a/frozen_mutation.hh +++ b/frozen_mutation.hh @@ -166,7 +166,7 @@ public: frozen_mutation& operator=(frozen_mutation&&) = default; frozen_mutation& operator=(const frozen_mutation&) = default; const bytes_ostream& representation() const { return _bytes; } - utils::UUID column_family_id() const; + table_id column_family_id() const; utils::UUID schema_version() const; // FIXME: Should replace column_family_id() partition_key_view key() const; dht::decorated_key decorated_key(const schema& s) const; diff --git a/idl/mutation.idl.hh b/idl/mutation.idl.hh index 125ff6e88e..286a50298f 100644 --- a/idl/mutation.idl.hh +++ b/idl/mutation.idl.hh @@ -123,7 +123,7 @@ class mutation_partition stub [[writable]] { }; class mutation stub [[writable]] { - utils::UUID table_id; + ::table_id table_id; utils::UUID schema_version; partition_key key; mutation_partition partition; @@ -140,7 +140,7 @@ class column_mapping { }; class canonical_mutation stub [[writable]] { - utils::UUID table_id; + ::table_id table_id; utils::UUID schema_version; partition_key key; column_mapping mapping; diff --git a/idl/partition_checksum.idl.hh b/idl/partition_checksum.idl.hh index f177ca1282..4f494e04f0 100644 --- a/idl/partition_checksum.idl.hh +++ b/idl/partition_checksum.idl.hh @@ -109,7 +109,7 @@ struct node_ops_cmd_request { // Optional field, map bootstrapping nodes to bootstrap tokens, set by bootstrap cmd std::unordered_map> bootstrap_nodes; // Optional field, list uuids of tables being repaired, set by repair cmd - std::list repair_tables; + std::list repair_tables; }; struct node_ops_cmd_response { @@ -121,7 +121,7 @@ struct node_ops_cmd_response { struct repair_update_system_table_request { utils::UUID repair_uuid; - utils::UUID table_uuid; + table_id table_uuid; sstring keyspace_name; sstring table_name; dht::token_range range; diff --git a/idl/read_command.idl.hh b/idl/read_command.idl.hh index d7ad9c077b..6d954f5db3 100644 --- a/idl/read_command.idl.hh +++ b/idl/read_command.idl.hh @@ -47,7 +47,7 @@ struct max_result_size { } class read_command { - utils::UUID cf_id; + table_id cf_id; utils::UUID schema_version; query::partition_slice slice; uint32_t row_limit_low_bits; diff --git a/idl/streaming.idl.hh b/idl/streaming.idl.hh index ab9f14d6f6..2a13257608 100644 --- a/idl/streaming.idl.hh +++ b/idl/streaming.idl.hh @@ -21,7 +21,7 @@ class stream_request { }; class stream_summary { - utils::UUID cf_id; + table_id cf_id; int files; long total_size; }; diff --git a/idl/uuid.idl.hh b/idl/uuid.idl.hh index 8276571b4f..a71c839cba 100644 --- a/idl/uuid.idl.hh +++ b/idl/uuid.idl.hh @@ -7,6 +7,7 @@ */ #include "utils/UUID.hh" +#include "schema_fwd.hh" namespace utils { class UUID final { @@ -14,3 +15,7 @@ class UUID final { int64_t get_least_significant_bits(); }; } + +class table_id final { + utils::UUID uuid(); +}; diff --git a/message/messaging_service.cc b/message/messaging_service.cc index 7f2e86bfcc..e786fbd599 100644 --- a/message/messaging_service.cc +++ b/message/messaging_service.cc @@ -823,14 +823,14 @@ rpc::sink messaging_service::make_sink_for_stream_mutation_fragments(rp } future, rpc::source>> -messaging_service::make_sink_and_source_for_stream_mutation_fragments(utils::UUID schema_id, utils::UUID plan_id, utils::UUID cf_id, uint64_t estimated_partitions, streaming::stream_reason reason, msg_addr id) { +messaging_service::make_sink_and_source_for_stream_mutation_fragments(utils::UUID schema_id, utils::UUID plan_id, table_id cf_id, uint64_t estimated_partitions, streaming::stream_reason reason, msg_addr id) { using value_type = std::tuple, rpc::source>; if (is_shutting_down()) { return make_exception_future(rpc::closed_error()); } auto rpc_client = get_rpc_client(messaging_verb::STREAM_MUTATION_FRAGMENTS, id); return rpc_client->make_stream_sink().then([this, plan_id, schema_id, cf_id, estimated_partitions, reason, rpc_client] (rpc::sink sink) mutable { - auto rpc_handler = rpc()->make_client (utils::UUID, utils::UUID, utils::UUID, uint64_t, streaming::stream_reason, rpc::sink)>(messaging_verb::STREAM_MUTATION_FRAGMENTS); + auto rpc_handler = rpc()->make_client (utils::UUID, utils::UUID, table_id, uint64_t, streaming::stream_reason, rpc::sink)>(messaging_verb::STREAM_MUTATION_FRAGMENTS); return rpc_handler(*rpc_client , plan_id, schema_id, cf_id, estimated_partitions, reason, sink).then_wrapped([sink, rpc_client] (future> source) mutable { return (source.failed() ? sink.close() : make_ready_future<>()).then([sink = std::move(sink), source = std::move(source)] () mutable { return make_ready_future(value_type(std::move(sink), source.get0())); @@ -839,7 +839,7 @@ messaging_service::make_sink_and_source_for_stream_mutation_fragments(utils::UUI }); } -void messaging_service::register_stream_mutation_fragments(std::function> (const rpc::client_info& cinfo, UUID plan_id, UUID schema_id, UUID cf_id, uint64_t estimated_partitions, rpc::optional, rpc::source> source)>&& func) { +void messaging_service::register_stream_mutation_fragments(std::function> (const rpc::client_info& cinfo, UUID plan_id, UUID schema_id, table_id cf_id, uint64_t estimated_partitions, rpc::optional, rpc::source> source)>&& func) { register_handler(this, messaging_verb::STREAM_MUTATION_FRAGMENTS, std::move(func)); } @@ -962,15 +962,15 @@ future<> messaging_service::unregister_prepare_done_message() { // STREAM_MUTATION_DONE void messaging_service::register_stream_mutation_done(std::function (const rpc::client_info& cinfo, - UUID plan_id, dht::token_range_vector ranges, UUID cf_id, unsigned dst_cpu_id)>&& func) { + UUID plan_id, dht::token_range_vector ranges, table_id cf_id, unsigned dst_cpu_id)>&& func) { register_handler(this, messaging_verb::STREAM_MUTATION_DONE, [func = std::move(func)] (const rpc::client_info& cinfo, UUID plan_id, std::vector> ranges, - UUID cf_id, unsigned dst_cpu_id) mutable { + table_id cf_id, unsigned dst_cpu_id) mutable { return func(cinfo, plan_id, ::compat::unwrap(std::move(ranges)), cf_id, dst_cpu_id); }); } -future<> messaging_service::send_stream_mutation_done(msg_addr id, UUID plan_id, dht::token_range_vector ranges, UUID cf_id, unsigned dst_cpu_id) { +future<> messaging_service::send_stream_mutation_done(msg_addr id, UUID plan_id, dht::token_range_vector ranges, table_id cf_id, unsigned dst_cpu_id) { return send_message(this, messaging_verb::STREAM_MUTATION_DONE, id, plan_id, std::move(ranges), cf_id, dst_cpu_id); } diff --git a/message/messaging_service.hh b/message/messaging_service.hh index a8203cf369..8946855c2b 100644 --- a/message/messaging_service.hh +++ b/message/messaging_service.hh @@ -19,6 +19,7 @@ #include #include "range.hh" #include "tracing/tracing.hh" +#include "schema_fwd.hh" #include #include @@ -349,10 +350,10 @@ public: // Wrapper for STREAM_MUTATION_FRAGMENTS // The receiver of STREAM_MUTATION_FRAGMENTS sends status code to the sender to notify any error on the receiver side. The status code is of type int32_t. 0 means successful, -1 means error, other status code value are reserved for future use. - void register_stream_mutation_fragments(std::function> (const rpc::client_info& cinfo, UUID plan_id, UUID schema_id, UUID cf_id, uint64_t estimated_partitions, rpc::optional reason_opt, rpc::source> source)>&& func); + void register_stream_mutation_fragments(std::function> (const rpc::client_info& cinfo, UUID plan_id, UUID schema_id, table_id cf_id, uint64_t estimated_partitions, rpc::optional reason_opt, rpc::source> source)>&& func); future<> unregister_stream_mutation_fragments(); rpc::sink make_sink_for_stream_mutation_fragments(rpc::source>& source); - future, rpc::source>> make_sink_and_source_for_stream_mutation_fragments(utils::UUID schema_id, utils::UUID plan_id, utils::UUID cf_id, uint64_t estimated_partitions, streaming::stream_reason reason, msg_addr id); + future, rpc::source>> make_sink_and_source_for_stream_mutation_fragments(utils::UUID schema_id, utils::UUID plan_id, table_id cf_id, uint64_t estimated_partitions, streaming::stream_reason reason, msg_addr id); // Wrapper for REPAIR_GET_ROW_DIFF_WITH_RPC_STREAM future, rpc::source>> make_sink_and_source_for_repair_get_row_diff_with_rpc_stream(uint32_t repair_meta_id, msg_addr id); @@ -372,8 +373,8 @@ public: void register_repair_get_full_row_hashes_with_rpc_stream(std::function> (const rpc::client_info& cinfo, uint32_t repair_meta_id, rpc::source source)>&& func); future<> unregister_repair_get_full_row_hashes_with_rpc_stream(); - void register_stream_mutation_done(std::function (const rpc::client_info& cinfo, UUID plan_id, dht::token_range_vector ranges, UUID cf_id, unsigned dst_cpu_id)>&& func); - future<> send_stream_mutation_done(msg_addr id, UUID plan_id, dht::token_range_vector ranges, UUID cf_id, unsigned dst_cpu_id); + void register_stream_mutation_done(std::function (const rpc::client_info& cinfo, UUID plan_id, dht::token_range_vector ranges, table_id cf_id, unsigned dst_cpu_id)>&& func); + future<> send_stream_mutation_done(msg_addr id, UUID plan_id, dht::token_range_vector ranges, table_id cf_id, unsigned dst_cpu_id); future<> unregister_stream_mutation_done(); void register_complete_message(std::function (const rpc::client_info& cinfo, UUID plan_id, unsigned dst_cpu_id, rpc::optional failed)>&& func); diff --git a/mutation.hh b/mutation.hh index f9af4c7e0f..a410c0e15a 100644 --- a/mutation.hh +++ b/mutation.hh @@ -139,7 +139,7 @@ public: const schema_ptr& schema() const { return _ptr->_schema; } const mutation_partition& partition() const { return _ptr->_p; } mutation_partition& partition() { return _ptr->_p; } - const utils::UUID& column_family_id() const { return _ptr->_schema->id(); } + const table_id& column_family_id() const { return _ptr->_schema->id(); } // Consistent with hash bool operator==(const mutation&) const; bool operator!=(const mutation&) const; diff --git a/querier.cc b/querier.cc index 0b68839be1..c7ddd38e3f 100644 --- a/querier.cc +++ b/querier.cc @@ -413,7 +413,7 @@ future querier_cache::evict_one() noexcept { co_return false; } -future<> querier_cache::evict_all_for_table(const utils::UUID& schema_id) noexcept { +future<> querier_cache::evict_all_for_table(const table_id& schema_id) noexcept { for (auto ip : {&_data_querier_index, &_mutation_querier_index, &_shard_mutation_querier_index}) { auto& idx = *ip; for (auto it = idx.begin(); it != idx.end();) { diff --git a/querier.hh b/querier.hh index 6b564fab00..4d5952917d 100644 --- a/querier.hh +++ b/querier.hh @@ -386,7 +386,7 @@ public: /// Evict all queriers that belong to a table. /// /// Should be used when dropping a table. - future<> evict_all_for_table(const utils::UUID& schema_id) noexcept; + future<> evict_all_for_table(const table_id& schema_id) noexcept; /// Close all queriers and wait on background work. /// diff --git a/query-request.hh b/query-request.hh index f9845b4a46..ad5ecc623d 100644 --- a/query-request.hh +++ b/query-request.hh @@ -277,7 +277,7 @@ using is_first_page = bool_class; // Can be accessed across cores. class read_command { public: - utils::UUID cf_id; + table_id cf_id; table_schema_version schema_version; // TODO: This should be enough, drop cf_id partition_slice slice; uint32_t row_limit_low_bits; @@ -306,7 +306,7 @@ public: db::allow_per_partition_rate_limit allow_limit; // not serialized public: // IDL constructor - read_command(utils::UUID cf_id, + read_command(table_id cf_id, table_schema_version schema_version, partition_slice slice, uint32_t row_limit_low_bits, @@ -332,7 +332,7 @@ public: , allow_limit(db::allow_per_partition_rate_limit::no) { } - read_command(utils::UUID cf_id, + read_command(table_id cf_id, table_schema_version schema_version, partition_slice slice, query::max_result_size max_result_size, diff --git a/repair/repair.cc b/repair/repair.cc index 31182bbe60..b2117ca415 100644 --- a/repair/repair.cc +++ b/repair/repair.cc @@ -143,8 +143,8 @@ std::ostream& operator<<(std::ostream& os, const repair_uniq_id& x) { } // Must run inside a seastar thread -static std::vector get_table_ids(const replica::database& db, const sstring& keyspace, const std::vector& tables) { - std::vector table_ids; +static std::vector get_table_ids(const replica::database& db, const sstring& keyspace, const std::vector& tables) { + std::vector table_ids; table_ids.reserve(tables.size()); for (auto& table : tables) { thread::maybe_yield(); @@ -153,7 +153,7 @@ static std::vector get_table_ids(const replica::database& db, const return table_ids; } -static std::vector get_table_names(const replica::database& db, const std::vector& table_ids) { +static std::vector get_table_names(const replica::database& db, const std::vector& table_ids) { std::vector table_names; table_names.reserve(table_ids.size()); for (auto& table_id : table_ids) { @@ -508,7 +508,7 @@ future estimate_partitions(seastar::sharded& db, co static const dht::sharder& -get_sharder_for_tables(seastar::sharded& db, const sstring& keyspace, const std::vector& table_ids) { +get_sharder_for_tables(seastar::sharded& db, const sstring& keyspace, const std::vector& table_ids) { schema_ptr last_s; for (size_t idx = 0 ; idx < table_ids.size(); idx++) { schema_ptr s; @@ -536,7 +536,7 @@ get_sharder_for_tables(seastar::sharded& db, const sstring& k repair_info::repair_info(repair_service& repair, const sstring& keyspace_, const dht::token_range_vector& ranges_, - std::vector table_ids_, + std::vector table_ids_, repair_uniq_id id_, const std::vector& data_centers_, const std::vector& hosts_, @@ -605,7 +605,7 @@ size_t repair_info::ranges_size() { // Repair a single local range, multiple column families. // Comparable to RepairSession in Origin -future<> repair_info::repair_range(const dht::token_range& range, utils::UUID table_id) { +future<> repair_info::repair_range(const dht::token_range& range, ::table_id table_id) { check_in_shutdown(); check_in_abort(); ranges_index++; @@ -1153,7 +1153,7 @@ int repair_service::do_repair_start(sstring keyspace, std::unordered_map(table_ids.begin(), table_ids.end()); + auto tables = std::list(table_ids.begin(), table_ids.end()); auto req = node_ops_cmd_request(node_ops_cmd::repair_updater, uuid, {}, {}, {}, {}, std::move(tables)); auto update_interval = std::chrono::seconds(30); while (!as.abort_requested()) { diff --git a/repair/repair.hh b/repair/repair.hh index 7c93a58cb6..781f961e45 100644 --- a/repair/repair.hh +++ b/repair/repair.hh @@ -151,7 +151,7 @@ public: sstring keyspace; dht::token_range_vector ranges; std::vector cfs; - std::vector table_ids; + std::vector table_ids; repair_uniq_id id; shard_id shard; std::vector data_centers; @@ -173,7 +173,7 @@ public: repair_info(repair_service& repair, const sstring& keyspace_, const dht::token_range_vector& ranges_, - std::vector table_ids_, + std::vector table_ids_, repair_uniq_id id_, const std::vector& data_centers_, const std::vector& hosts_, @@ -200,7 +200,7 @@ public: return _hints_batchlog_flushed; } - future<> repair_range(const dht::token_range& range, utils::UUID table_id); + future<> repair_range(const dht::token_range& range, table_id); size_t ranges_size(); }; @@ -386,14 +386,14 @@ struct node_ops_cmd_request { // Optional field, map bootstrapping nodes to bootstrap tokens, set by bootstrap cmd std::unordered_map> bootstrap_nodes; // Optional field, list uuids of tables being repaired, set by repair cmd - std::list repair_tables; + std::list repair_tables; node_ops_cmd_request(node_ops_cmd command, utils::UUID uuid, std::list ignore = {}, std::list leaving = {}, std::unordered_map replace = {}, std::unordered_map> bootstrap = {}, - std::list tables = {}) + std::list tables = {}) : cmd(command) , ops_uuid(std::move(uuid)) , ignore_nodes(std::move(ignore)) @@ -418,7 +418,7 @@ struct node_ops_cmd_response { struct repair_update_system_table_request { utils::UUID repair_uuid; - utils::UUID table_uuid; + table_id table_uuid; sstring keyspace_name; sstring table_name; dht::token_range range; diff --git a/repair/row_level.cc b/repair/row_level.cc index 2291c885c2..d8ba51a781 100644 --- a/repair/row_level.cc +++ b/repair/row_level.cc @@ -2370,7 +2370,7 @@ static void add_to_repair_meta_for_followers(repair_meta& rm) { class row_level_repair { repair_info& _ri; sstring _cf_name; - utils::UUID _table_id; + table_id _table_id; dht::token_range _range; inet_address_vector_replica_set _all_live_peer_nodes; replica::column_family& _cf; @@ -2419,7 +2419,7 @@ class row_level_repair { public: row_level_repair(repair_info& ri, sstring cf_name, - utils::UUID table_id, + table_id table_id, dht::token_range range, std::vector all_live_peer_nodes) : _ri(ri) @@ -2844,7 +2844,7 @@ public: }; future<> repair_cf_range_row_level(repair_info& ri, - sstring cf_name, utils::UUID table_id, dht::token_range range, + sstring cf_name, table_id table_id, dht::token_range range, const std::vector& all_peer_nodes) { return seastar::futurize_invoke([&ri, cf_name = std::move(cf_name), table_id = std::move(table_id), range = std::move(range), &all_peer_nodes] () mutable { auto repair = row_level_repair(ri, std::move(cf_name), std::move(table_id), std::move(range), all_peer_nodes); @@ -2962,7 +2962,7 @@ static shard_id repair_id_to_shard(utils::UUID& repair_id) { } future> -repair_service::update_history(utils::UUID repair_id, utils::UUID table_id, dht::token_range range, gc_clock::time_point repair_time) { +repair_service::update_history(utils::UUID repair_id, table_id table_id, dht::token_range range, gc_clock::time_point repair_time) { auto shard = repair_id_to_shard(repair_id); return container().invoke_on(shard, [repair_id, table_id, range, repair_time] (repair_service& rs) mutable -> future> { repair_history& rh = rs._finished_ranges_history[repair_id]; @@ -2996,7 +2996,7 @@ future<> repair_service::load_history() { for (const auto& x : tables) { auto& table_uuid = x.first; auto& table = x.second; - auto shard = unsigned(table_uuid.get_most_significant_bits()) % smp::count; + auto shard = unsigned(table_uuid.uuid().get_most_significant_bits()) % smp::count; if (shard != this_shard_id()) { continue; } diff --git a/repair/row_level.hh b/repair/row_level.hh index 19512a9818..6a4295b23f 100644 --- a/repair/row_level.hh +++ b/repair/row_level.hh @@ -47,8 +47,7 @@ struct shard_config { class repair_history { public: - // The key for the map is the table_id - std::unordered_map> finished_ranges; + std::unordered_map> finished_ranges; gc_clock::time_point repair_time = gc_clock::time_point::max(); }; @@ -127,7 +126,7 @@ public: // stop them abruptly). future<> shutdown(); - future> update_history(utils::UUID repair_id, utils::UUID table_id, dht::token_range range, gc_clock::time_point repair_time); + future> update_history(utils::UUID repair_id, table_id table_id, dht::token_range range, gc_clock::time_point repair_time); future<> cleanup_history(utils::UUID repair_id); future<> load_history(); @@ -243,7 +242,7 @@ class repair_hasher; class repair_writer; future<> repair_cf_range_row_level(repair_info& ri, - sstring cf_name, utils::UUID table_id, dht::token_range range, + sstring cf_name, table_id table_id, dht::token_range range, const std::vector& all_peer_nodes); future> to_repair_rows_list(repair_rows_on_wire rows, schema_ptr s, uint64_t seed, repair_master is_master, diff --git a/replica/data_dictionary_impl.hh b/replica/data_dictionary_impl.hh index 76b8928824..81b33a0ca0 100644 --- a/replica/data_dictionary_impl.hh +++ b/replica/data_dictionary_impl.hh @@ -70,7 +70,7 @@ public: return std::nullopt; } } - virtual std::optional try_find_table(data_dictionary::database db, utils::UUID id) const override { + virtual std::optional try_find_table(data_dictionary::database db, table_id id) const override { try { return wrap(unwrap(db).find_column_family(id)); } catch (no_such_column_family&) { diff --git a/replica/database.cc b/replica/database.cc index d925360294..1a7f754dc7 100644 --- a/replica/database.cc +++ b/replica/database.cc @@ -141,7 +141,7 @@ public: }; const boost::container::static_vector>, 10> -phased_barrier_top_10_counts(const std::unordered_map>& tables, std::function op_count_getter) { +phased_barrier_top_10_counts(const std::unordered_map>& tables, std::function op_count_getter) { using table_list = boost::container::static_vector; using count_and_tables = std::pair; const auto less = [] (const count_and_tables& a, const count_and_tables& b) { @@ -1012,7 +1012,7 @@ future<> database::detach_column_family(table& cf) { co_await _querier_cache.evict_all_for_table(uuid); } -future>>> database::get_table_on_all_shards(sharded& sharded_db, utils::UUID uuid) { +future>>> database::get_table_on_all_shards(sharded& sharded_db, table_id uuid) { std::vector>> table_shards; table_shards.resize(smp::count); co_await coroutine::parallel_for_each(boost::irange(0u, smp::count), [&] (unsigned shard) -> future<> { @@ -1049,7 +1049,7 @@ future<> database::drop_table_on_all_shards(sharded& sharded_db, sstri co_await sstables::remove_table_directory_if_has_no_snapshots(table_dir); } -const utils::UUID& database::find_uuid(std::string_view ks, std::string_view cf) const { +const table_id& database::find_uuid(std::string_view ks, std::string_view cf) const { try { return _ks_cf_to_uuid.at(std::make_pair(ks, cf)); } catch (std::out_of_range&) { @@ -1057,7 +1057,7 @@ const utils::UUID& database::find_uuid(std::string_view ks, std::string_view cf) } } -const utils::UUID& database::find_uuid(const schema_ptr& schema) const { +const table_id& database::find_uuid(const schema_ptr& schema) const { return find_uuid(schema->ks_name(), schema->cf_name()); } @@ -1137,7 +1137,7 @@ const column_family& database::find_column_family(std::string_view ks_name, std: } } -column_family& database::find_column_family(const utils::UUID& uuid) { +column_family& database::find_column_family(const table_id& uuid) { try { return *_column_families.at(uuid); } catch (...) { @@ -1145,7 +1145,7 @@ column_family& database::find_column_family(const utils::UUID& uuid) { } } -const column_family& database::find_column_family(const utils::UUID& uuid) const { +const column_family& database::find_column_family(const table_id& uuid) const { try { return *_column_families.at(uuid); } catch (...) { @@ -1153,7 +1153,7 @@ const column_family& database::find_column_family(const utils::UUID& uuid) const } } -bool database::column_family_exists(const utils::UUID& uuid) const { +bool database::column_family_exists(const table_id& uuid) const { return _column_families.contains(uuid); } @@ -1237,19 +1237,19 @@ keyspace::make_column_family_config(const schema& s, const database& db) const { } sstring -keyspace::column_family_directory(const sstring& name, utils::UUID uuid) const { +keyspace::column_family_directory(const sstring& name, table_id uuid) const { return column_family_directory(_config.datadir, name, uuid); } sstring -keyspace::column_family_directory(const sstring& base_path, const sstring& name, utils::UUID uuid) const { +keyspace::column_family_directory(const sstring& base_path, const sstring& name, table_id uuid) const { auto uuid_sstring = uuid.to_sstring(); boost::erase_all(uuid_sstring, "-"); return format("{}/{}-{}", base_path, name, uuid_sstring); } future<> -keyspace::make_directory_for_column_family(const sstring& name, utils::UUID uuid) { +keyspace::make_directory_for_column_family(const sstring& name, table_id uuid) { std::vector cfdirs; for (auto& extra : _config.all_datadirs) { cfdirs.push_back(column_family_directory(extra, name, uuid)); @@ -1294,7 +1294,7 @@ schema_ptr database::find_schema(const sstring& ks_name, const sstring& cf_name) } } -schema_ptr database::find_schema(const utils::UUID& uuid) const { +schema_ptr database::find_schema(const table_id& uuid) const { return find_column_family(uuid).schema(); } @@ -1349,7 +1349,7 @@ database::create_keyspace(const lw_shared_ptr& ksm, locator:: future<> database::drop_caches() const { - std::unordered_map> tables = get_column_families(); + std::unordered_map> tables = get_column_families(); for (auto&& e : tables) { table& t = *e.second; co_await t.get_row_cache().invalidate(row_cache::external_updater([] {})); @@ -2292,7 +2292,7 @@ future<> database::flush(const sstring& ksname, const sstring& cfname) { return cf.flush(); } -future<> database::flush_table_on_all_shards(sharded& sharded_db, utils::UUID id) { +future<> database::flush_table_on_all_shards(sharded& sharded_db, table_id id) { return sharded_db.invoke_on_all([id] (replica::database& db) { return db.find_column_family(id).flush(); }); @@ -2489,7 +2489,7 @@ static sstring get_snapshot_table_dir_prefix(const sstring& table_name) { return table_name + "-"; } -static std::pair extract_cf_name_and_uuid(const sstring& directory_name) { +static std::pair extract_cf_name_and_uuid(const sstring& directory_name) { // cf directory is of the form: 'cf_name-uuid' // uuid is assumed to be exactly 32 hex characters wide. constexpr size_t uuid_size = 32; @@ -2497,7 +2497,7 @@ static std::pair extract_cf_name_and_uuid(const sstring& d if (pos <= 0 || directory_name[pos] != '-') { on_internal_error(dblog, format("table directory entry name '{}' is invalid: no '-' separator found at pos {}", directory_name, pos)); } - return std::make_pair(directory_name.substr(0, pos), utils::UUID(directory_name.substr(pos + 1))); + return std::make_pair(directory_name.substr(0, pos), table_id(utils::UUID(directory_name.substr(pos + 1)))); } future> database::get_snapshot_details() { @@ -2741,10 +2741,10 @@ flat_mutation_reader_v2 make_multishard_streaming_reader(distributed& _db; - utils::UUID _table_id; + table_id _table_id; std::vector _contexts; public: - streaming_reader_lifecycle_policy(distributed& db, utils::UUID table_id) : _db(db), _table_id(table_id), _contexts(smp::count) { + streaming_reader_lifecycle_policy(distributed& db, table_id table_id) : _db(db), _table_id(table_id), _contexts(smp::count) { } virtual flat_mutation_reader_v2 create_reader( schema_ptr schema, diff --git a/replica/database.hh b/replica/database.hh index 29ab805c8b..bf90f25f8c 100644 --- a/replica/database.hh +++ b/replica/database.hh @@ -1187,7 +1187,7 @@ public: } column_family::config make_column_family_config(const schema& s, const database& db) const; - future<> make_directory_for_column_family(const sstring& name, utils::UUID uuid); + future<> make_directory_for_column_family(const sstring& name, table_id uuid); void add_or_update_column_family(const schema_ptr& s); void add_user_type(const user_type ut); void remove_user_type(const user_type ut); @@ -1204,8 +1204,8 @@ public: return _config.datadir; } - sstring column_family_directory(const sstring& base_path, const sstring& name, utils::UUID uuid) const; - sstring column_family_directory(const sstring& name, utils::UUID uuid) const; + sstring column_family_directory(const sstring& base_path, const sstring& name, table_id uuid) const; + sstring column_family_directory(const sstring& name, table_id uuid) const; future<> ensure_populated() const; void mark_as_populated(); @@ -1323,9 +1323,9 @@ private: db::per_partition_rate_limit::info> _apply_stage; flat_hash_map _keyspaces; - std::unordered_map> _column_families; + std::unordered_map> _column_families; using ks_cf_to_uuid_t = - flat_hash_map, utils::UUID, utils::tuple_hash, string_pair_eq>; + flat_hash_map, table_id, utils::tuple_hash, string_pair_eq>; ks_cf_to_uuid_t _ks_cf_to_uuid; std::unique_ptr _commitlog; std::unique_ptr _schema_commitlog; @@ -1480,8 +1480,8 @@ public: future<> add_column_family_and_make_directory(schema_ptr schema); /* throws no_such_column_family if missing */ - const utils::UUID& find_uuid(std::string_view ks, std::string_view cf) const; - const utils::UUID& find_uuid(const schema_ptr&) const; + const table_id& find_uuid(std::string_view ks, std::string_view cf) const; + const table_id& find_uuid(const schema_ptr&) const; /** * Creates a keyspace for a given metadata if it still doesn't exist. @@ -1502,13 +1502,13 @@ public: std::vector get_all_keyspaces() const; column_family& find_column_family(std::string_view ks, std::string_view name); const column_family& find_column_family(std::string_view ks, std::string_view name) const; - column_family& find_column_family(const utils::UUID&); - const column_family& find_column_family(const utils::UUID&) const; + column_family& find_column_family(const table_id&); + const column_family& find_column_family(const table_id&) const; column_family& find_column_family(const schema_ptr&); const column_family& find_column_family(const schema_ptr&) const; - bool column_family_exists(const utils::UUID& uuid) const; + bool column_family_exists(const table_id& uuid) const; schema_ptr find_schema(const sstring& ks_name, const sstring& cf_name) const; - schema_ptr find_schema(const utils::UUID&) const; + schema_ptr find_schema(const table_id&) const; bool has_schema(std::string_view ks_name, std::string_view cf_name) const; std::set existing_index_names(const sstring& ks_name, const sstring& cf_to_exclude = sstring()) const; sstring get_available_index_name(const sstring& ks_name, const sstring& cf_name, @@ -1587,11 +1587,11 @@ public: return _keyspaces; } - const std::unordered_map>& get_column_families() const { + const std::unordered_map>& get_column_families() const { return _column_families; } - std::unordered_map>& get_column_families() { + std::unordered_map>& get_column_families() { return _column_families; } @@ -1629,7 +1629,7 @@ public: future<> flush_all_memtables(); future<> flush(const sstring& ks, const sstring& cf); // flush a table identified by the given id on all shards. - static future<> flush_table_on_all_shards(sharded& sharded_db, utils::UUID id); + static future<> flush_table_on_all_shards(sharded& sharded_db, table_id id); // flush a single table in a keyspace on all shards. static future<> flush_table_on_all_shards(sharded& sharded_db, std::string_view ks_name, std::string_view table_name); // flush a list of tables in a keyspace on all shards. @@ -1646,7 +1646,7 @@ public: private: future<> detach_column_family(table& cf); - static future>>> get_table_on_all_shards(sharded& db, utils::UUID uuid); + static future>>> get_table_on_all_shards(sharded& db, table_id uuid); struct table_truncate_state { gate::holder holder; diff --git a/replica/distributed_loader.cc b/replica/distributed_loader.cc index 80a066a01a..94700154a8 100644 --- a/replica/distributed_loader.cc +++ b/replica/distributed_loader.cc @@ -70,7 +70,7 @@ io_error_handler error_handler_gen_for_upload_dir(disk_error_signal_type& dummy) // global_column_family_ptr provides a way to easily retrieve local instance of a given column family. class global_column_family_ptr { distributed& _db; - utils::UUID _id; + table_id _id; private: replica::column_family& get() const { return _db.local().find_column_family(_id); } public: @@ -357,7 +357,7 @@ distributed_loader::process_upload_dir(distributed& db, distr }); } -future>>> +future>>> distributed_loader::get_sstables_from_upload_dir(distributed& db, sstring ks, sstring cf) { return seastar::async([&db, ks = std::move(ks), cf = std::move(cf)] { global_column_family_ptr global_table(db, ks, cf); @@ -539,7 +539,7 @@ future<> distributed_loader::populate_keyspace(distributed& d auto& column_families = db.local().get_column_families(); co_await coroutine::parallel_for_each(ks.metadata()->cf_meta_data() | boost::adaptors::map_values, [&] (schema_ptr s) -> future<> { - utils::UUID uuid = s->id(); + auto uuid = s->id(); lw_shared_ptr cf = column_families[uuid]; sstring cfname = cf->schema()->cf_name(); auto sstdir = ks.column_family_directory(ksdir, cfname, uuid); diff --git a/replica/distributed_loader.hh b/replica/distributed_loader.hh index 1f3b8ad24d..2997b4164e 100644 --- a/replica/distributed_loader.hh +++ b/replica/distributed_loader.hh @@ -85,7 +85,7 @@ public: // Each entry with index of idx should be accessed on shard idx only. // Each entry contains a vector of sstables for this shard. // The table UUID is returned too. - static future>>> + static future>>> get_sstables_from_upload_dir(distributed& db, sstring ks, sstring cf); static future<> process_upload_dir(distributed& db, distributed& sys_dist_ks, distributed& view_update_generator, sstring ks_name, sstring cf_name); diff --git a/schema.cc b/schema.cc index 5984c44b35..ea1eeac4ed 100644 --- a/schema.cc +++ b/schema.cc @@ -310,7 +310,7 @@ const column_mapping& schema::get_column_mapping() const { return _column_mapping; } -schema::raw_schema::raw_schema(utils::UUID id) +schema::raw_schema::raw_schema(table_id id) : _id(id) , _partitioner(::get_partitioner(default_partitioner_name)) , _sharder(::get_sharder(smp::count, default_partitioner_ignore_msb)) @@ -441,7 +441,7 @@ schema::schema(reversed_tag, const schema& o) { } -lw_shared_ptr make_shared_schema(std::optional id, std::string_view ks_name, +lw_shared_ptr make_shared_schema(std::optional id, std::string_view ks_name, std::string_view cf_name, std::vector partition_key, std::vector clustering_key, std::vector regular_columns, std::vector static_columns, data_type regular_column_name_type, sstring comment) { @@ -554,7 +554,7 @@ bool index_metadata::equals_noname(const index_metadata& other) const { return _kind == other._kind && _options == other._options; } -const utils::UUID& index_metadata::id() const { +const table_id& index_metadata::id() const { return _id; } @@ -752,11 +752,11 @@ static std::ostream& column_definition_as_cql_key(std::ostream& os, const column return os; } -static bool is_global_index(replica::database& db, const utils::UUID& id, const schema& s) { +static bool is_global_index(replica::database& db, const table_id& id, const schema& s) { return db.find_column_family(id).get_index_manager().is_global_index(s); } -static bool is_index(replica::database& db, const utils::UUID& id, const schema& s) { +static bool is_index(replica::database& db, const table_id& id, const schema& s) { return db.find_column_family(id).get_index_manager().is_index(s); } @@ -910,9 +910,9 @@ bool operator==(const column_definition& x, const column_definition& y) } // Based on org.apache.cassandra.config.CFMetaData#generateLegacyCfId -utils::UUID +table_id generate_legacy_id(const sstring& ks_name, const sstring& cf_name) { - return utils::UUID_gen::get_name_UUID(ks_name + cf_name); + return table_id(utils::UUID_gen::get_name_UUID(ks_name + cf_name)); } bool thrift_schema::has_compound_comparator() const { @@ -944,8 +944,8 @@ schema_builder& schema_builder::with_null_sharder() { } schema_builder::schema_builder(std::string_view ks_name, std::string_view cf_name, - std::optional id, data_type rct) - : _raw(id ? *id : utils::UUID_gen::get_time_UUID()) + std::optional id, data_type rct) + : _raw(id ? *id : table_id(utils::UUID_gen::get_time_UUID())) { // Various schema-creation commands (creating tables, indexes, etc.) // usually place limits on which characters are allowed in keyspace or @@ -989,7 +989,7 @@ schema_builder::schema_builder(const schema::raw_schema& raw) } schema_builder::schema_builder( - std::optional id, + std::optional id, std::string_view ks_name, std::string_view cf_name, std::vector partition_key, @@ -1204,7 +1204,7 @@ void schema_builder::prepare_dense_schema(schema::raw_schema& raw) { } } -schema_builder& schema_builder::with_view_info(utils::UUID base_id, sstring base_name, bool include_all_columns, sstring where_clause) { +schema_builder& schema_builder::with_view_info(table_id base_id, sstring base_name, bool include_all_columns, sstring where_clause) { _view_info = raw_view_info(std::move(base_id), std::move(base_name), include_all_columns, std::move(where_clause)); return *this; } @@ -1675,7 +1675,7 @@ schema_ptr schema::get_reversed() const { }); } -raw_view_info::raw_view_info(utils::UUID base_id, sstring base_name, bool include_all_columns, sstring where_clause) +raw_view_info::raw_view_info(table_id base_id, sstring base_name, bool include_all_columns, sstring where_clause) : _base_id(std::move(base_id)) , _base_name(std::move(base_name)) , _include_all_columns(include_all_columns) diff --git a/schema.hh b/schema.hh index 4dbf4ad80e..8435ac50fc 100644 --- a/schema.hh +++ b/schema.hh @@ -248,7 +248,7 @@ public: struct is_local_index_tag {}; using is_local_index = bool_class; private: - utils::UUID _id; + table_id _id; sstring _name; index_metadata_kind _kind; index_options_map _options; @@ -257,7 +257,7 @@ public: index_metadata(const sstring& name, const index_options_map& options, index_metadata_kind kind, is_local_index local); bool operator==(const index_metadata& other) const; bool equals_noname(const index_metadata& other) const; - const utils::UUID& id() const; + const table_id& id() const; const sstring& name() const; const index_metadata_kind kind() const; const index_options_map& options() const; @@ -486,14 +486,14 @@ bool operator==(const column_mapping& lhs, const column_mapping& rhs); * Effectively immutable. */ class raw_view_info final { - utils::UUID _base_id; + table_id _base_id; sstring _base_name; bool _include_all_columns; sstring _where_clause; public: - raw_view_info(utils::UUID base_id, sstring base_name, bool include_all_columns, sstring where_clause); + raw_view_info(table_id base_id, sstring base_name, bool include_all_columns, sstring where_clause); - const utils::UUID& base_id() const { + const table_id& base_id() const { return _base_id; } @@ -595,8 +595,8 @@ private: // More complex fields are derived from these inside rebuild(). // Contains only fields which can be safely default-copied. struct raw_schema { - raw_schema(utils::UUID id); - utils::UUID _id; + raw_schema(table_id id); + table_id _id; sstring _ks_name; sstring _cf_name; // regular columns are sorted by name @@ -735,7 +735,7 @@ public: const thrift_schema& thrift() const { return _thrift; } - const utils::UUID& id() const { + const table_id& id() const { return _raw._id; } const sstring& comment() const { @@ -996,7 +996,7 @@ public: schema_ptr get_reversed() const; }; -lw_shared_ptr make_shared_schema(std::optional id, std::string_view ks_name, std::string_view cf_name, +lw_shared_ptr make_shared_schema(std::optional id, std::string_view ks_name, std::string_view cf_name, std::vector partition_key, std::vector clustering_key, std::vector regular_columns, std::vector static_columns, data_type regular_column_name_type, sstring comment = ""); @@ -1031,7 +1031,7 @@ public: std::ostream& operator<<(std::ostream& os, const view_ptr& view); -utils::UUID generate_legacy_id(const sstring& ks_name, const sstring& cf_name); +table_id generate_legacy_id(const sstring& ks_name, const sstring& cf_name); // Thrown when attempted to access a schema-dependent object using diff --git a/schema_builder.hh b/schema_builder.hh index 88d70e6191..39edd5c2bf 100644 --- a/schema_builder.hh +++ b/schema_builder.hh @@ -29,10 +29,10 @@ private: schema_builder(const schema::raw_schema&); public: schema_builder(std::string_view ks_name, std::string_view cf_name, - std::optional = { }, + std::optional = { }, data_type regular_column_name_type = utf8_type); schema_builder( - std::optional id, + std::optional id, std::string_view ks_name, std::string_view cf_name, std::vector partition_key, @@ -43,11 +43,11 @@ public: sstring comment = ""); schema_builder(const schema_ptr); - schema_builder& set_uuid(const utils::UUID& id) { + schema_builder& set_uuid(const table_id& id) { _raw._id = id; return *this; } - const utils::UUID& uuid() const { + const table_id& uuid() const { return _raw._id; } schema_builder& set_regular_column_name_type(const data_type& t) { @@ -273,7 +273,7 @@ public: schema_builder& with(compact_storage); schema_builder& with_version(table_schema_version); - schema_builder& with_view_info(utils::UUID base_id, sstring base_name, bool include_all_columns, sstring where_clause); + schema_builder& with_view_info(table_id base_id, sstring base_name, bool include_all_columns, sstring where_clause); schema_builder& with_view_info(const schema& base_schema, bool include_all_columns, sstring where_clause) { return with_view_info(base_schema.id(), base_schema.cf_name(), include_all_columns, where_clause); } diff --git a/schema_fwd.hh b/schema_fwd.hh index 3c5ffbb159..eb2403f40e 100644 --- a/schema_fwd.hh +++ b/schema_fwd.hh @@ -10,6 +10,8 @@ #include +#include "utils/UUID.hh" + using column_count_type = uint32_t; // Column ID, unique within column_kind @@ -19,3 +21,5 @@ class schema; class schema_extension; using schema_ptr = seastar::lw_shared_ptr; + +using table_id = utils::tagged_uuid; diff --git a/service/cache_hitrate_calculator.hh b/service/cache_hitrate_calculator.hh index 419dae0957..b9c38538d9 100644 --- a/service/cache_hitrate_calculator.hh +++ b/service/cache_hitrate_calculator.hh @@ -9,7 +9,7 @@ #pragma once #include "replica/database_fwd.hh" -#include "utils/UUID.hh" +#include "schema_fwd.hh" #include #include @@ -35,7 +35,7 @@ class cache_hitrate_calculator : public seastar::async_sharded_service _timer; bool _stopped = false; float _diff = 0; - std::unordered_map _rates; + std::unordered_map _rates; size_t _slen = 0; std::string _gstate; uint64_t _published_nr = 0; diff --git a/service/migration_manager.cc b/service/migration_manager.cc index 0c500fc012..ffba5b1ed3 100644 --- a/service/migration_manager.cc +++ b/service/migration_manager.cc @@ -1120,7 +1120,7 @@ future<> migration_manager::sync_schema(const replica::database& db, const std:: }); } -future get_column_mapping(utils::UUID table_id, table_schema_version v) { +future get_column_mapping(table_id table_id, table_schema_version v) { schema_ptr s = local_schema_registry().get_or_null(v); if (s) { return make_ready_future(s->get_column_mapping()); diff --git a/service/migration_manager.hh b/service/migration_manager.hh index 8f594cef6a..645c861767 100644 --- a/service/migration_manager.hh +++ b/service/migration_manager.hh @@ -222,6 +222,6 @@ public: void set_concurrent_ddl_retries(size_t); }; -future get_column_mapping(utils::UUID table_id, table_schema_version v); +future get_column_mapping(table_id, table_schema_version v); } diff --git a/service/misc_services.cc b/service/misc_services.cc index 65662b8ad8..23e5d66796 100644 --- a/service/misc_services.cc +++ b/service/misc_services.cc @@ -136,26 +136,26 @@ void cache_hitrate_calculator::run_on(size_t master, lowres_clock::duration d) { } future cache_hitrate_calculator::recalculate_hitrates() { - auto non_system_filter = [&] (const std::pair>& cf) { + auto non_system_filter = [&] (const std::pair>& cf) { return _db.local().find_keyspace(cf.second->schema()->ks_name()).get_replication_strategy().get_type() != locator::replication_strategy_type::local; }; auto cf_to_cache_hit_stats = [non_system_filter] (replica::database& db) { - return boost::copy_range>(db.get_column_families() | boost::adaptors::filtered(non_system_filter) | - boost::adaptors::transformed([] (const std::pair>& cf) { + return boost::copy_range>(db.get_column_families() | boost::adaptors::filtered(non_system_filter) | + boost::adaptors::transformed([] (const std::pair>& cf) { auto& stats = cf.second->get_row_cache().stats(); return std::make_pair(cf.first, stat{float(stats.reads_with_no_misses.rate().rates[0]), float(stats.reads_with_misses.rate().rates[0])}); })); }; - auto sum_stats_per_cf = [] (std::unordered_map a, std::unordered_map b) { + auto sum_stats_per_cf = [] (std::unordered_map a, std::unordered_map b) { for (auto& r : b) { a[r.first] += r.second; } return a; }; - return _db.map_reduce0(cf_to_cache_hit_stats, std::unordered_map(), sum_stats_per_cf).then([this, non_system_filter] (std::unordered_map rates) mutable { + return _db.map_reduce0(cf_to_cache_hit_stats, std::unordered_map(), sum_stats_per_cf).then([this, non_system_filter] (std::unordered_map rates) mutable { _diff = 0; _gstate.reserve(_slen); // assume length did not change from previous iteration _slen = 0; diff --git a/sstables_loader.cc b/sstables_loader.cc index a77ea91faa..94d7d88650 100644 --- a/sstables_loader.cc +++ b/sstables_loader.cc @@ -115,7 +115,7 @@ public: } // anonymous namespace future<> sstables_loader::load_and_stream(sstring ks_name, sstring cf_name, - utils::UUID table_id, std::vector sstables, bool primary_replica_only) { + ::table_id table_id, std::vector sstables, bool primary_replica_only) { const auto full_partition_range = dht::partition_range::make_open_ended_both_sides(); const auto full_token_range = dht::token_range::make_open_ended_both_sides(); auto& table = _db.local().find_column_family(table_id); @@ -249,7 +249,7 @@ future<> sstables_loader::load_new_sstables(sstring ks_name, sstring cf_name, ks_name, cf_name, load_and_stream, primary_replica_only); try { if (load_and_stream) { - utils::UUID table_id; + ::table_id table_id; std::vector> sstables_on_shards; std::tie(table_id, sstables_on_shards) = co_await replica::distributed_loader::get_sstables_from_upload_dir(_db, ks_name, cf_name); co_await container().invoke_on_all([&sstables_on_shards, ks_name, cf_name, table_id, primary_replica_only] (sstables_loader& loader) mutable -> future<> { diff --git a/sstables_loader.hh b/sstables_loader.hh index ffdc147fb1..63dd254258 100644 --- a/sstables_loader.hh +++ b/sstables_loader.hh @@ -9,7 +9,7 @@ #pragma once #include -#include "utils/UUID.hh" +#include "schema_fwd.hh" #include "sstables/shared_sstable.hh" using namespace seastar; @@ -45,7 +45,7 @@ class sstables_loader : public seastar::peering_sharded_service bool _loading_new_sstables = false; future<> load_and_stream(sstring ks_name, sstring cf_name, - utils::UUID table_id, std::vector sstables, + table_id, std::vector sstables, bool primary_replica_only); public: diff --git a/streaming/stream_detail.hh b/streaming/stream_detail.hh index 2dc19fe6f8..7236514f01 100644 --- a/streaming/stream_detail.hh +++ b/streaming/stream_detail.hh @@ -11,7 +11,7 @@ #pragma once #include "query-request.hh" -#include "utils/UUID.hh" +#include "schema_fwd.hh" #include #include "range.hh" #include "dht/i_partitioner.hh" @@ -19,10 +19,9 @@ namespace streaming { struct stream_detail { - using UUID = utils::UUID; - UUID cf_id; + table_id cf_id; stream_detail() = default; - stream_detail(UUID cf_id_) + stream_detail(table_id cf_id_) : cf_id(std::move(cf_id_)) { } }; diff --git a/streaming/stream_manager.cc b/streaming/stream_manager.cc index c174394cbf..c843e74999 100644 --- a/streaming/stream_manager.cc +++ b/streaming/stream_manager.cc @@ -341,7 +341,7 @@ future<> stream_manager::on_dead(inet_address endpoint, endpoint_state ep_state) return make_ready_future(); } -shared_ptr stream_manager::get_session(utils::UUID plan_id, gms::inet_address from, const char* verb, std::optional cf_id) { +shared_ptr stream_manager::get_session(utils::UUID plan_id, gms::inet_address from, const char* verb, std::optional cf_id) { if (cf_id) { sslog.debug("[Stream #{}] GOT {} from {}: cf_id={}", plan_id, verb, from, *cf_id); } else { diff --git a/streaming/stream_manager.hh b/streaming/stream_manager.hh index 27a5ec5ea5..72d00d1e10 100644 --- a/streaming/stream_manager.hh +++ b/streaming/stream_manager.hh @@ -169,7 +169,7 @@ public: stream_bytes get_progress_on_local_shard() const; - shared_ptr get_session(utils::UUID plan_id, gms::inet_address from, const char* verb, std::optional cf_id = {}); + shared_ptr get_session(utils::UUID plan_id, gms::inet_address from, const char* verb, std::optional cf_id = {}); public: virtual future<> on_join(inet_address endpoint, endpoint_state ep_state) override { return make_ready_future(); } diff --git a/streaming/stream_receive_task.cc b/streaming/stream_receive_task.cc index 86d9e315fe..c3192ba7a2 100644 --- a/streaming/stream_receive_task.cc +++ b/streaming/stream_receive_task.cc @@ -13,7 +13,7 @@ namespace streaming { -stream_receive_task::stream_receive_task(shared_ptr _session, UUID _cf_id, int _total_files, long _total_size) +stream_receive_task::stream_receive_task(shared_ptr _session, table_id _cf_id, int _total_files, long _total_size) : stream_task(_session, _cf_id) , total_files(_total_files) , total_size(_total_size) { diff --git a/streaming/stream_receive_task.hh b/streaming/stream_receive_task.hh index d032c7dda0..76437f0190 100644 --- a/streaming/stream_receive_task.hh +++ b/streaming/stream_receive_task.hh @@ -28,7 +28,7 @@ private: // total size of files to receive long total_size; public: - stream_receive_task(shared_ptr _session, UUID _cf_id, int _total_files, long _total_size); + stream_receive_task(shared_ptr _session, table_id _cf_id, int _total_files, long _total_size); ~stream_receive_task(); virtual int get_total_number_of_files() const override { diff --git a/streaming/stream_session.cc b/streaming/stream_session.cc index 51ca45dfb6..723ad7ea7b 100644 --- a/streaming/stream_session.cc +++ b/streaming/stream_session.cc @@ -74,7 +74,7 @@ void stream_manager::init_messaging_service_handler() { return make_ready_future<>(); }); }); - ms.register_stream_mutation_fragments([this] (const rpc::client_info& cinfo, UUID plan_id, UUID schema_id, UUID cf_id, uint64_t estimated_partitions, rpc::optional reason_opt, rpc::source> source) { + ms.register_stream_mutation_fragments([this] (const rpc::client_info& cinfo, UUID plan_id, UUID schema_id, table_id cf_id, uint64_t estimated_partitions, rpc::optional reason_opt, rpc::source> source) { auto from = netw::messaging_service::get_source(cinfo); auto reason = reason_opt ? *reason_opt: stream_reason::unspecified; sslog.trace("Got stream_mutation_fragments from {} reason {}", from, int(reason)); @@ -163,7 +163,7 @@ void stream_manager::init_messaging_service_handler() { }); }); }); - ms.register_stream_mutation_done([this] (const rpc::client_info& cinfo, UUID plan_id, dht::token_range_vector ranges, UUID cf_id, unsigned dst_cpu_id) { + ms.register_stream_mutation_done([this] (const rpc::client_info& cinfo, UUID plan_id, dht::token_range_vector ranges, table_id cf_id, unsigned dst_cpu_id) { const auto& from = cinfo.retrieve_auxiliary("baddr"); return container().invoke_on(dst_cpu_id, [ranges = std::move(ranges), plan_id, cf_id, from] (auto& sm) mutable { auto session = sm.get_session(plan_id, from, "STREAM_MUTATION_DONE", cf_id); @@ -336,14 +336,14 @@ session_info stream_session::make_session_info() { return session_info(peer, std::move(receiving_summaries), std::move(transfer_summaries), _state); } -void stream_session::receive_task_completed(UUID cf_id) { +void stream_session::receive_task_completed(table_id cf_id) { _receivers.erase(cf_id); sslog.debug("[Stream #{}] receive task_completed: cf_id={} done, stream_receive_task.size={} stream_transfer_task.size={}", plan_id(), cf_id, _receivers.size(), _transfers.size()); maybe_completed(); } -void stream_session::transfer_task_completed(UUID cf_id) { +void stream_session::transfer_task_completed(table_id cf_id) { _transfers.erase(cf_id); sslog.debug("[Stream #{}] transfer task_completed: cf_id={} done, stream_receive_task.size={} stream_transfer_task.size={}", plan_id(), cf_id, _receivers.size(), _transfers.size()); @@ -460,7 +460,7 @@ void stream_session::add_transfer_ranges(sstring keyspace, dht::token_range_vect } } -future<> stream_session::receiving_failed(UUID cf_id) +future<> stream_session::receiving_failed(table_id cf_id) { return make_ready_future<>(); } diff --git a/streaming/stream_session.hh b/streaming/stream_session.hh index 5ff343bc07..f1f979244b 100644 --- a/streaming/stream_session.hh +++ b/streaming/stream_session.hh @@ -139,9 +139,9 @@ private: // stream requests to send to the peer std::vector _requests; // streaming tasks are created and managed per ColumnFamily ID - std::map _transfers; + std::map _transfers; // data receivers, filled after receiving prepare message - std::map _receivers; + std::map _receivers; //private final StreamingMetrics metrics; /* can be null when session is created in remote */ //private final StreamConnectionFactory factory; @@ -312,15 +312,15 @@ public: future<> update_progress(); - void receive_task_completed(UUID cf_id); - void transfer_task_completed(UUID cf_id); + void receive_task_completed(table_id cf_id); + void transfer_task_completed(table_id cf_id); void transfer_task_completed_all(); private: void send_failed_complete_message(); bool maybe_completed(); void prepare_receiving(stream_summary& summary); void start_streaming_files(); - future<> receiving_failed(UUID cf_id); + future<> receiving_failed(table_id cf_id); }; } // namespace streaming diff --git a/streaming/stream_summary.hh b/streaming/stream_summary.hh index 1496cbc93f..ffdc3fec3c 100644 --- a/streaming/stream_summary.hh +++ b/streaming/stream_summary.hh @@ -10,7 +10,7 @@ #pragma once -#include "utils/UUID.hh" +#include "schema_fwd.hh" #include namespace streaming { @@ -20,8 +20,7 @@ namespace streaming { */ class stream_summary { public: - using UUID = utils::UUID; - UUID cf_id; + table_id cf_id; /** * Number of files to transfer. Can be 0 if nothing to transfer for some streaming request. @@ -30,7 +29,7 @@ public: long total_size; stream_summary() = default; - stream_summary(UUID _cf_id, int _files, long _total_size) + stream_summary(table_id _cf_id, int _files, long _total_size) : cf_id (_cf_id) , files(_files) , total_size(_total_size) { diff --git a/streaming/stream_task.cc b/streaming/stream_task.cc index b98860e38a..cd6e06e48c 100644 --- a/streaming/stream_task.cc +++ b/streaming/stream_task.cc @@ -13,7 +13,7 @@ namespace streaming { -stream_task::stream_task(shared_ptr _session, UUID _cf_id) +stream_task::stream_task(shared_ptr _session, table_id _cf_id) : session(_session) , cf_id(std::move(_cf_id)) { } diff --git a/streaming/stream_task.hh b/streaming/stream_task.hh index 37d0eb0ca2..b9e46868e5 100644 --- a/streaming/stream_task.hh +++ b/streaming/stream_task.hh @@ -10,7 +10,7 @@ #pragma once -#include "utils/UUID.hh" +#include "schema_fwd.hh" #include "streaming/stream_summary.hh" #include #include @@ -24,13 +24,12 @@ class stream_session; */ class stream_task { public: - using UUID = utils::UUID; /** StreamSession that this task belongs */ shared_ptr session; - UUID cf_id; + table_id cf_id; - stream_task(shared_ptr _session, UUID _cf_id); + stream_task(shared_ptr _session, table_id _cf_id); virtual ~stream_task(); public: diff --git a/streaming/stream_transfer_task.cc b/streaming/stream_transfer_task.cc index 5057014f9a..6869945ad9 100644 --- a/streaming/stream_transfer_task.cc +++ b/streaming/stream_transfer_task.cc @@ -35,7 +35,7 @@ namespace streaming { extern logging::logger sslog; -stream_transfer_task::stream_transfer_task(shared_ptr session, UUID cf_id, dht::token_range_vector ranges, long total_size) +stream_transfer_task::stream_transfer_task(shared_ptr session, table_id cf_id, dht::token_range_vector ranges, long total_size) : stream_task(session, cf_id) , _ranges(std::move(ranges)) , _total_size(total_size) { @@ -46,7 +46,7 @@ stream_transfer_task::~stream_transfer_task() = default; struct send_info { netw::messaging_service& ms; utils::UUID plan_id; - utils::UUID cf_id; + table_id cf_id; netw::messaging_service::msg_addr id; uint32_t dst_cpu_id; stream_reason reason; diff --git a/streaming/stream_transfer_task.hh b/streaming/stream_transfer_task.hh index 6cb152190b..e3183307ab 100644 --- a/streaming/stream_transfer_task.hh +++ b/streaming/stream_transfer_task.hh @@ -32,9 +32,8 @@ private: long _total_size; bool _mutation_done_sent = false; public: - using UUID = utils::UUID; stream_transfer_task(stream_transfer_task&&) = default; - stream_transfer_task(shared_ptr session, UUID cf_id, dht::token_range_vector ranges, long total_size = 0); + stream_transfer_task(shared_ptr session, table_id cf_id, dht::token_range_vector ranges, long total_size = 0); ~stream_transfer_task(); public: virtual void abort() override { diff --git a/test/boost/batchlog_manager_test.cc b/test/boost/batchlog_manager_test.cc index 81a65997be..8c8c4fe98d 100644 --- a/test/boost/batchlog_manager_test.cc +++ b/test/boost/batchlog_manager_test.cc @@ -50,7 +50,7 @@ SEASTAR_TEST_CASE(test_execute_batch) { using namespace std::chrono_literals; auto version = netw::messaging_service::current_version; - auto bm = qp.proxy().get_batchlog_mutation_for({ m }, s->id(), version, db_clock::now() - db_clock::duration(3h)); + auto bm = qp.proxy().get_batchlog_mutation_for({ m }, s->id().uuid(), version, db_clock::now() - db_clock::duration(3h)); return qp.proxy().mutate_locally(bm, tracing::trace_state_ptr(), db::commitlog::force_sync::no).then([&bp] () mutable { return bp.count_all_batches().then([](auto n) { diff --git a/test/boost/column_mapping_test.cc b/test/boost/column_mapping_test.cc index 6490970b7e..ba4554c433 100644 --- a/test/boost/column_mapping_test.cc +++ b/test/boost/column_mapping_test.cc @@ -24,7 +24,7 @@ SEASTAR_TEST_CASE(test_column_mapping_persistence) { // column mapping into the history table cquery_nofail(e, "create table test (pk int PRIMARY KEY, v int)"); auto schema = e.local_db().find_schema("ks", "test"); - const utils::UUID table_id = schema->id(); + const auto table_id = schema->id(); const table_schema_version v1 = schema->version(); const column_mapping orig_cm = schema->get_column_mapping(); @@ -52,7 +52,7 @@ SEASTAR_TEST_CASE(test_column_mapping_ttl_check) { // column mapping into the history table cquery_nofail(e, "create table test (pk int PRIMARY KEY, v int)"); auto schema = e.local_db().find_schema("ks", "test"); - const utils::UUID table_id = schema->id(); + const auto table_id = schema->id(); const table_schema_version v1 = schema->version(); const sstring select_ttl_query = format( diff --git a/test/boost/commitlog_test.cc b/test/boost/commitlog_test.cc index c357652d49..b5947ed28f 100644 --- a/test/boost/commitlog_test.cc +++ b/test/boost/commitlog_test.cc @@ -70,11 +70,15 @@ static future<> cl_test(noncopyable_function (commitlog&)> f) { return cl_test(cfg, std::move(f)); } +static table_id make_table_id() { + return table_id(utils::UUID_gen::get_time_UUID()); +} + // just write in-memory... SEASTAR_TEST_CASE(test_create_commitlog){ return cl_test([](commitlog& log) { sstring tmp = "hej bubba cow"; - return log.add_mutation(utils::UUID_gen::get_time_UUID(), tmp.size(), db::commitlog::force_sync::no, [tmp](db::commitlog::output& dst) { + return log.add_mutation(make_table_id(), tmp.size(), db::commitlog::force_sync::no, [tmp](db::commitlog::output& dst) { dst.write(tmp.data(), tmp.size()); }).then([](db::replay_position rp) { BOOST_CHECK_NE(rp, db::replay_position()); @@ -88,7 +92,7 @@ SEASTAR_TEST_CASE(test_commitlog_written_to_disk_batch){ cfg.mode = commitlog::sync_mode::BATCH; return cl_test(cfg, [](commitlog& log) { sstring tmp = "hej bubba cow"; - return log.add_mutation(utils::UUID_gen::get_time_UUID(), tmp.size(), db::commitlog::force_sync::no, [tmp](db::commitlog::output& dst) { + return log.add_mutation(make_table_id(), tmp.size(), db::commitlog::force_sync::no, [tmp](db::commitlog::output& dst) { dst.write(tmp.data(), tmp.size()); }).then([&log](replay_position rp) { BOOST_CHECK_NE(rp, db::replay_position()); @@ -103,7 +107,7 @@ SEASTAR_TEST_CASE(test_commitlog_written_to_disk_sync){ commitlog::config cfg; return cl_test(cfg, [](commitlog& log) { sstring tmp = "hej bubba cow"; - return log.add_mutation(utils::UUID_gen::get_time_UUID(), tmp.size(), db::commitlog::force_sync::yes, [tmp](db::commitlog::output& dst) { + return log.add_mutation(make_table_id(), tmp.size(), db::commitlog::force_sync::yes, [tmp](db::commitlog::output& dst) { dst.write(tmp.data(), tmp.size()); }).then([&log](replay_position rp) { BOOST_CHECK_NE(rp, db::replay_position()); @@ -119,7 +123,7 @@ SEASTAR_TEST_CASE(test_commitlog_written_to_disk_no_sync){ cfg.commitlog_sync_period_in_ms = 10000000000; return cl_test(cfg, [](commitlog& log) { sstring tmp = "hej bubba cow"; - return log.add_mutation(utils::UUID_gen::get_time_UUID(), tmp.size(), db::commitlog::force_sync::no, [tmp](db::commitlog::output& dst) { + return log.add_mutation(make_table_id(), tmp.size(), db::commitlog::force_sync::no, [tmp](db::commitlog::output& dst) { dst.write(tmp.data(), tmp.size()); }).then([&log](replay_position rp) { BOOST_CHECK_NE(rp, db::replay_position()); @@ -132,7 +136,7 @@ SEASTAR_TEST_CASE(test_commitlog_written_to_disk_no_sync){ SEASTAR_TEST_CASE(test_commitlog_written_to_disk_periodic){ return cl_test([](commitlog& log) { auto state = make_lw_shared(false); - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = make_table_id(); return do_until([state]() {return *state;}, [&log, state, uuid]() { sstring tmp = "hej bubba cow"; @@ -153,7 +157,7 @@ SEASTAR_TEST_CASE(test_commitlog_new_segment){ cfg.commitlog_segment_size_in_mb = 1; return cl_test(cfg, [](commitlog& log) { return do_with(rp_set(), [&log](auto& set) { - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = make_table_id(); return do_until([&set]() { return set.size() > 1; }, [&log, &set, uuid]() { sstring tmp = "hej bubba cow"; return log.add_mutation(uuid, tmp.size(), db::commitlog::force_sync::no, [tmp](db::commitlog::output& dst) { @@ -189,17 +193,17 @@ SEASTAR_TEST_CASE(test_commitlog_discard_completed_segments){ cfg.commitlog_segment_size_in_mb = 1; return cl_test(cfg, [](commitlog& log) { struct state_type { - std::vector uuids; - std::unordered_map rps; + std::vector uuids; + std::unordered_map rps; mutable size_t index = 0; state_type() { for (int i = 0; i < 10; ++i) { - uuids.push_back(utils::UUID_gen::get_time_UUID()); + uuids.push_back(make_table_id()); } } - const utils::UUID & next_uuid() const { + const table_id& next_uuid() const { return uuids[index++ % uuids.size()]; } bool done() const { @@ -250,7 +254,7 @@ SEASTAR_TEST_CASE(test_commitlog_discard_completed_segments){ SEASTAR_TEST_CASE(test_equal_record_limit){ return cl_test([](commitlog& log) { auto size = log.max_record_size(); - return log.add_mutation(utils::UUID_gen::get_time_UUID(), size, db::commitlog::force_sync::no, [size](db::commitlog::output& dst) { + return log.add_mutation(make_table_id(), size, db::commitlog::force_sync::no, [size](db::commitlog::output& dst) { dst.fill(char(1), size); }).then([](db::replay_position rp) { BOOST_CHECK_NE(rp, db::replay_position()); @@ -261,7 +265,7 @@ SEASTAR_TEST_CASE(test_equal_record_limit){ SEASTAR_TEST_CASE(test_exceed_record_limit){ return cl_test([](commitlog& log) { auto size = log.max_record_size() + 1; - return log.add_mutation(utils::UUID_gen::get_time_UUID(), size, db::commitlog::force_sync::no, [size](db::commitlog::output& dst) { + return log.add_mutation(make_table_id(), size, db::commitlog::force_sync::no, [size](db::commitlog::output& dst) { dst.fill(char(1), size); }).then_wrapped([](future f) { try { @@ -280,7 +284,7 @@ SEASTAR_TEST_CASE(test_commitlog_closed) { return cl_test(cfg, [](commitlog& log) { return log.shutdown().then([&log] { sstring tmp = "test321"; - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = make_table_id(); return log.add_mutation(uuid, tmp.size(), db::commitlog::force_sync::no, [tmp](db::commitlog::output& dst) { dst.write(tmp.data(), tmp.size()); }).then_wrapped([] (future f) { @@ -323,7 +327,7 @@ SEASTAR_TEST_CASE(test_commitlog_delete_when_over_disk_limit) { }); auto set = make_lw_shared>(); - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = make_table_id(); return do_until([set, sem]() {return set->size() > 2 && sem->try_wait();}, [&log, set, uuid]() { sstring tmp = "hej bubba cow"; @@ -367,7 +371,7 @@ SEASTAR_TEST_CASE(test_commitlog_reader){ auto set = make_lw_shared(); auto count = make_lw_shared(0); auto count2 = make_lw_shared(0); - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = make_table_id(); return do_until([count, set]() {return set->size() > 1;}, [&log, uuid, count, set]() { sstring tmp = "hej bubba cow"; @@ -435,7 +439,7 @@ SEASTAR_TEST_CASE(test_commitlog_entry_corruption){ auto rps = make_lw_shared>(); return do_until([rps]() {return rps->size() > 1;}, [&log, rps]() { - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = make_table_id(); sstring tmp = "hej bubba cow"; return log.add_mutation(uuid, tmp.size(), db::commitlog::force_sync::no, [tmp](db::commitlog::output& dst) { dst.write(tmp.data(), tmp.size()); @@ -475,7 +479,7 @@ SEASTAR_TEST_CASE(test_commitlog_chunk_corruption){ auto rps = make_lw_shared>(); return do_until([rps]() {return rps->size() > 1;}, [&log, rps]() { - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = make_table_id(); sstring tmp = "hej bubba cow"; return log.add_mutation(uuid, tmp.size(), db::commitlog::force_sync::no, [tmp](db::commitlog::output& dst) { dst.write(tmp.data(), tmp.size()); @@ -514,7 +518,7 @@ SEASTAR_TEST_CASE(test_commitlog_reader_produce_exception){ auto rps = make_lw_shared>(); return do_until([rps]() {return rps->size() > 1;}, [&log, rps]() { - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = make_table_id(); sstring tmp = "hej bubba cow"; return log.add_mutation(uuid, tmp.size(), db::commitlog::force_sync::no, [tmp](db::commitlog::output& dst) { dst.write(tmp.data(), tmp.size()); @@ -579,7 +583,7 @@ SEASTAR_TEST_CASE(test_allocation_failure){ } auto last = junk->end(); junk->erase(--last); - return log.add_mutation(utils::UUID_gen::get_time_UUID(), size, db::commitlog::force_sync::no, [size](db::commitlog::output& dst) { + return log.add_mutation(make_table_id(), size, db::commitlog::force_sync::no, [size](db::commitlog::output& dst) { dst.fill(char(1), size); }).then_wrapped([junk, size](future f) { std::exception_ptr ep; @@ -718,7 +722,7 @@ SEASTAR_TEST_CASE(test_commitlog_new_segment_odsync){ cfg.use_o_dsync = true; return cl_test(cfg, [](commitlog& log) -> future<> { - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = make_table_id(); rp_set set; while (set.size() <= 1) { sstring tmp = "hej bubba cow"; @@ -769,7 +773,7 @@ SEASTAR_TEST_CASE(test_commitlog_deadlock_in_recycle) { // uncomment for verbosity // logging::logger_registry().set_logger_level("commitlog", logging::log_level::debug); - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = make_table_id(); auto size = log.max_record_size() / 2; timer<> t; @@ -844,7 +848,7 @@ SEASTAR_TEST_CASE(test_commitlog_shutdown_during_wait) { // uncomment for verbosity //logging::logger_registry().set_logger_level("commitlog", logging::log_level::debug); - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = make_table_id(); auto size = log.max_record_size() / 2; // add a flush handler that does not. @@ -909,7 +913,7 @@ SEASTAR_TEST_CASE(test_commitlog_deadlock_with_flush_threshold) { // uncomment for verbosity // logging::logger_registry().set_logger_level("commitlog", logging::log_level::debug); - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = make_table_id(); auto size = log.max_record_size(); bool done = false; @@ -998,7 +1002,7 @@ static future<> do_test_exception_in_allocate_ex(bool do_file_delete) { // uncomment for verbosity // logging::logger_registry().set_logger_level("commitlog", logging::log_level::debug); - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = make_table_id(); auto size = log.max_record_size(); auto r = log.add_flush_handler([&](cf_id_type id, replay_position pos) { diff --git a/test/boost/database_test.cc b/test/boost/database_test.cc index fad43e4e39..f325a50495 100644 --- a/test/boost/database_test.cc +++ b/test/boost/database_test.cc @@ -54,7 +54,7 @@ public: } }; -static future<> apply_mutation(sharded& sharded_db, utils::UUID uuid, const mutation& m, bool do_flush = false, +static future<> apply_mutation(sharded& sharded_db, table_id uuid, const mutation& m, bool do_flush = false, db::commitlog::force_sync fs = db::commitlog::force_sync::no, db::timeout_clock::time_point timeout = db::no_timeout) { auto shard = m.shard_of(); return sharded_db.invoke_on(shard, [uuid, fm = freeze(m), do_flush, fs, timeout] (replica::database& db) { diff --git a/test/lib/cql_test_env.cc b/test/lib/cql_test_env.cc index 3c7c0300e4..e3dd180f39 100644 --- a/test/lib/cql_test_env.cc +++ b/test/lib/cql_test_env.cc @@ -284,7 +284,7 @@ public: } virtual future<> create_table(std::function schema_maker) override { - auto id = utils::UUID_gen::get_time_UUID(); + auto id = table_id(utils::UUID_gen::get_time_UUID()); schema_builder builder(make_lw_shared(schema_maker(ks_name))); builder.set_uuid(id); auto s = builder.build(schema_builder::compact_storage::no); diff --git a/test/manual/hint_test.cc b/test/manual/hint_test.cc index b85e2c09a4..ccee8d788b 100644 --- a/test/manual/hint_test.cc +++ b/test/manual/hint_test.cc @@ -55,7 +55,7 @@ SEASTAR_TEST_CASE(test_commitlog_new_segment_custom_prefix){ cfg.commitlog_segment_size_in_mb = 1; return cl_test(cfg, [](commitlog& log) { return do_with(rp_set(), [&log](auto& set) { - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = table_id(utils::UUID_gen::get_time_UUID()); return do_until([&set]() { return set.size() > 1; }, [&log, &set, uuid]() { sstring tmp = "hej bubba cow"; return log.add_mutation(uuid, tmp.size(), db::commitlog::force_sync::no, [tmp](db::commitlog::output& dst) { diff --git a/test/perf/perf_commitlog.cc b/test/perf/perf_commitlog.cc index c99f76ebbc..8f4bfff807 100644 --- a/test/perf/perf_commitlog.cc +++ b/test/perf/perf_commitlog.cc @@ -136,7 +136,7 @@ struct commitlog_service { }; static std::vector do_commitlog_test(distributed& cls, test_config& cfg) { - auto uuid = utils::UUID_gen::get_time_UUID(); + auto uuid = table_id(utils::UUID_gen::get_time_UUID()); return time_parallel_ex([&] { auto& log = cls.local(); diff --git a/thrift/handler.cc b/thrift/handler.cc index 6843959058..cfbbcb7e44 100644 --- a/thrift/handler.cc +++ b/thrift/handler.cc @@ -1310,7 +1310,7 @@ private: } return {}; } - static schema_ptr schema_from_thrift(const CfDef& cf_def, const sstring ks_name, std::optional id = { }) { + static schema_ptr schema_from_thrift(const CfDef& cf_def, const sstring ks_name, std::optional id = { }) { thrift_validation::validate_cf_def(cf_def); schema_builder builder(ks_name, cf_def.name, id); schema_builder::default_names names(builder); diff --git a/tombstone_gc.cc b/tombstone_gc.cc index a1c5138ce3..7c9ca16103 100644 --- a/tombstone_gc.cc +++ b/tombstone_gc.cc @@ -27,9 +27,9 @@ public: boost::icl::interval_map map; }; -thread_local std::unordered_map> repair_history_maps; +thread_local std::unordered_map> repair_history_maps; -static seastar::lw_shared_ptr get_or_create_repair_history_map_for_table(const utils::UUID& id) { +static seastar::lw_shared_ptr get_or_create_repair_history_map_for_table(const table_id& id) { auto it = repair_history_maps.find(id); if (it != repair_history_maps.end()) { return it->second; @@ -39,7 +39,7 @@ static seastar::lw_shared_ptr get_or_create_repair_history_m } } -seastar::lw_shared_ptr get_repair_history_map_for_table(const utils::UUID& id) { +seastar::lw_shared_ptr get_repair_history_map_for_table(const table_id& id) { auto it = repair_history_maps.find(id); if (it != repair_history_maps.end()) { return it->second; @@ -48,7 +48,7 @@ seastar::lw_shared_ptr get_repair_history_map_for_table(cons } } -void drop_repair_history_map_for_table(const utils::UUID& id) { +void drop_repair_history_map_for_table(const table_id& id) { repair_history_maps.erase(id); } diff --git a/tombstone_gc.hh b/tombstone_gc.hh index ecb69a81ad..18f2a42a57 100644 --- a/tombstone_gc.hh +++ b/tombstone_gc.hh @@ -41,7 +41,7 @@ namespace replica { class database; } -void drop_repair_history_map_for_table(const utils::UUID& id); +void drop_repair_history_map_for_table(const table_id& id); get_gc_before_for_range_result get_gc_before_for_range(schema_ptr s, const dht::token_range& range, const gc_clock::time_point& query_time); diff --git a/tools/schema_loader.cc b/tools/schema_loader.cc index e86e02d998..f29013a770 100644 --- a/tools/schema_loader.cc +++ b/tools/schema_loader.cc @@ -109,7 +109,7 @@ private: } return wrap(*it); } - virtual std::optional try_find_table(data_dictionary::database db, utils::UUID id) const override { + virtual std::optional try_find_table(data_dictionary::database db, table_id id) const override { auto& tables = unwrap(db).tables; auto it = std::find_if(tables.begin(), tables.end(), [id] (const table& tbl) { return tbl.schema->id() == id; }); if (it == tables.end()) { diff --git a/utils/UUID.hh b/utils/UUID.hh index 3965314229..b28be0d5e8 100644 --- a/utils/UUID.hh +++ b/utils/UUID.hh @@ -238,6 +238,10 @@ struct tagged_uuid { const utils::UUID& uuid() const noexcept { return id; } + + sstring to_sstring() const { + return id.to_sstring(); + } }; } // namespace utils diff --git a/view_info.hh b/view_info.hh index bc2a3f5cda..45d1817cb4 100644 --- a/view_info.hh +++ b/view_info.hh @@ -31,7 +31,7 @@ public: return _raw; } - const utils::UUID& base_id() const { + const table_id& base_id() const { return _raw.base_id(); }