Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move MyRocks sysvars to sysvars.cc and sysvars.h #1499

Open
wants to merge 2 commits into
base: fb-mysql-8.0.32
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions mysql-test/r/mysqld--help-notwin.result
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@ The following options may be given as the first argument:
to the binlog. Default: 1 hour
--rocksdb-binlog-ttl-compaction-ts-offset-secs=#
Offset in seconds which is subtracted from the compaction
ts when it's written to the binlogDefault: 60s
ts when it's written to the binlog. Default: 60s
--rocksdb-blind-delete-primary-key
Deleting rows by primary key lookup, without reading rows
(Blind Deletes). Blind delete is disabled if the table
Expand Down Expand Up @@ -2355,7 +2355,7 @@ The following options may be given as the first argument:
--rocksdb-info-log-level=name
Filter level for info logs to be written mysqld error
log. Valid values include 'debug_level', 'info_level',
'warn_level''error_level' and 'fatal_level'.
'warn_level', 'error_level' and 'fatal_level'.
--rocksdb-invalid-create-option-action=name
Control behavior when creating the table hits some error.
We can log the error only, pass the query and give users
Expand Down Expand Up @@ -2429,9 +2429,9 @@ The following options may be given as the first argument:
--rocksdb-max-file-opening-threads=#
DBOptions::max_file_opening_threads for RocksDB
--rocksdb-max-intrinsic-tmp-table-write-count=#
Intrinsic tmp table max allowed write batch size.After
Intrinsic tmp table max allowed write batch size. After
this, current transaction holding write batch will commit
and newtransaction will be started.
and new transaction will be started.
--rocksdb-max-latest-deadlocks=#
Maximum number of recent deadlocks to store
--rocksdb-max-log-file-size=#
Expand Down Expand Up @@ -2465,7 +2465,7 @@ The following options may be given as the first argument:
once when index creation is complete can cause trim
stalls on Flash. This variable specifies a duration to
sleep (in milliseconds) between calling chsize() to
truncate the file in chunks. The chunk size is the same
truncate the file in chunks. The chunk size is the same
as merge_buf_size.
--rocksdb-mrr-batch-size=#
maximum number of keys to fetch during each MRR
Expand Down
1 change: 1 addition & 0 deletions storage/rocksdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ SET(ROCKSDB_SE_SOURCES
rdb_vector_db.cc rdb_vector_db.h
rdb_bulk_load.cc rdb_bulk_load.h
clone/common.h clone/common.cc clone/donor.h clone/donor.cc clone/client.cc
sysvars.h sysvars.cc
)

IF(WITH_FB_TSAN OR ROCKSDB_DYNAMIC_PLUGIN)
Expand Down
25 changes: 14 additions & 11 deletions storage/rocksdb/clone/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "sql/sql_class.h"

#include "../ha_rocksdb.h"
#include "../sysvars.h"

