Skip to content

Commit

Permalink
Fix assertion whitelist == nullptr for rocksdb_read_free_rpl_tables (#…
Browse files Browse the repository at this point in the history
…887)

Summary:
It is valid for NULL to be passed in as an argument for
read_free_rpl_tables and skip_unique_check. Handle NULL arguments in
these functions by treating it as the default value.

Addresses #844
Pull Request resolved: #887

Differential Revision: D10392551

Pulled By: hermanlee

fbshipit-source-id: 18d2c0b
  • Loading branch information
Herman Lee authored and facebook-github-bot committed Nov 21, 2018
1 parent 04d444a commit 274bad3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
Expand Up @@ -61,5 +61,7 @@ SET @@session.ROCKSDB_READ_FREE_RPL_TABLES = @start_session_value;
SELECT @@session.ROCKSDB_READ_FREE_RPL_TABLES;
@@session.ROCKSDB_READ_FREE_RPL_TABLES

SET GLOBAL ROCKSDB_READ_FREE_RPL_TABLES=NULL;
SET GLOBAL ROCKSDB_READ_FREE_RPL_TABLES=DEFAULT;
DROP TABLE valid_values;
DROP TABLE invalid_values;
Expand Up @@ -61,5 +61,7 @@ SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES = @start_session_value;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES
.*
SET GLOBAL ROCKSDB_SKIP_UNIQUE_CHECK_TABLES=NULL;
SET GLOBAL ROCKSDB_SKIP_UNIQUE_CHECK_TABLES=DEFAULT;
DROP TABLE valid_values;
DROP TABLE invalid_values;
Expand Up @@ -11,5 +11,8 @@ CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
--let $session=1
--source ../include/rocksdb_sys_var.inc

SET GLOBAL ROCKSDB_READ_FREE_RPL_TABLES=NULL;
SET GLOBAL ROCKSDB_READ_FREE_RPL_TABLES=DEFAULT;

DROP TABLE valid_values;
DROP TABLE invalid_values;
Expand Up @@ -11,5 +11,8 @@ CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
--let $session=1
--source ../include/rocksdb_sys_var.inc

SET GLOBAL ROCKSDB_SKIP_UNIQUE_CHECK_TABLES=NULL;
SET GLOBAL ROCKSDB_SKIP_UNIQUE_CHECK_TABLES=DEFAULT;

DROP TABLE valid_values;
DROP TABLE invalid_values;
15 changes: 9 additions & 6 deletions storage/rocksdb/ha_rocksdb.cc
Expand Up @@ -806,10 +806,11 @@ static MYSQL_THDVAR_STR(tmpdir, PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_MEMALLOC,
"Directory for temporary files during DDL operations.",
nullptr, nullptr, "");

#define DEFAULT_SKIP_UNIQUE_CHECK_TABLES ".*"
static MYSQL_THDVAR_STR(
skip_unique_check_tables, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
"Skip unique constraint checking for the specified tables", nullptr,
nullptr, ".*");
nullptr, DEFAULT_SKIP_UNIQUE_CHECK_TABLES);

static MYSQL_THDVAR_BOOL(
commit_in_the_middle, PLUGIN_VAR_RQCMDARG,
Expand All @@ -823,11 +824,12 @@ static MYSQL_THDVAR_BOOL(
" Blind delete is disabled if the table has secondary key",
nullptr, nullptr, FALSE);

#define DEFAULT_READ_FREE_RPL_TABLES ""
static MYSQL_THDVAR_STR(
read_free_rpl_tables, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
"List of tables that will use read-free replication on the slave "
"(i.e. not lookup a row during replication)",
nullptr, nullptr, "");
nullptr, nullptr, DEFAULT_READ_FREE_RPL_TABLES);

static MYSQL_THDVAR_BOOL(skip_bloom_filter_on_read, PLUGIN_VAR_RQCMDARG,
"Skip using bloom filter for reads", nullptr, nullptr,
Expand Down Expand Up @@ -6448,31 +6450,32 @@ void ha_rocksdb::free_key_buffers() {
}

void ha_rocksdb::set_use_read_free_rpl(const char *const whitelist) {
DBUG_ASSERT(whitelist != nullptr);
const char *const wl = whitelist ? whitelist : DEFAULT_READ_FREE_RPL_TABLES;

#if defined(HAVE_PSI_INTERFACE)
Regex_list_handler regex_handler(key_rwlock_read_free_rpl_tables);
#else
Regex_list_handler regex_handler;
#endif

if (!regex_handler.set_patterns(whitelist)) {
if (!regex_handler.set_patterns(wl)) {
warn_about_bad_patterns(&regex_handler, "read_free_rpl_tables");
}

m_use_read_free_rpl = regex_handler.matches(m_tbl_def->base_tablename());
}

void ha_rocksdb::set_skip_unique_check_tables(const char *const whitelist) {
DBUG_ASSERT(whitelist != nullptr);
const char *const wl =
whitelist ? whitelist : DEFAULT_SKIP_UNIQUE_CHECK_TABLES;

#if defined(HAVE_PSI_INTERFACE)
Regex_list_handler regex_handler(key_rwlock_skip_unique_check_tables);
#else
Regex_list_handler regex_handler;
#endif

if (!regex_handler.set_patterns(whitelist)) {
if (!regex_handler.set_patterns(wl)) {
warn_about_bad_patterns(&regex_handler, "skip_unique_check_tables");
}

Expand Down

0 comments on commit 274bad3

Please sign in to comment.