diff --git a/mysql-test/suite/rocksdb/r/rocksdb.result b/mysql-test/suite/rocksdb/r/rocksdb.result index 5ec1d0b3360a..833b09d97da8 100644 --- a/mysql-test/suite/rocksdb/r/rocksdb.result +++ b/mysql-test/suite/rocksdb/r/rocksdb.result @@ -902,6 +902,7 @@ rocksdb_allow_unsafe_alter OFF rocksdb_alter_column_default_inplace ON rocksdb_alter_table_comment_inplace OFF rocksdb_blind_delete_primary_key OFF +rocksdb_block_cache_numshardbits -1 rocksdb_block_cache_size 536870912 rocksdb_block_restart_interval 16 rocksdb_block_size 16384 diff --git a/mysql-test/suite/rocksdb_sys_vars/r/rocksdb_block_cache_numshardbits_basic.result b/mysql-test/suite/rocksdb_sys_vars/r/rocksdb_block_cache_numshardbits_basic.result new file mode 100644 index 000000000000..a30547b99e54 --- /dev/null +++ b/mysql-test/suite/rocksdb_sys_vars/r/rocksdb_block_cache_numshardbits_basic.result @@ -0,0 +1,7 @@ +SET @start_global_value = @@global.ROCKSDB_BLOCK_CACHE_NUMSHARDBITS; +SELECT @start_global_value; +@start_global_value +-1 +"Trying to set variable @@global.ROCKSDB_BLOCK_CACHE_NUMSHARDBITS to 444. It should fail because it is readonly." +SET @@global.ROCKSDB_BLOCK_CACHE_NUMSHARDBITS = 444; +ERROR HY000: Variable 'rocksdb_block_cache_numshardbits' is a read only variable diff --git a/mysql-test/suite/rocksdb_sys_vars/t/rocksdb_block_cache_numshardbits_basic.test b/mysql-test/suite/rocksdb_sys_vars/t/rocksdb_block_cache_numshardbits_basic.test new file mode 100644 index 000000000000..924c7abe11fc --- /dev/null +++ b/mysql-test/suite/rocksdb_sys_vars/t/rocksdb_block_cache_numshardbits_basic.test @@ -0,0 +1,6 @@ +--source include/have_rocksdb.inc + +--let $sys_var=ROCKSDB_BLOCK_CACHE_NUMSHARDBITS +--let $read_only=1 +--let $session=0 +--source ../include/rocksdb_sys_var.inc diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index e1d5c126323f..da268613fea5 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -791,6 +791,7 @@ static uint32_t rocksdb_validate_tables = 1; // ROCKSDB_INCLUDE_VALIDATE_TABLES static char *rocksdb_datadir = nullptr; static uint32_t rocksdb_max_bottom_pri_background_compactions = 0; +static int rocksdb_block_cache_numshardbits = -1; static uint32_t rocksdb_table_stats_sampling_pct = RDB_DEFAULT_TBL_STATS_SAMPLE_PCT; static uint32_t rocksdb_table_stats_recalc_threshold_pct = 10; @@ -1840,6 +1841,13 @@ static MYSQL_SYSVAR_INT(table_cache_numshardbits, rocksdb_db_options->table_cache_numshardbits, /* min */ 0, /* max */ 19, 0); +static MYSQL_SYSVAR_INT(block_cache_numshardbits, + rocksdb_block_cache_numshardbits, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "Block cache numshardbits for RocksDB", nullptr, + nullptr, + /* default */ -1, /* min */ -1, /* max */ 8, 0); + static MYSQL_SYSVAR_UINT64_T(wal_ttl_seconds, rocksdb_db_options->WAL_ttl_seconds, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, @@ -2689,6 +2697,7 @@ static struct SYS_VAR *rocksdb_system_variables[] = { MYSQL_SYSVAR(keep_log_file_num), MYSQL_SYSVAR(max_manifest_file_size), MYSQL_SYSVAR(table_cache_numshardbits), + MYSQL_SYSVAR(block_cache_numshardbits), MYSQL_SYSVAR(wal_ttl_seconds), MYSQL_SYSVAR(wal_size_limit_mb), MYSQL_SYSVAR(manifest_preallocation_size), @@ -6673,13 +6682,12 @@ static int rocksdb_init_internal(void *const p) { rocksdb_use_hyper_clock_cache ? rocksdb::HyperClockCacheOptions( rocksdb_block_cache_size, rocksdb_tbl_options->block_size, - -1 - /* num_shard_bits */, + rocksdb_block_cache_numshardbits, false /* strict_capacity_limit */, memory_allocator) .MakeSharedCache() : rocksdb::NewLRUCache( - rocksdb_block_cache_size, -1 /*num_shard_bits*/, + rocksdb_block_cache_size, rocksdb_block_cache_numshardbits, false /*strict_capcity_limit*/, rocksdb_cache_high_pri_pool_ratio, memory_allocator); if (rocksdb_sim_cache_size > 0) {