namespace {

Expand Down Expand Up @@ -179,7 +180,9 @@ std::atomic<std::uint64_t> locator::m_next_id{1};

std::atomic<uint> session::m_next_task_id{session::m_main_task_id + 1};

std::string checkpoint_base_dir() { return std::string{rocksdb_datadir}; }
std::string checkpoint_base_dir() {
return std::string{sysvars::rocksdb_datadir};
}

[[nodiscard]] bool remove_dir(const std::string &dir, bool fatal_error) {
LogPluginErrMsg(INFORMATION_LEVEL, ER_LOG_PRINTF_MSG, "Removing %s",
Expand Down Expand Up @@ -231,31 +234,31 @@ void fixup_on_startup() {
}

const auto current_datadir_in_progress_marker_path =
rdb_concat_paths(rocksdb_datadir, in_progress_marker_file);
rdb_concat_paths(sysvars::rocksdb_datadir, in_progress_marker_file);
if (path_exists(current_datadir_in_progress_marker_path))
rdb_fatal_error("In-progress clone marker found in the MyRocks datadir");

// Enable sst file checksum verification if
// CHECKSUMS_WRITE_AND_VERIFY_ON_CLONE flag is enabled and this restart is
// after a clone.
if (myrocks::rocksdb_file_checksums ==
myrocks::file_checksums_type::CHECKSUMS_WRITE_AND_VERIFY_ON_CLONE &&
if (sysvars::file_checksums ==
sysvars::file_checksums_type::CHECKSUMS_WRITE_AND_VERIFY_ON_CLONE &&
temp_dir_exists_abort_if_not_dir(in_place_temp_datadir)) {
myrocks::rocksdb_file_checksums =
myrocks::file_checksums_type::CHECKSUMS_WRITE_AND_VERIFY;
sysvars::file_checksums =
sysvars::file_checksums_type::CHECKSUMS_WRITE_AND_VERIFY;
}

move_temp_dir_to_destination(in_place_temp_datadir, in_place_old_datadir,
rocksdb_datadir);
sysvars::rocksdb_datadir);

if (is_wal_dir_separate()) {
move_temp_dir_contents_to_dest(in_place_temp_wal_dir, rocksdb_wal_dir);
if (sysvars::is_wal_dir_separate()) {
move_temp_dir_contents_to_dest(in_place_temp_wal_dir, sysvars::wal_dir);
} else if (path_exists(in_place_temp_wal_dir)) {
for_each_in_dir(in_place_temp_wal_dir, MY_FAE, [](const fileinfo &f_info) {
const auto fn = std::string_view{f_info.name};

const auto old_log_path = rdb_concat_paths(in_place_temp_wal_dir, fn);
const auto new_log_path = rdb_concat_paths(rocksdb_datadir, fn);
const auto new_log_path = rdb_concat_paths(sysvars::rocksdb_datadir, fn);
myrocks::rdb_path_rename_or_abort(old_log_path, new_log_path);
return true;
});
Expand Down Expand Up @@ -304,7 +307,7 @@ void fixup_on_startup() {
const auto is_sst = has_file_extension(file_name, ".sst"sv);
if (!is_sst) return false;

const auto &rdb_opts = *myrocks::get_rocksdb_db_options();
const auto &rdb_opts = myrocks::get_rocksdb_db_options();
switch (mode) {
case mode_for_direct_io::DONOR:
return rdb_opts.use_direct_reads;
Expand Down
14 changes: 8 additions & 6 deletions storage/rocksdb/clone/donor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
// MyRocks includes
#include "../ha_rocksdb.h"
#include "../ha_rocksdb_proto.h"
#include "../sysvars.h"
#include "common.h"

using namespace std::string_view_literals;
Expand Down Expand Up @@ -480,20 +481,21 @@ class [[nodiscard]] donor final : public myrocks::clone::session {
assert(m_state != donor_state::INITIAL);
assert(m_checkpoint_count > 0);

const auto checkpoint_max_age = myrocks::sysvars::clone_checkpoint_max_age;
if (m_state == donor_state::FINAL_CHECKPOINT ||
m_state == donor_state::FINAL_CHECKPOINT_WITH_LOGS ||
myrocks::rocksdb_clone_checkpoint_max_age == 0)
checkpoint_max_age == 0)
return false;

assert(m_state == donor_state::ROLLING_CHECKPOINT);
if (myrocks::rocksdb_clone_checkpoint_max_count != 0 &&
m_checkpoint_count >= myrocks::rocksdb_clone_checkpoint_max_count)
const auto checkpoint_max_count =
myrocks::sysvars::clone_checkpoint_max_count;
if (checkpoint_max_count != 0 && m_checkpoint_count >= checkpoint_max_count)
return false;

const auto checkpoint_age =
std::chrono::steady_clock::now() - m_checkpoint_start_time;
const std::chrono::seconds max_age{
myrocks::rocksdb_clone_checkpoint_max_age};
const std::chrono::seconds max_age{checkpoint_max_age};
return checkpoint_age >= max_age;
}

Expand Down Expand Up @@ -543,7 +545,7 @@ class [[nodiscard]] donor final : public myrocks::clone::session {
assert(m_state != donor_state::INITIAL);

return myrocks::has_file_extension(fn, ".log"sv)
? myrocks::rdb_concat_paths(myrocks::get_wal_dir(), fn)
? myrocks::rdb_concat_paths(myrocks::sysvars::get_wal_dir(), fn)
: m_checkpoint.path(fn);
}

Expand Down
5 changes: 3 additions & 2 deletions storage/rocksdb/event_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "./ha_rocksdb_proto.h"
#include "./properties_collector.h"
#include "./rdb_datadic.h"
#include "sysvars.h"

namespace myrocks {

Expand Down Expand Up @@ -63,7 +64,7 @@ void Rdb_event_listener::update_index_stats(
//
// This lag is acceptable now and we will change when it becomes
// an issue.
if (rdb_is_table_scan_index_stats_calculation_enabled()) {
if (sysvars::is_table_scan_index_stats_calculation_enabled()) {
return;
}

Expand All @@ -83,7 +84,7 @@ void Rdb_event_listener::OnCompactionCompleted(
assert(db != nullptr);
assert(m_ddl_manager != nullptr);

if (rdb_is_table_scan_index_stats_calculation_enabled()) {
if (sysvars::is_table_scan_index_stats_calculation_enabled()) {
return;
}

Expand Down
Loading