From ca0a0f14580b72da41ecb9105c8494dc34220a86 Mon Sep 17 00:00:00 2001 From: Vlad Zolotarov Date: Wed, 11 Jan 2017 11:55:25 -0500 Subject: [PATCH] tracing::trace_keyspace_helper: use generate_legacy_id() for CF IDs generation Explicitly generate tables' IDs of tables from the system_traces KS using generate_legacy_id() in order to ensure all Nodes create these tables with the same IDs. This is going to prevent hitting issue #420. Fixes #1976 Signed-off-by: Vlad Zolotarov Message-Id: <1484153725-31030-1-git-send-email-vladz@scylladb.com> --- tracing/trace_keyspace_helper.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tracing/trace_keyspace_helper.cc b/tracing/trace_keyspace_helper.cc index ca72f49e8a..e69ee10fba 100644 --- a/tracing/trace_keyspace_helper.cc +++ b/tracing/trace_keyspace_helper.cc @@ -118,11 +118,27 @@ future<> trace_keyspace_helper::setup_table(const sstring& name, const sstring& return make_ready_future<>(); } + ::shared_ptr parsed = static_pointer_cast< + cql3::statements::raw::cf_statement>(cql3::query_processor::parse_statement(cql)); + parsed->prepare_keyspace(KEYSPACE_NAME); + ::shared_ptr statement = + static_pointer_cast( + parsed->prepare(db, qp.get_cql_stats())->statement); + auto schema = statement->get_cf_meta_data(); + + // Generate the CF UUID based on its KF names. This is needed to ensure that + // all Nodes that create it would create it with the same UUID and we don't + // hit the #420 issue. + auto uuid = generate_legacy_id(schema->ks_name(), schema->cf_name()); + + schema_builder b(schema); + b.set_uuid(uuid); + // We don't care it it fails really - this may happen due to concurrent // "CREATE TABLE" invocation on different Nodes. // The important thing is that it will converge eventually (some traces may // be lost in a process but that's ok). - return qp.process(cql, db::consistency_level::ONE).discard_result().handle_exception([this] (auto ep) {}); + return service::get_local_migration_manager().announce_new_column_family(b.build(), false).discard_result().handle_exception([this] (auto ep) {});; } bool trace_keyspace_helper::cache_sessions_table_handles(const schema_ptr& schema) {