MDEV-27791: Create a new MyRocks parameter rocksdb_log_dir

Parameter rocksdb_log_dir specifies the path of MyRocks error logs.

By default, the error logs are stored in the same folder with MyRocks
redo logs. Being able to put human readable logs in one place and
machine logs in another place improves usability.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
This commit is contained in:
Xinyi Hong 2022-01-19 23:40:41 +00:00 committed by Daniel Black
parent ef8d203a31
commit 1ac87d6dd4
7 changed files with 47 additions and 1 deletions

View File

@ -600,6 +600,7 @@ static unsigned long // NOLINT(runtime/int)
rocksdb_persistent_cache_size_mb;
static ulong rocksdb_info_log_level;
static char *rocksdb_wal_dir;
static char *rocksdb_log_dir;
static char *rocksdb_persistent_cache_path;
static ulong rocksdb_index_type;
static uint32_t rocksdb_flush_log_at_trx_commit;
@ -1316,6 +1317,11 @@ static MYSQL_SYSVAR_STR(wal_dir, rocksdb_wal_dir,
"DBOptions::wal_dir for RocksDB", nullptr, nullptr,
rocksdb_db_options->wal_dir.c_str());
static MYSQL_SYSVAR_STR(log_dir, rocksdb_log_dir,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::db_log_dir for RocksDB", nullptr, nullptr,
rocksdb_db_options->db_log_dir.c_str());
static MYSQL_SYSVAR_STR(
persistent_cache_path, rocksdb_persistent_cache_path,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
@ -2041,6 +2047,7 @@ static struct st_mysql_sys_var *rocksdb_system_variables[] = {
MYSQL_SYSVAR(max_total_wal_size),
MYSQL_SYSVAR(use_fsync),
MYSQL_SYSVAR(wal_dir),
MYSQL_SYSVAR(log_dir),
MYSQL_SYSVAR(persistent_cache_path),
MYSQL_SYSVAR(persistent_cache_size_mb),
MYSQL_SYSVAR(delete_obsolete_files_period_micros),
@ -5381,7 +5388,7 @@ static int rocksdb_init_func(void *const p) {
rocksdb::NewGenericRateLimiter(rocksdb_rate_limiter_bytes_per_sec));
rocksdb_db_options->rate_limiter = rocksdb_rate_limiter;
}
rocksdb_db_options->db_log_dir = rocksdb_log_dir;
rocksdb_db_options->delayed_write_rate = rocksdb_delayed_write_rate;
std::shared_ptr<Rdb_logger> myrocks_logger = std::make_shared<Rdb_logger>();

View File

@ -942,6 +942,7 @@ rocksdb_keep_log_file_num 1000
rocksdb_large_prefix OFF
rocksdb_lock_scanned_rows OFF
rocksdb_lock_wait_timeout 1
rocksdb_log_dir
rocksdb_log_file_time_to_roll 0
rocksdb_manifest_preallocation_size 4194304
rocksdb_manual_compaction_threads 0

View File

@ -0,0 +1,8 @@
CREATE DATABASE mysqltest;
USE mysqltest;
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES(42);
DROP TABLE t1;
DROP DATABASE mysqltest;
Check for MyRocks info LOG files
db_LOG

View File

@ -0,0 +1,2 @@
--plugin-load=$HA_ROCKSDB_SO --default-storage-engine=rocksdb --rocksdb_log_dir=$MYSQL_TMP_DIR

View File

@ -0,0 +1,15 @@
--source include/have_rocksdb.inc
CREATE DATABASE mysqltest;
USE mysqltest;
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES(42);
DROP TABLE t1;
DROP DATABASE mysqltest;
--echo Check for MyRocks info LOG files
--replace_regex /.*LOG/db_LOG/
--list_files $MYSQL_TMP_DIR *LOG
# Clean up
remove_files_wildcard $MYSQL_TMP_DIR *LOG;

View File

@ -0,0 +1,7 @@
SET @start_global_value = @@global.ROCKSDB_LOG_DIR;
SELECT @start_global_value;
@start_global_value
"Trying to set variable @@global.ROCKSDB_LOG_DIR to 444. It should fail because it is readonly."
SET @@global.ROCKSDB_LOG_DIR = 444;
ERROR HY000: Variable 'rocksdb_log_dir' is a read only variable

View File

@ -0,0 +1,6 @@
--source include/have_rocksdb.inc
--let $sys_var=ROCKSDB_LOG_DIR
--let $read_only=1
--let $session=0
--source include/rocksdb_sys_var.inc