mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-20 00:20:47 +00:00
We want to switch system.scylla_local table to the schema commitlog, but load phases hamper here - schema commitlog is initialized after phase1, so a table which is using it should be moved to phase2, but system.scylla_local contains features, and we need them before schema commitlog initialization for SCHEMA_COMMITLOG feature. In this commit we are taking a different approach to loading system tables. First, we load them all in one pass in 'readonly' mode. In this mode, the table cannot be written to and has not yet been assigned a commit log. To achieve this we've added _readonly bool field to the table class, it's initialized to true in table's constructor. In addition, we changed the table constructor to always assign nullptr to commitlog, and we trigger an internal error if table.commitlog() property is accessed while the table is in readonly mode. Then, after triggering on_system_tables_loaded notifications on feature_service and sstable_format_selector, we call system_keyspace::mark_writable and eventually table::mark_ready_for_writes which selects the proper commitlog and marks the table as writable. In sstable_compaction_test we drop several mark_ready_for_writes calls since they are redundant, the table has already been made writable in env.make_table_for_tests call. The table::commitlog function either returns the current commitlog or causes an error if the table is readonly. This didn't work for virtual tables, since they never called mark_ready_for_writes. In this commit we add this call to initialize_virtual_tables.
104 lines
3.7 KiB
C++
104 lines
3.7 KiB
C++
/*
|
|
* Copyright (C) 2018-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
#include <seastar/core/future.hh>
|
|
#include <seastar/core/distributed.hh>
|
|
#include <seastar/core/sstring.hh>
|
|
#include <seastar/core/file.hh>
|
|
#include <seastar/util/bool_class.hh>
|
|
#include <vector>
|
|
#include <functional>
|
|
#include <filesystem>
|
|
#include "seastarx.hh"
|
|
#include "compaction/compaction_descriptor.hh"
|
|
#include "db/system_keyspace.hh"
|
|
#include "sstables/sstable_directory.hh"
|
|
|
|
namespace replica {
|
|
class database;
|
|
class table;
|
|
using column_family = table;
|
|
}
|
|
|
|
namespace db {
|
|
class config;
|
|
class system_distributed_keyspace;
|
|
class system_keyspace;
|
|
namespace view {
|
|
class view_update_generator;
|
|
}
|
|
}
|
|
|
|
namespace sstables {
|
|
|
|
class entry_descriptor;
|
|
class foreign_sstable_open_info;
|
|
|
|
}
|
|
|
|
namespace service {
|
|
|
|
class storage_proxy;
|
|
|
|
}
|
|
|
|
namespace locator {
|
|
class effective_replication_map_factory;
|
|
}
|
|
|
|
class distributed_loader_for_tests;
|
|
|
|
namespace replica {
|
|
|
|
class table_populator;
|
|
|
|
class distributed_loader {
|
|
friend class ::distributed_loader_for_tests;
|
|
friend class table_populator;
|
|
|
|
static future<> reshape(sharded<sstables::sstable_directory>& dir, sharded<replica::database>& db, sstables::reshape_mode mode,
|
|
sstring ks_name, sstring table_name, sstables::compaction_sstable_creator_fn creator, std::function<bool (const sstables::shared_sstable&)> filter);
|
|
static future<> reshard(sharded<sstables::sstable_directory>& dir, sharded<replica::database>& db, sstring ks_name, sstring table_name, sstables::compaction_sstable_creator_fn creator,
|
|
compaction::owned_ranges_ptr owned_ranges_ptr = nullptr);
|
|
static future<> process_sstable_dir(sharded<sstables::sstable_directory>& dir, sstables::sstable_directory::process_flags flags);
|
|
static future<> lock_table(sharded<sstables::sstable_directory>& dir, sharded<replica::database>& db, sstring ks_name, sstring cf_name);
|
|
static future<size_t> make_sstables_available(sstables::sstable_directory& dir,
|
|
sharded<replica::database>& db, sharded<db::view::view_update_generator>& view_update_generator,
|
|
bool needs_view_update, sstring ks, sstring cf);
|
|
static future<> populate_keyspace(distributed<replica::database>& db, sstring datadir, sstring ks_name);
|
|
|
|
public:
|
|
static future<> init_system_keyspace(sharded<db::system_keyspace>&, distributed<locator::effective_replication_map_factory>&, distributed<replica::database>&);
|
|
static future<> init_non_system_keyspaces(distributed<replica::database>& db, distributed<service::storage_proxy>& proxy, sharded<db::system_keyspace>& sys_ks);
|
|
|
|
/**
|
|
* Marks a keyspace (by name) as "prioritized" on bootstrap.
|
|
* This will effectively let it bypass concurrency control.
|
|
* The only real use for this is to avoid certain chicken and
|
|
* egg issues.
|
|
*
|
|
* May only be called pre-bootstrap on main shard.
|
|
* Required for enterprise. Do _not_ remove.
|
|
*/
|
|
static void mark_keyspace_as_load_prio(const sstring&);
|
|
|
|
// Scan sstables under upload directory. Return a vector with smp::count entries.
|
|
// 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<std::tuple<table_id, std::vector<std::vector<sstables::shared_sstable>>>>
|
|
get_sstables_from_upload_dir(distributed<replica::database>& db, sstring ks, sstring cf, sstables::sstable_open_config cfg);
|
|
static future<> process_upload_dir(distributed<replica::database>& db, distributed<db::system_distributed_keyspace>& sys_dist_ks,
|
|
distributed<db::view::view_update_generator>& view_update_generator, sstring ks_name, sstring cf_name);
|
|
};
|
|
|
|
}
|