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

Add env_uri to define a plugin as a string #4914

Open
wants to merge 1 commit into
base: 8.0
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions storage/rocksdb/ha_rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ static uint32_t rocksdb_validate_tables = 1;
// ROCKSDB_INCLUDE_VALIDATE_TABLES
static char *rocksdb_datadir = nullptr;
static char *rocksdb_fs_uri;
static char *rocksdb_env_uri;
static uint32_t rocksdb_max_bottom_pri_background_compactions = 0;
static uint32_t rocksdb_table_stats_sampling_pct =
RDB_DEFAULT_TBL_STATS_SAMPLE_PCT;
Expand Down Expand Up @@ -2204,6 +2205,11 @@ static MYSQL_SYSVAR_STR(fs_uri, rocksdb_fs_uri,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
"Custom filesystem URI", nullptr, nullptr, nullptr);

static MYSQL_SYSVAR_STR(env_uri, rocksdb_env_uri,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
"RocksDB plugin for different environment", nullptr,
nullptr, nullptr);

static MYSQL_SYSVAR_UINT(
table_stats_sampling_pct, rocksdb_table_stats_sampling_pct,
PLUGIN_VAR_RQCMDARG,
Expand Down Expand Up @@ -2521,6 +2527,7 @@ static struct SYS_VAR *rocksdb_system_variables[] = {

MYSQL_SYSVAR(datadir),
MYSQL_SYSVAR(fs_uri),
MYSQL_SYSVAR(env_uri),
MYSQL_SYSVAR(create_checkpoint),
MYSQL_SYSVAR(create_temporary_checkpoint),
MYSQL_SYSVAR(disable_file_deletions),
Expand Down Expand Up @@ -5889,6 +5896,20 @@ static int rocksdb_init_internal(void *const p) {
DBUG_RETURN(HA_EXIT_FAILURE);
}
rocksdb_db_options->env = GetCompositeEnv(fs);

} else if (rocksdb_env_uri) {
rocksdb::Env *rdbp_env = nullptr;
static std::shared_ptr<rocksdb::Env> env_guard;
rocksdb::ConfigOptions config_options(*rocksdb_db_options);
std::string rocksdb_env_uri_str = std::string(rocksdb_env_uri);
s = rocksdb::Env::CreateFromString(config_options, rocksdb_env_uri_str,
&rdbp_env, &env_guard);
if (s.ok()) {
rocksdb_db_options->env = rdbp_env;
} else {
rdb_log_status_error(s, "Can't initialize Rocksdb Plugin Environment");
DBUG_RETURN(HA_EXIT_FAILURE);
}
}

DBUG_EXECUTE_IF("rocksdb_init_failure_files_corruption",
Expand Down