Files
scylladb/replica/global_table_ptr.hh
Marcin Maliszkiewicz c2cd02272a replica: db: split drop_table into steps
This is done so that actual dropping can be
an atomic step which could be composed with other
schema operations, and eventually all subsystems modified
via raft so that we could introduce atomic changes which
span across different subsystems.

We split drop_table_on_all_shards() into:
- prepare_tables_metadata_change_on_all_shards()
- prepare_drop_table_on_all_shards()
- drop_table()
- cleanup_drop_table_on_all_shards()

prepare_tables_metadata_change_on_all_shards() is necessary
because when applying multiple schema changes at once (e.g. drop
and add tables) we need to lock only once.

We add legacy_drop_table_on_all_shards() which
behaves exactly like old drop_table_on_all_shards() to be
compatible with code which doesn't need to play with atomicity.

Usages of legacy_drop_table_on_all_shards() in schema_applier
will be replaced with direct calls to split functions in the following
commits - that's the place we will take advantage of drop_table not
yielding (as it returns void now).
2025-07-10 10:40:43 +02:00

41 lines
1.2 KiB
C++

/*
* Copyright (C) 2023-present ScyllaDB
*/
/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
*/
#pragma once
#include <seastar/core/sharded.hh>
#include <seastar/core/shared_ptr.hh>
#include "schema/schema_fwd.hh"
namespace replica {
class database;
class table;
class global_table_ptr {
std::vector<foreign_ptr<lw_shared_ptr<table>>> _p;
std::vector<foreign_ptr<lw_shared_ptr<table>>> _base; // relevant if _p is view or index
std::vector<foreign_ptr<std::unique_ptr<std::vector<lw_shared_ptr<table>>>>> _views;
public:
global_table_ptr();
global_table_ptr(global_table_ptr&&) noexcept = default;
void assign(database& db, table_id uuid);
table* operator->() const noexcept;
table& operator*() const noexcept;
std::vector<lw_shared_ptr<table>>& views() const noexcept;
void clear_views() noexcept;
table& base() const noexcept;
auto as_sharded_parameter() {
return sharded_parameter([this] { return std::ref(**this); });
}
};
future<global_table_ptr> get_table_on_all_shards(sharded<database>& db, table_id uuid);
future<global_table_ptr> get_table_on_all_shards(sharded<database>& db, sstring ks_name, sstring cf_name);
} // replica namespace