Commit 7468ccfa authored by Sergei Petrunia's avatar Sergei Petrunia

Copy of

commit d1bb19b8f751875472211312c8e810143a7ba4b6
Author: Manuel Ung <mung@fb.com>
Date:   Fri Feb 3 11:50:34 2017 -0800

    Add cardinality stats to information schema

    Summary: This adds cardinality stats to the INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP table. This is the only missing user collected properties from SST files that we don't expose, which is useful for debugging cardinality bugs.

    Reviewed By: hermanlee

    Differential Revision: D4509156

    fbshipit-source-id: 2d3918a
parent cfb59f31
......@@ -22,8 +22,8 @@
#include <vector>
/* MySQL includes */
#include <mysql/plugin.h>
#include <my_global.h>
#include <mysql/plugin.h>
/* MyRocks includes */
#include "./ha_rocksdb.h"
......@@ -33,10 +33,8 @@
namespace myrocks {
static std::vector<Rdb_index_stats>
extract_index_stats(
const std::vector<std::string>& files,
const rocksdb::TablePropertiesCollection& props
) {
extract_index_stats(const std::vector<std::string> &files,
const rocksdb::TablePropertiesCollection &props) {
std::vector<Rdb_index_stats> ret;
for (auto fn : files) {
const auto it = props.find(fn);
......@@ -49,11 +47,10 @@ extract_index_stats(
}
void Rdb_event_listener::update_index_stats(
const rocksdb::TableProperties& props
) {
const rocksdb::TableProperties &props) {
DBUG_ASSERT(m_ddl_manager != nullptr);
const auto tbl_props =
std::make_shared<const rocksdb::TableProperties>(props);
std::make_shared<const rocksdb::TableProperties>(props);
std::vector<Rdb_index_stats> stats;
Rdb_tbl_prop_coll::read_stats_from_tbl_props(tbl_props, &stats);
......@@ -62,32 +59,26 @@ void Rdb_event_listener::update_index_stats(
}
void Rdb_event_listener::OnCompactionCompleted(
rocksdb::DB *db,
const rocksdb::CompactionJobInfo& ci
) {
rocksdb::DB *db, const rocksdb::CompactionJobInfo &ci) {
DBUG_ASSERT(db != nullptr);
DBUG_ASSERT(m_ddl_manager != nullptr);
if (ci.status.ok()) {
m_ddl_manager->adjust_stats(
extract_index_stats(ci.output_files, ci.table_properties),
extract_index_stats(ci.input_files, ci.table_properties));
extract_index_stats(ci.output_files, ci.table_properties),
extract_index_stats(ci.input_files, ci.table_properties));
}
}
void Rdb_event_listener::OnFlushCompleted(
rocksdb::DB* db,
const rocksdb::FlushJobInfo& flush_job_info
) {
rocksdb::DB *db, const rocksdb::FlushJobInfo &flush_job_info) {
DBUG_ASSERT(db != nullptr);
update_index_stats(flush_job_info.table_properties);
}
void Rdb_event_listener::OnExternalFileIngested(
rocksdb::DB* db,
const rocksdb::ExternalFileIngestionInfo& info
) {
rocksdb::DB *db, const rocksdb::ExternalFileIngestionInfo &info) {
DBUG_ASSERT(db != nullptr);
update_index_stats(info.table_properties);
}
} // namespace myrocks
} // namespace myrocks
......@@ -21,29 +21,26 @@ namespace myrocks {
class Rdb_ddl_manager;
class Rdb_event_listener : public rocksdb::EventListener
{
public:
Rdb_event_listener(const Rdb_event_listener&) = delete;
Rdb_event_listener& operator=(const Rdb_event_listener&) = delete;
explicit Rdb_event_listener(Rdb_ddl_manager* const ddl_manager) :
m_ddl_manager(ddl_manager) {
}
void OnCompactionCompleted(
rocksdb::DB* db, const rocksdb::CompactionJobInfo& ci) override;
void OnFlushCompleted(
rocksdb::DB* db, const rocksdb::FlushJobInfo& flush_job_info) override;
class Rdb_event_listener : public rocksdb::EventListener {
public:
Rdb_event_listener(const Rdb_event_listener &) = delete;
Rdb_event_listener &operator=(const Rdb_event_listener &) = delete;
explicit Rdb_event_listener(Rdb_ddl_manager *const ddl_manager)
: m_ddl_manager(ddl_manager) {}
void OnCompactionCompleted(rocksdb::DB *db,
const rocksdb::CompactionJobInfo &ci) override;
void OnFlushCompleted(rocksdb::DB *db,
const rocksdb::FlushJobInfo &flush_job_info) override;
void OnExternalFileIngested(
rocksdb::DB* db, const rocksdb::ExternalFileIngestionInfo& ingestion_info)
override;
rocksdb::DB *db,
const rocksdb::ExternalFileIngestionInfo &ingestion_info) override;
private:
Rdb_ddl_manager* m_ddl_manager;
private:
Rdb_ddl_manager *m_ddl_manager;
void update_index_stats(
const rocksdb::TableProperties& props);
void update_index_stats(const rocksdb::TableProperties &props);
};
} // namespace myrocks
} // namespace myrocks
This diff is collapsed.
This diff is collapsed.
......@@ -32,27 +32,31 @@ enum RDB_IO_ERROR_TYPE {
RDB_IO_ERROR_TX_COMMIT,
RDB_IO_ERROR_DICT_COMMIT,
RDB_IO_ERROR_BG_THREAD,
RDB_IO_ERROR_GENERAL
RDB_IO_ERROR_GENERAL,
RDB_IO_ERROR_LAST
};
void rdb_handle_io_error(rocksdb::Status status, RDB_IO_ERROR_TYPE err_type);
const char *get_rdb_io_error_string(const RDB_IO_ERROR_TYPE err_type);
int rdb_normalize_tablename(const std::string& tablename, std::string* str)
__attribute__((__nonnull__, __warn_unused_result__));
void rdb_handle_io_error(const rocksdb::Status status,
const RDB_IO_ERROR_TYPE err_type);
int rdb_split_normalized_tablename(const std::string& fullname, std::string *db,
int rdb_normalize_tablename(const std::string &tablename, std::string *str)
MY_ATTRIBUTE((__nonnull__, __warn_unused_result__));
int rdb_split_normalized_tablename(const std::string &fullname, std::string *db,
std::string *table = nullptr,
std::string *partition = nullptr)
__attribute__((__warn_unused_result__));
MY_ATTRIBUTE((__warn_unused_result__));
std::vector<std::string> rdb_get_open_table_names(void);
int rdb_get_table_perf_counters(const char *tablename,
Rdb_perf_counters *counters)
__attribute__((__nonnull__(2)));
MY_ATTRIBUTE((__nonnull__(2)));
void rdb_get_global_perf_counters(Rdb_perf_counters *counters)
__attribute__((__nonnull__(1)));
MY_ATTRIBUTE((__nonnull__(1)));
void rdb_queue_save_stats_request();
......@@ -63,20 +67,20 @@ void rdb_queue_save_stats_request();
rocksdb::TransactionDB *rdb_get_rocksdb_db();
class Rdb_cf_manager;
Rdb_cf_manager& rdb_get_cf_manager();
Rdb_cf_manager &rdb_get_cf_manager();
rocksdb::BlockBasedTableOptions& rdb_get_table_options();
rocksdb::BlockBasedTableOptions &rdb_get_table_options();
class Rdb_dict_manager;
Rdb_dict_manager *rdb_get_dict_manager(void)
__attribute__((__warn_unused_result__));
MY_ATTRIBUTE((__warn_unused_result__));
class Rdb_ddl_manager;
Rdb_ddl_manager *rdb_get_ddl_manager(void)
__attribute__((__warn_unused_result__));
MY_ATTRIBUTE((__warn_unused_result__));
class Rdb_binlog_manager;
Rdb_binlog_manager *rdb_get_binlog_manager(void)
__attribute__((__warn_unused_result__));
MY_ATTRIBUTE((__warn_unused_result__));
} // namespace myrocks
} // namespace myrocks
......@@ -21,13 +21,10 @@
namespace myrocks {
class Rdb_logger : public rocksdb::Logger
{
public:
void Logv(const rocksdb::InfoLogLevel log_level,
const char* format,
va_list ap) override
{
class Rdb_logger : public rocksdb::Logger {
public:
void Logv(const rocksdb::InfoLogLevel log_level, const char *format,
va_list ap) override {
DBUG_ASSERT(format != nullptr);
enum loglevel mysql_log_level;
......@@ -41,11 +38,11 @@ class Rdb_logger : public rocksdb::Logger
}
if (log_level >= rocksdb::InfoLogLevel::ERROR_LEVEL) {
mysql_log_level= ERROR_LEVEL;
mysql_log_level = ERROR_LEVEL;
} else if (log_level >= rocksdb::InfoLogLevel::WARN_LEVEL) {
mysql_log_level= WARNING_LEVEL;
mysql_log_level = WARNING_LEVEL;
} else {
mysql_log_level= INFORMATION_LEVEL;
mysql_log_level = INFORMATION_LEVEL;
}
// log to MySQL
......@@ -54,20 +51,18 @@ class Rdb_logger : public rocksdb::Logger
error_log_print(mysql_log_level, f.c_str(), ap);
}
void Logv(const char* format, va_list ap) override
{
void Logv(const char *format, va_list ap) override {
DBUG_ASSERT(format != nullptr);
// If no level is specified, it is by default at information level
Logv(rocksdb::InfoLogLevel::INFO_LEVEL, format, ap);
}
void SetRocksDBLogger(const std::shared_ptr<rocksdb::Logger> logger)
{
void SetRocksDBLogger(const std::shared_ptr<rocksdb::Logger> logger) {
m_logger = logger;
}
private:
private:
std::shared_ptr<rocksdb::Logger> m_logger;
};
} // namespace myrocks
} // namespace myrocks
......@@ -4,20 +4,20 @@ CREATE DATABASE mysqlslap;
USE mysqlslap;
CREATE TABLE t1(id BIGINT AUTO_INCREMENT, value BIGINT, PRIMARY KEY(id)) ENGINE=rocksdb;
# 2PC enabled, MyRocks durability enabled
SET GLOBAL rocksdb_disable_2pc=0;
SET GLOBAL rocksdb_enable_2pc=0;
SET GLOBAL rocksdb_write_sync=1;
## 2PC + durability + single thread
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
select case when variable_value-@c = 1000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
case when variable_value-@c = 1000 then 'true' else 'false' end
true
false
## 2PC + durability + group commit
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
select case when variable_value-@c > 0 and variable_value-@c < 10000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
case when variable_value-@c > 0 and variable_value-@c < 10000 then 'true' else 'false' end
true
false
# 2PC enabled, MyRocks durability disabled
SET GLOBAL rocksdb_disable_2pc=0;
SET GLOBAL rocksdb_enable_2pc=0;
SET GLOBAL rocksdb_write_sync=0;
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
......@@ -28,17 +28,17 @@ select case when variable_value-@c = 0 then 'true' else 'false' end from informa
case when variable_value-@c = 0 then 'true' else 'false' end
true
# 2PC disabled, MyRocks durability enabled
SET GLOBAL rocksdb_disable_2pc=1;
SET GLOBAL rocksdb_enable_2pc=1;
SET GLOBAL rocksdb_write_sync=1;
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
case when variable_value-@c = 0 then 'true' else 'false' end
true
false
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
case when variable_value-@c = 0 then 'true' else 'false' end
true
SET GLOBAL rocksdb_disable_2pc=1;
false
SET GLOBAL rocksdb_enable_2pc=1;
SET GLOBAL rocksdb_write_sync=0;
DROP TABLE t1;
DROP DATABASE mysqlslap;
......@@ -60,11 +60,8 @@ CREATE TABLE t1 (i INT, j INT, k INT, PRIMARY KEY (i), KEY(j)) ENGINE = ROCKSDB
# crash_during_index_creation_partition
flush logs;
SET SESSION debug="+d,myrocks_simulate_index_create_rollback";
# expected assertion failure from sql layer here for alter rollback
call mtr.add_suppression("Assertion `0' failed.");
call mtr.add_suppression("Attempting backtrace. You can use the following information to find out");
ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
ERROR HY000: Lost connection to MySQL server during query
ERROR HY000: Intentional failure in inplace alter occurred.
SET SESSION debug="-d,myrocks_simulate_index_create_rollback";
SHOW CREATE TABLE t1;
Table Create Table
......
drop table if exists t1;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
INSERT INTO t1 (a, b) VALUES (1, 5);
INSERT INTO t1 (a, b) VALUES (2, 6);
INSERT INTO t1 (a, b) VALUES (3, 7);
INSERT INTO t1 (a,b) VALUES (4,5);
ALTER TABLE t1 ADD UNIQUE INDEX kb(b), ALGORITHM=INPLACE;
ERROR 23000: Duplicate entry '5' for key 'kb'
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
INSERT INTO t1 (a, b) VALUES (1, 5);
INSERT INTO t1 (a, b) VALUES (2, 6);
INSERT INTO t1 (a, b) VALUES (3, 7);
ALTER TABLE t1 ADD UNIQUE INDEX kb(b), ALGORITHM=INPLACE;
INSERT INTO t1 (a,b) VALUES (4,5);
ERROR 23000: Duplicate entry '5' for key 'kb'
INSERT INTO t1 (a,b) VALUES (5,8);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
UNIQUE KEY `kb` (`b`)
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
SELECT * FROM t1 FORCE INDEX(kb);
a b
1 5
2 6
3 7
5 8
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
INSERT INTO t1 (a, b) VALUES (1, 5);
INSERT INTO t1 (a, b) VALUES (2, NULL);
INSERT INTO t1 (a, b) VALUES (3, NULL);
ALTER TABLE t1 ADD UNIQUE INDEX kb(b), ALGORITHM=INPLACE;
INSERT INTO t1 (a, b) VALUES (4, NULL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
UNIQUE KEY `kb` (`b`)
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
SELECT COUNT(*) FROM t1 FORCE INDEX(kb);
COUNT(*)
4
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, c INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
INSERT INTO t1 (a,b,c) VALUES (1,1,NULL);
INSERT INTO t1 (a,b,c) VALUES (2,1,NULL);
INSERT INTO t1 (a,b,c) VALUES (3,1,NULL);
INSERT INTO t1 (a,b,c) VALUES (4,1,5);
ALTER TABLE t1 ADD UNIQUE INDEX kbc(b,c), ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
UNIQUE KEY `kbc` (`b`,`c`)
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
SELECT COUNT(*) FROM t1 FORCE INDEX(kbc);
COUNT(*)
4
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT) ENGINE=RocksDB;
INSERT INTO t1 (a, b) VALUES (1, 5);
INSERT INTO t1 (a, b) VALUES (2, 6);
INSERT INTO t1 (a, b) VALUES (3, 7);
ALTER TABLE t1 ADD UNIQUE INDEX kb(b);
ERROR HY000: Unique index support is disabled when the table has no primary key.
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
DROP TABLE t1;
......@@ -10,19 +10,19 @@ SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP
WHERE INDEX_NUMBER =
(SELECT INDEX_NUMBER FROM INFORMATION_SCHEMA.ROCKSDB_DDL
WHERE TABLE_NAME = 't1' AND INDEX_NAME = "PRIMARY");
COLUMN_FAMILY INDEX_NUMBER SST_NAME NUM_ROWS DATA_SIZE ENTRY_DELETES ENTRY_SINGLEDELETES ENTRY_MERGES ENTRY_OTHERS
# # SSTNAME 5 # # # # #
COLUMN_FAMILY INDEX_NUMBER SST_NAME NUM_ROWS DATA_SIZE ENTRY_DELETES ENTRY_SINGLEDELETES ENTRY_MERGES ENTRY_OTHERS DISTINCT_KEYS_PREFIX
# # SSTNAME 5 # # # # # 5
SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP
WHERE INDEX_NUMBER =
(SELECT INDEX_NUMBER FROM INFORMATION_SCHEMA.ROCKSDB_DDL
WHERE TABLE_NAME = 't1' AND INDEX_NAME = "j");
COLUMN_FAMILY INDEX_NUMBER SST_NAME NUM_ROWS DATA_SIZE ENTRY_DELETES ENTRY_SINGLEDELETES ENTRY_MERGES ENTRY_OTHERS
# # SSTNAME 5 # # # # #
COLUMN_FAMILY INDEX_NUMBER SST_NAME NUM_ROWS DATA_SIZE ENTRY_DELETES ENTRY_SINGLEDELETES ENTRY_MERGES ENTRY_OTHERS DISTINCT_KEYS_PREFIX
# # SSTNAME 5 # # # # # 5,5
SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP
WHERE INDEX_NUMBER =
(SELECT INDEX_NUMBER FROM INFORMATION_SCHEMA.ROCKSDB_DDL
WHERE TABLE_NAME = 't2' AND INDEX_NAME = "PRIMARY");
COLUMN_FAMILY INDEX_NUMBER SST_NAME NUM_ROWS DATA_SIZE ENTRY_DELETES ENTRY_SINGLEDELETES ENTRY_MERGES ENTRY_OTHERS
# # SSTNAME 4 # # # # #
COLUMN_FAMILY INDEX_NUMBER SST_NAME NUM_ROWS DATA_SIZE ENTRY_DELETES ENTRY_SINGLEDELETES ENTRY_MERGES ENTRY_OTHERS DISTINCT_KEYS_PREFIX
# # SSTNAME 4 # # # # # 4
DROP TABLE t1;
DROP TABLE t2;
......@@ -9,6 +9,7 @@ CF_FLAGS 1 __system__ [0]
select count(*) from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO;
count(*)
3
select VALUE into @keysIn from INFORMATION_SCHEMA.ROCKSDB_COMPACTION_STATS where CF_NAME = 'default' and LEVEL = 'Sum' and TYPE = 'KeyIn';
CREATE TABLE t1 (i1 INT, i2 INT, PRIMARY KEY (i1)) ENGINE = ROCKSDB;
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO;
......@@ -22,6 +23,11 @@ CF_FLAGS 1 __system__ [0]
select count(*) from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO;
count(*)
6
set global rocksdb_force_flush_memtable_now = true;
set global rocksdb_compact_cf='default';
select case when VALUE-@keysIn >= 3 then 'true' else 'false' end from INFORMATION_SCHEMA.ROCKSDB_COMPACTION_STATS where CF_NAME = 'default' and LEVEL = 'Sum' and TYPE = 'KeyIn';
case when VALUE-@keysIn >= 3 then 'true' else 'false' end
true
CREATE INDEX tindex1 on t1 (i1);
CREATE INDEX tindex2 on t1 (i2);
select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where TYPE = 'CF_FLAGS';
......
......@@ -121,7 +121,7 @@ a b
5 loaded
7 test
DROP TABLE t1;
set session rocksdb_skip_unique_check=1;
set session unique_checks=0;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
LOAD DATA INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
......
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int primary key) ENGINE=ROCKSDB;
insert into t1 values (1);
set global rocksdb_force_flush_memtable_now=1;
select * from t1 where a = 1;
a
1
select * from t1 where a = 1;
a
1
drop table t1;
......@@ -890,8 +890,8 @@ rocksdb_deadlock_detect OFF
rocksdb_debug_optimizer_no_zero_cardinality ON
rocksdb_default_cf_options
rocksdb_delete_obsolete_files_period_micros 21600000000
rocksdb_disable_2pc ON
rocksdb_disabledatasync OFF
rocksdb_enable_2pc ON
rocksdb_enable_bulk_load_api ON
rocksdb_enable_thread_tracking OFF
rocksdb_enable_write_thread_adaptive_yield OFF
......@@ -924,17 +924,17 @@ rocksdb_override_cf_options
rocksdb_paranoid_checks ON
rocksdb_pause_background_work ON
rocksdb_perf_context_level 0
rocksdb_persistent_cache_path
rocksdb_persistent_cache_size 0
rocksdb_pin_l0_filter_and_index_blocks_in_cache ON
rocksdb_print_snapshot_conflict_queries OFF
rocksdb_rate_limiter_bytes_per_sec 0
rocksdb_read_free_rpl_tables
rocksdb_records_in_range 50
rocksdb_rpl_skip_tx_api OFF
rocksdb_seconds_between_stat_computes 3600
rocksdb_signal_drop_index_thread OFF
rocksdb_skip_bloom_filter_on_read OFF
rocksdb_skip_fill_cache OFF
rocksdb_skip_unique_check OFF
rocksdb_skip_unique_check_tables .*
rocksdb_stats_dump_period_sec 600
rocksdb_store_row_debug_checksums OFF
......@@ -2231,7 +2231,7 @@ DROP DATABASE test_db;
# Issue #143: Split rocksdb_bulk_load option into two
#
CREATE TABLE t1 (id int primary key, value int) engine=RocksDB;
SET rocksdb_skip_unique_check=1;
SET unique_checks=0;
INSERT INTO t1 VALUES(1, 1);
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t1 VALUES(1, 3);
......@@ -2243,7 +2243,7 @@ INSERT INTO t1 VALUES(5, 5) ON DUPLICATE KEY UPDATE value=value+1;
ERROR HY000: When unique checking is disabled in MyRocks, INSERT,UPDATE,LOAD statements with clauses that update or replace the key (i.e. INSERT ON DUPLICATE KEY UPDATE, REPLACE) are not allowed. Query: INSERT INTO t1 VALUES(5, 5) ON DUPLICATE KEY UPDATE value=value+1
TRUNCATE TABLE t1;
SET @save_rocksdb_bulk_load_size= @@rocksdb_bulk_load_size;
SET rocksdb_skip_unique_check=0;
SET unique_checks=1;
SET rocksdb_commit_in_the_middle=1;
SET rocksdb_bulk_load_size=10;
BEGIN;
......
......@@ -6,9 +6,9 @@ Note #### Storing MySQL user name or password information in the master info rep
DROP TABLE IF EXISTS t1;
include/stop_slave.inc
create table t1 (a int) engine=rocksdb;
show variables like 'rocksdb_rpl_skip_tx_api';
show variables like 'rpl_skip_tx_api';
Variable_name Value
rocksdb_rpl_skip_tx_api ON
rpl_skip_tx_api ON
include/start_slave.inc
found
DROP TABLE t1;
......
......@@ -183,3 +183,24 @@ ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
INSERT INTO t2 VALUES (2,1);
ERROR 23000: Duplicate entry '1' for key 'a'
DROP TABLE t2;
#
# Issue #491 (https://github.com/facebook/mysql-5.6/issues/491)
#
CREATE TABLE t (a BLOB, PRIMARY KEY(a(2)), UNIQUE KEY (a(1))) engine=rocksdb;
INSERT INTO t VALUES('a');
CHECK TABLE t EXTENDED;
Table Op Msg_type Msg_text
test.t check status OK
DROP TABLE t;
CREATE TABLE t (a VARCHAR(255), PRIMARY KEY(a), UNIQUE KEY (a(1))) engine=rocksdb;
INSERT INTO t VALUES('a');
CHECK TABLE t EXTENDED;
Table Op Msg_type Msg_text
test.t check status OK
DROP TABLE t;
CREATE TABLE t (a VARCHAR(255), PRIMARY KEY(a(2)), UNIQUE KEY (a(1))) engine=rocksdb;
INSERT INTO t VALUES('a');
CHECK TABLE t EXTENDED;
Table Op Msg_type Msg_text
test.t check status OK
DROP TABLE t;
......@@ -13,7 +13,7 @@ USE mysqlslap;
CREATE TABLE t1(id BIGINT AUTO_INCREMENT, value BIGINT, PRIMARY KEY(id)) ENGINE=rocksdb;
--echo # 2PC enabled, MyRocks durability enabled
SET GLOBAL rocksdb_disable_2pc=0;
SET GLOBAL rocksdb_enable_2pc=0;
SET GLOBAL rocksdb_write_sync=1;
--echo ## 2PC + durability + single thread
......@@ -28,7 +28,7 @@ select case when variable_value-@c > 0 and variable_value-@c < 10000 then 'true'
--echo # 2PC enabled, MyRocks durability disabled
SET GLOBAL rocksdb_disable_2pc=0;
SET GLOBAL rocksdb_enable_2pc=0;
SET GLOBAL rocksdb_write_sync=0;
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
......@@ -41,7 +41,7 @@ select case when variable_value-@c = 0 then 'true' else 'false' end from informa
--echo # 2PC disabled, MyRocks durability enabled
SET GLOBAL rocksdb_disable_2pc=1;
SET GLOBAL rocksdb_enable_2pc=1;
SET GLOBAL rocksdb_write_sync=1;
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
......@@ -58,7 +58,7 @@ select case when variable_value-@c = 0 then 'true' else 'false' end from informa
SET GLOBAL rocksdb_disable_2pc=1;
SET GLOBAL rocksdb_enable_2pc=1;
SET GLOBAL rocksdb_write_sync=0;
DROP TABLE t1;
DROP DATABASE mysqlslap;
......@@ -89,22 +89,11 @@ while ($i <= $max) {
--echo # crash_during_index_creation_partition
flush logs;
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
SET SESSION debug="+d,myrocks_simulate_index_create_rollback";
--echo # expected assertion failure from sql layer here for alter rollback
call mtr.add_suppression("Assertion `0' failed.");
call mtr.add_suppression("Attempting backtrace. You can use the following information to find out");
--error 2013
--error 1105
ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
--enable_reconnect
--source include/wait_until_connected_again.inc
SET SESSION debug="-d,myrocks_simulate_index_create_rollback";
SHOW CREATE TABLE t1;
# here, the index numbers should be higher because previously 4 index numbers
......
--source include/have_rocksdb.inc
--source include/have_debug.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
# test adding duplicate value before unique index
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
INSERT INTO t1 (a, b) VALUES (1, 5);
INSERT INTO t1 (a, b) VALUES (2, 6);
INSERT INTO t1 (a, b) VALUES (3, 7);
INSERT INTO t1 (a,b) VALUES (4,5);
# should cause error here, duplicate value on b
--error 1062
ALTER TABLE t1 ADD UNIQUE INDEX kb(b), ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
DROP TABLE t1;
# test dup value AFTER unique index
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
INSERT INTO t1 (a, b) VALUES (1, 5);
INSERT INTO t1 (a, b) VALUES (2, 6);
INSERT INTO t1 (a, b) VALUES (3, 7);
ALTER TABLE t1 ADD UNIQUE INDEX kb(b), ALGORITHM=INPLACE;
# should error here, duplicate value on b
--error 1062
INSERT INTO t1 (a,b) VALUES (4,5);
# should succeed
INSERT INTO t1 (a,b) VALUES (5,8);
SHOW CREATE TABLE t1;
SELECT * FROM t1 FORCE INDEX(kb);
DROP TABLE t1;
# test what happens when duplicate nulls exist
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
INSERT INTO t1 (a, b) VALUES (1, 5);
INSERT INTO t1 (a, b) VALUES (2, NULL);
INSERT INTO t1 (a, b) VALUES (3, NULL);
# should pass, because in MySQL we allow multiple NULLS in unique key
ALTER TABLE t1 ADD UNIQUE INDEX kb(b), ALGORITHM=INPLACE;
INSERT INTO t1 (a, b) VALUES (4, NULL);
SHOW CREATE TABLE t1;
SELECT COUNT(*) FROM t1 FORCE INDEX(kb);
DROP TABLE t1;
## test case with multi-part key with nulls
CREATE TABLE t1 (a INT, b INT, c INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
INSERT INTO t1 (a,b,c) VALUES (1,1,NULL);
INSERT INTO t1 (a,b,c) VALUES (2,1,NULL);
INSERT INTO t1 (a,b,c) VALUES (3,1,NULL);
INSERT INTO t1 (a,b,c) VALUES (4,1,5);
# should pass
ALTER TABLE t1 ADD UNIQUE INDEX kbc(b,c), ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
SELECT COUNT(*) FROM t1 FORCE INDEX(kbc);
DROP TABLE t1;
## test case with table w/ no primary key, and we try to add unique key
CREATE TABLE t1 (a INT, b INT) ENGINE=RocksDB;
INSERT INTO t1 (a, b) VALUES (1, 5);
INSERT INTO t1 (a, b) VALUES (2, 6);
INSERT INTO t1 (a, b) VALUES (3, 7);
# should fail, can't add unique index on table w/ no pk
--error 1105
ALTER TABLE t1 ADD UNIQUE INDEX kb(b);
SHOW CREATE TABLE t1;
DROP TABLE t1;
......@@ -12,6 +12,8 @@ DROP TABLE IF EXISTS t3;
select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO;
select count(*) from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO;
select VALUE into @keysIn from INFORMATION_SCHEMA.ROCKSDB_COMPACTION_STATS where CF_NAME = 'default' and LEVEL = 'Sum' and TYPE = 'KeyIn';
CREATE TABLE t1 (i1 INT, i2 INT, PRIMARY KEY (i1)) ENGINE = ROCKSDB;
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
......@@ -21,6 +23,10 @@ INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO;
select count(*) from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO;
set global rocksdb_force_flush_memtable_now = true;
set global rocksdb_compact_cf='default';
select case when VALUE-@keysIn >= 3 then 'true' else 'false' end from INFORMATION_SCHEMA.ROCKSDB_COMPACTION_STATS where CF_NAME = 'default' and LEVEL = 'Sum' and TYPE = 'KeyIn';
CREATE INDEX tindex1 on t1 (i1);
--let $start_max_index_id = query_get_value(SELECT * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where type = 'MAX_INDEX_ID', VALUE, 1)
......
......@@ -3,6 +3,5 @@
let $skip_unique_check = 0;
--source loaddata.inc
let $skip_unique_check = 1;
set session rocksdb_skip_unique_check=1;
set session unique_checks=0;
--source loaddata.inc
--source include/have_rocksdb.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $_server_id= `SELECT @@server_id`
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
--let $_cache_file_name= $MYSQLTEST_VARDIR/tmp/persistent_cache
--exec echo "wait" >$_expect_file_name
# restart server with correct parameters
shutdown_server 10;
--exec echo "restart:--rocksdb_persistent_cache_path=$_cache_file_name --rocksdb_persistent_cache_size=1000000000" >$_expect_file_name
--sleep 5
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect
# insert values and flush out of memtable
CREATE TABLE t1 (a int primary key) ENGINE=ROCKSDB;
insert into t1 values (1);
set global rocksdb_force_flush_memtable_now=1;
# pull data through cache
select * from t1 where a = 1;
# restart server to re-read cache
--exec echo "wait" >$_expect_file_name
shutdown_server 10;
--exec echo "restart:--rocksdb_persistent_cache_path=$_cache_file_name --rocksdb_persistent_cache_size=1000000000" >$_expect_file_name
--sleep 5
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect
# pull values from cache again
select * from t1 where a = 1;
drop table t1;
......@@ -1768,7 +1768,7 @@ DROP DATABASE test_db;
--echo # Issue #143: Split rocksdb_bulk_load option into two
--echo #
CREATE TABLE t1 (id int primary key, value int) engine=RocksDB;
SET rocksdb_skip_unique_check=1;
SET unique_checks=0;
INSERT INTO t1 VALUES(1, 1);
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t1 VALUES(1, 3);
......@@ -1779,7 +1779,7 @@ REPLACE INTO t1 VALUES(4, 4);
INSERT INTO t1 VALUES(5, 5) ON DUPLICATE KEY UPDATE value=value+1;
TRUNCATE TABLE t1;
SET @save_rocksdb_bulk_load_size= @@rocksdb_bulk_load_size;
SET rocksdb_skip_unique_check=0;
SET unique_checks=1;
SET rocksdb_commit_in_the_middle=1;
SET rocksdb_bulk_load_size=10;
BEGIN;
......
......@@ -5,4 +5,4 @@ binlog_format=row
[mysqld.2]
binlog_format=row
slave_parallel_workers=1
rocksdb_rpl_skip_tx_api=ON
rpl_skip_tx_api=ON
......@@ -17,7 +17,7 @@ while ($aa < 1000) {
--enable_query_log
connection slave;
show variables like 'rocksdb_rpl_skip_tx_api';
show variables like 'rpl_skip_tx_api';
--source include/start_slave.inc
--let $it=0
......
......@@ -31,3 +31,21 @@ INSERT INTO t2 VALUES (1,1);
--error ER_DUP_ENTRY
INSERT INTO t2 VALUES (2,1);
DROP TABLE t2;
--echo #
--echo # Issue #491 (https://github.com/facebook/mysql-5.6/issues/491)
--echo #
CREATE TABLE t (a BLOB, PRIMARY KEY(a(2)), UNIQUE KEY (a(1))) engine=rocksdb;
INSERT INTO t VALUES('a');
CHECK TABLE t EXTENDED;
DROP TABLE t;
CREATE TABLE t (a VARCHAR(255), PRIMARY KEY(a), UNIQUE KEY (a(1))) engine=rocksdb;
INSERT INTO t VALUES('a');
CHECK TABLE t EXTENDED;
DROP TABLE t;
CREATE TABLE t (a VARCHAR(255), PRIMARY KEY(a(2)), UNIQUE KEY (a(1))) engine=rocksdb;
INSERT INTO t VALUES('a');
CHECK TABLE t EXTENDED;
DROP TABLE t;
src_data_dir="${MYSQLTEST_VARDIR}/mysqld.1/data/"
python -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('${src_data_dir}/slocket')"
set -e
# Insert 10 batches of 10 records each to a table with following schema:
# create table slocket.t1 (
# `id` int(10) not null auto_increment,
# `k` int(10),
# `data` varchar(2048),
# primary key (`id`),
# key (`k`)
# ) engine=innodb;
MAX_INSERTS=10
MAX_ROWS_PER_INSERT=10
insertData() {
for ((i=1; i<=$MAX_INSERTS; i++));
do
stmt='INSERT INTO slocket.t1 values'
for ((j=1; j<=$MAX_ROWS_PER_INSERT; j++));
do
k=$RANDOM
data=$(head -c 2048 /dev/urandom|tr -cd 'a-zA-Z0-9')
stmt=$stmt' (NULL, '$k', "'$data'")'
if [ $j -lt $MAX_ROWS_PER_INSERT ]; then
stmt=$stmt','
fi
done
stmt=$stmt';'
$MYSQL --defaults-group-suffix=.1 -e "$stmt"
done
}
NUM_PARALLEL_INSERTS=25
pids=()
for ((k=1; k<=$NUM_PARALLEL_INSERTS; k++));
do
insertData &
pids+=($!)
done
for ((k=1; k<=$NUM_PARALLEL_INSERTS; k++));
do
wait ${pids[k]}
done
src_data_dir="${MYSQLTEST_VARDIR}/mysqld.1/data/"
rm "${src_data_dir}/slocket"
connection server_1;
create database slocket;
create table slocket.t1 (
`id` int(10) not null auto_increment,
`k` int(10),
`data` varchar(2048),
primary key (`id`),
key (`k`)
) engine=rocksdb;
......@@ -39,6 +39,11 @@ elif [ "$STREAM_TYPE" == 'xbstream' ]; then
--stream=xbstream --checkpoint_dir=$checkpoint_dir 2> \
$COPY_LOG | xbstream -x \
--directory=$backup_dir"
elif [ "$STREAM_TYPE" == "xbstream_socket" ]; then
BACKUP_CMD="$MYSQL_MYROCKS_HOTBACKUP --user='root' --socket=${MASTER_MYSOCK} \
--stream=xbstream --checkpoint_dir=$checkpoint_dir 2> \
$COPY_LOG | xbstream -x \
--directory=$backup_dir"
else
BACKUP_CMD="$MYSQL_MYROCKS_HOTBACKUP --user='root' --stream=wdt \
--port=${MASTER_MYPORT} --destination=localhost --backup_dir=$backup_dir \
......
include/rpl_init.inc [topology=none]
include/rpl_default_connections.inc
create database db1;
create table db1.t1 (
`id` int(10) not null auto_increment,
`k` int(10),
`data` varchar(2048),
primary key (`id`),
key (`k`)
) engine=rocksdb;
create database slocket;
create table slocket.t1 (
`id` int(10) not null auto_increment,
`k` int(10),
`data` varchar(2048),
primary key (`id`),
key (`k`)
) engine=rocksdb;
include/rpl_stop_server.inc [server_number=2]
myrocks_hotbackup copy phase
myrocks_hotbackup move-back phase
include/rpl_start_server.inc [server_number=2]
select count(*) from db1.t1;
count(*)
250000
select count(*) from slocket.t1;
count(*)
2500
drop database slocket;
drop database db1;
drop database slocket;
include/rpl_stop_server.inc [server_number=2]
myrocks_hotbackup copy phase
myrocks_hotbackup move-back phase
include/rpl_start_server.inc [server_number=2]
select count(*) from db1.t1;
count(*)
250000
drop database db1;
drop database db1;
include/rpl_end.inc
include/rpl_init.inc [topology=none]
include/rpl_default_connections.inc
create database db1;
create table db1.t1 (
`id` int(10) not null auto_increment,
`k` int(10),
`data` varchar(2048),
primary key (`id`),
key (`k`)
) engine=rocksdb;
include/rpl_stop_server.inc [server_number=2]
myrocks_hotbackup copy phase
myrocks_hotbackup move-back phase
include/rpl_start_server.inc [server_number=2]
select count(*) from db1.t1;
count(*)
250000
drop database db1;
drop database db1;
include/rpl_end.inc
source suite/rocksdb_hotbackup/include/setup.inc;
source suite/rocksdb_hotbackup/include/setup_slocket.inc;
--exec suite/rocksdb_hotbackup/include/load_data.sh 2>&1
--exec suite/rocksdb_hotbackup/include/load_data_slocket.sh 2>&1
--let $rpl_server_number= 2
--source include/rpl_stop_server.inc
--exec suite/rocksdb_hotbackup/include/stream_run.sh 2>&1
--let $rpl_server_number= 2
--source include/rpl_start_server.inc
connection server_2;
select count(*) from db1.t1;
select count(*) from slocket.t1;
connection server_1;
drop database slocket;
connection server_2;
drop database db1;
drop database slocket;
--exec sleep 2
--exec suite/rocksdb_hotbackup/include/create_slocket_socket.sh 2>&1
--let $rpl_server_number= 2
--source include/rpl_stop_server.inc
--exec suite/rocksdb_hotbackup/include/stream_run.sh 2>&1
--let $rpl_server_number= 2
--source include/rpl_start_server.inc
connection server_2;
select count(*) from db1.t1;
connection server_1;
drop database db1;
connection server_2;
drop database db1;
--exec suite/rocksdb_hotbackup/include/remove_slocket_socket.sh 2>&1
source suite/rocksdb_hotbackup/include/cleanup.inc;
source suite/rocksdb_hotbackup/include/setup.inc;
--exec suite/rocksdb_hotbackup/include/load_data.sh 2>&1
--let $rpl_server_number= 2
--source include/rpl_stop_server.inc
--exec STREAM_TYPE=xbstream_socket suite/rocksdb_hotbackup/include/stream_run.sh 2>&1
--let $rpl_server_number= 2
--source include/rpl_start_server.inc
connection server_2;
select count(*) from db1.t1;
connection server_1;
drop database db1;
connection server_2;
drop database db1;
source suite/rocksdb_hotbackup/include/cleanup.inc;
DROP TABLE IF EXISTS t1;
SET GLOBAL ROCKSDB_DISABLE_2PC = OFF;
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
create table t1 (a int primary key, b int, c varchar(255)) engine=rocksdb;
'con1'
SET SESSION debug="d,crash_commit_after_log";
......@@ -7,11 +7,11 @@ SET DEBUG_SYNC='rocksdb.prepared SIGNAL parked WAIT_FOR go';
insert into t1 values (1, 1, "iamtheogthealphaandomega");;
'con2'
insert into t1 values (2, 1, "i_am_just_here_to_trigger_a_flush");
SET GLOBAL ROCKSDB_DISABLE_2PC = ON;
SET GLOBAL ROCKSDB_ENABLE_2PC = OFF;
SET GLOBAL ROCKSDB_WRITE_SYNC = OFF;
SET GLOBAL SYNC_BINLOG = 0;
SET DEBUG_SYNC='now WAIT_FOR parked';
SET GLOBAL ROCKSDB_DISABLE_2PC = OFF;
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
SET GLOBAL ROCKSDB_WRITE_SYNC = ON;
SET GLOBAL SYNC_BINLOG = 1;
insert into t1 values (1000000, 1, "i_am_just_here_to_trigger_a_flush");
......
DROP TABLE IF EXISTS t1;
create table t1 (a int primary key, msg varchar(255)) engine=rocksdb;
SET GLOBAL ROCKSDB_DISABLE_2PC = OFF;
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
SET SESSION debug="d,crash_commit_after_prepare";
insert into t1 values (1, 'dogz');
select * from t1;
a msg
SET GLOBAL ROCKSDB_DISABLE_2PC = OFF;
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
SET SESSION debug="d,crash_commit_after_log";
insert into t1 values (2, 'catz'), (3, 'men');
select * from t1;
a msg
2 catz
3 men
SET GLOBAL ROCKSDB_DISABLE_2PC = OFF;
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
SET SESSION debug="d,crash_commit_after";
insert into t1 values (4, 'cars'), (5, 'foo');
select * from t1;
......@@ -21,7 +21,7 @@ a msg
3 men
4 cars
5 foo
SET GLOBAL ROCKSDB_DISABLE_2PC = ON;
SET GLOBAL ROCKSDB_ENABLE_2PC = OFF;
SET SESSION debug="d,crash_commit_after_log";
insert into t1 values (6, 'shipz'), (7, 'tankz');
select * from t1;
......@@ -30,7 +30,7 @@ a msg
3 men
4 cars
5 foo
SET GLOBAL ROCKSDB_DISABLE_2PC = ON;
SET GLOBAL ROCKSDB_ENABLE_2PC = OFF;
SET SESSION debug="d,crash_commit_after";
insert into t1 values (8, 'space'), (9, 'time');
select * from t1;
......
include/master-slave.inc
Warnings:
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
[connection master]
call mtr.add_suppression("Master's binlog format is not ROW but rpl_skip_tx_api is enabled on the slave");
set global rpl_skip_tx_api=ON;
set global rocksdb_unsafe_for_binlog=1;
create table t1(a int);
set session binlog_format=STATEMENT;
insert into t1 values(1);
include/wait_for_slave_sql_error.inc [errno=1756]
Last_SQL_Error = 'Master's binlog format is not ROW but rpl_skip_tx_api is enabled on the slave. rpl_skip_tx_api recovery should only be used when master's binlog format is ROW.'
"Table after error"
select * from t1;
a
set global rpl_skip_tx_api=OFF;
include/start_slave.inc
include/sync_slave_sql_with_master.inc
"Table after error fixed"
select * from t1;
a
1
drop table t1;
set global rocksdb_unsafe_for_binlog=0;
set global rpl_skip_tx_api=0;
include/rpl_end.inc
......@@ -10,7 +10,7 @@
DROP TABLE IF EXISTS t1;
--enable_warnings
SET GLOBAL ROCKSDB_DISABLE_2PC = OFF;
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
create table t1 (a int primary key, b int, c varchar(255)) engine=rocksdb;
connect (con1, localhost, root,,);
......@@ -35,7 +35,7 @@ insert into t1 values (2, 1, "i_am_just_here_to_trigger_a_flush");
# Disable 2PC and syncing for faster inserting of dummy rows
# These rows only purpose is to rotate the binlog
SET GLOBAL ROCKSDB_DISABLE_2PC = ON;
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
SET GLOBAL ROCKSDB_WRITE_SYNC = OFF;
SET GLOBAL SYNC_BINLOG = 0;
......@@ -50,7 +50,7 @@ while ($pk < 1000000) {
# re-enable 2PC an syncing then write to trigger a flush
# before we trigger the crash to simulate full-durability
SET GLOBAL ROCKSDB_DISABLE_2PC = OFF;
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
SET GLOBAL ROCKSDB_WRITE_SYNC = ON;
SET GLOBAL SYNC_BINLOG = 1;
......
......@@ -2,8 +2,10 @@
[mysqld.1]
log_slave_updates
rocksdb_enable_2pc=OFF
[mysqld.2]
relay_log_recovery=1
relay_log_info_repository=TABLE
log_slave_updates
rocksdb_enable_2pc=OFF
......@@ -4,6 +4,7 @@
log_slave_updates
gtid_mode=ON
enforce_gtid_consistency=ON
rocksdb_enable_2pc=OFF
[mysqld.2]
sync_relay_log_info=100
......@@ -12,3 +13,4 @@ relay_log_info_repository=FILE
log_slave_updates
gtid_mode=ON
enforce_gtid_consistency=ON
rocksdb_enable_2pc=OFF
......@@ -8,7 +8,7 @@ DROP TABLE IF EXISTS t1;
create table t1 (a int primary key, msg varchar(255)) engine=rocksdb;
SET GLOBAL ROCKSDB_DISABLE_2PC = OFF;
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
SET SESSION debug="d,crash_commit_after_prepare";
--error 0,2013
......@@ -17,7 +17,7 @@ insert into t1 values (1, 'dogz');
--source include/wait_until_connected_again.inc
select * from t1;
SET GLOBAL ROCKSDB_DISABLE_2PC = OFF;
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
SET SESSION debug="d,crash_commit_after_log";
--error 0,2013
......@@ -26,7 +26,7 @@ insert into t1 values (2, 'catz'), (3, 'men');
--source include/wait_until_connected_again.inc
select * from t1;
SET GLOBAL ROCKSDB_DISABLE_2PC = OFF;
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
SET SESSION debug="d,crash_commit_after";
--error 0,2013
......@@ -35,7 +35,7 @@ insert into t1 values (4, 'cars'), (5, 'foo');
--source include/wait_until_connected_again.inc
select * from t1;
SET GLOBAL ROCKSDB_DISABLE_2PC = ON;
SET GLOBAL ROCKSDB_ENABLE_2PC = OFF;
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
SET SESSION debug="d,crash_commit_after_log";
--error 0,2013
......@@ -44,7 +44,7 @@ insert into t1 values (6, 'shipz'), (7, 'tankz');
--source include/wait_until_connected_again.inc
select * from t1;
SET GLOBAL ROCKSDB_DISABLE_2PC = ON;
SET GLOBAL ROCKSDB_ENABLE_2PC = OFF;
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
SET SESSION debug="d,crash_commit_after";
--error 0,2013
......
--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates
--binlog_format=STATEMENT --default-storage-engine=rocksdb
--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates
--sync_binlog=1000 --relay_log_recovery=1 --default-storage-engine=rocksdb
# Checks if the slave stops executing transactions when master's binlog format
# is STATEMENT but rpl_skip_tx_api is enabled
-- source include/master-slave.inc
call mtr.add_suppression("Master's binlog format is not ROW but rpl_skip_tx_api is enabled on the slave");
connection slave;
let $old_rpl_skip_tx_api= `SELECT @@global.rpl_skip_tx_api`;
set global rpl_skip_tx_api=ON;
connection master;
let $old_rocksdb_unsafe_for_binlog= `SELECT @@global.rocksdb_unsafe_for_binlog`;
set global rocksdb_unsafe_for_binlog=1;
create table t1(a int);
set session binlog_format=STATEMENT;
insert into t1 values(1);
# Wait till we hit the binlog format mismatch error
connection slave;
let $slave_sql_errno= convert_error(ER_MTS_INCONSISTENT_DATA); # 1756
let $show_slave_sql_error= 1;
source include/wait_for_slave_sql_error.inc;
# Print table
connection slave;
echo "Table after error";
select * from t1;
connection slave;
# Turn off rpl_skip_tx_api and start the slave again
set global rpl_skip_tx_api=OFF;
source include/start_slave.inc;
connection slave;
source include/sync_slave_sql_with_master.inc;
connection slave;
# Print table again
echo "Table after error fixed";
select * from t1;
# Cleanup
connection master;
drop table t1;
eval set global rocksdb_unsafe_for_binlog=$old_rocksdb_unsafe_for_binlog;
sync_slave_with_master;
connection slave;
eval set global rpl_skip_tx_api=$old_rpl_skip_tx_api;
-- source include/rpl_end.inc
......@@ -9,5 +9,7 @@ There should be *no* long test name listed below:
select variable_name as `There should be *no* variables listed below:` from t2
left join t1 on variable_name=test_name where test_name is null ORDER BY variable_name;
There should be *no* variables listed below:
ROCKSDB_ENABLE_2PC
ROCKSDB_ENABLE_2PC
drop table t1;
drop table t2;
......@@ -6,70 +6,70 @@ INSERT INTO valid_values VALUES('off');
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO invalid_values VALUES('\'aaa\'');
INSERT INTO invalid_values VALUES('\'bbb\'');
SET @start_global_value = @@global.ROCKSDB_DISABLE_2PC;
SET @start_global_value = @@global.ROCKSDB_ENABLE_2PC;
SELECT @start_global_value;
@start_global_value
1
'# Setting to valid values in global scope#'
"Trying to set variable @@global.ROCKSDB_DISABLE_2PC to 1"
SET @@global.ROCKSDB_DISABLE_2PC = 1;
SELECT @@global.ROCKSDB_DISABLE_2PC;
@@global.ROCKSDB_DISABLE_2PC
"Trying to set variable @@global.ROCKSDB_ENABLE_2PC to 1"
SET @@global.ROCKSDB_ENABLE_2PC = 1;
SELECT @@global.ROCKSDB_ENABLE_2PC;
@@global.ROCKSDB_ENABLE_2PC
1
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_DISABLE_2PC = DEFAULT;
SELECT @@global.ROCKSDB_DISABLE_2PC;
@@global.ROCKSDB_DISABLE_2PC
SET @@global.ROCKSDB_ENABLE_2PC = DEFAULT;
SELECT @@global.ROCKSDB_ENABLE_2PC;
@@global.ROCKSDB_ENABLE_2PC
1
"Trying to set variable @@global.ROCKSDB_DISABLE_2PC to 0"
SET @@global.ROCKSDB_DISABLE_2PC = 0;
SELECT @@global.ROCKSDB_DISABLE_2PC;
@@global.ROCKSDB_DISABLE_2PC
"Trying to set variable @@global.ROCKSDB_ENABLE_2PC to 0"
SET @@global.ROCKSDB_ENABLE_2PC = 0;
SELECT @@global.ROCKSDB_ENABLE_2PC;
@@global.ROCKSDB_ENABLE_2PC
0
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_DISABLE_2PC = DEFAULT;
SELECT @@global.ROCKSDB_DISABLE_2PC;
@@global.ROCKSDB_DISABLE_2PC
SET @@global.ROCKSDB_ENABLE_2PC = DEFAULT;
SELECT @@global.ROCKSDB_ENABLE_2PC;
@@global.ROCKSDB_ENABLE_2PC
1
"Trying to set variable @@global.ROCKSDB_DISABLE_2PC to on"
SET @@global.ROCKSDB_DISABLE_2PC = on;
SELECT @@global.ROCKSDB_DISABLE_2PC;
@@global.ROCKSDB_DISABLE_2PC
"Trying to set variable @@global.ROCKSDB_ENABLE_2PC to on"
SET @@global.ROCKSDB_ENABLE_2PC = on;
SELECT @@global.ROCKSDB_ENABLE_2PC;
@@global.ROCKSDB_ENABLE_2PC
1
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_DISABLE_2PC = DEFAULT;
SELECT @@global.ROCKSDB_DISABLE_2PC;
@@global.ROCKSDB_DISABLE_2PC
SET @@global.ROCKSDB_ENABLE_2PC = DEFAULT;
SELECT @@global.ROCKSDB_ENABLE_2PC;
@@global.ROCKSDB_ENABLE_2PC
1
"Trying to set variable @@global.ROCKSDB_DISABLE_2PC to off"
SET @@global.ROCKSDB_DISABLE_2PC = off;
SELECT @@global.ROCKSDB_DISABLE_2PC;
@@global.ROCKSDB_DISABLE_2PC
"Trying to set variable @@global.ROCKSDB_ENABLE_2PC to off"
SET @@global.ROCKSDB_ENABLE_2PC = off;
SELECT @@global.ROCKSDB_ENABLE_2PC;
@@global.ROCKSDB_ENABLE_2PC
0
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_DISABLE_2PC = DEFAULT;
SELECT @@global.ROCKSDB_DISABLE_2PC;
@@global.ROCKSDB_DISABLE_2PC
SET @@global.ROCKSDB_ENABLE_2PC = DEFAULT;
SELECT @@global.ROCKSDB_ENABLE_2PC;
@@global.ROCKSDB_ENABLE_2PC
1
"Trying to set variable @@session.ROCKSDB_DISABLE_2PC to 444. It should fail because it is not session."
SET @@session.ROCKSDB_DISABLE_2PC = 444;
ERROR HY000: Variable 'rocksdb_disable_2pc' is a GLOBAL variable and should be set with SET GLOBAL
"Trying to set variable @@session.ROCKSDB_ENABLE_2PC to 444. It should fail because it is not session."
SET @@session.ROCKSDB_ENABLE_2PC = 444;
ERROR HY000: Variable 'rocksdb_enable_2pc' is a GLOBAL variable and should be set with SET GLOBAL
'# Testing with invalid values in global scope #'
"Trying to set variable @@global.ROCKSDB_DISABLE_2PC to 'aaa'"
SET @@global.ROCKSDB_DISABLE_2PC = 'aaa';
"Trying to set variable @@global.ROCKSDB_ENABLE_2PC to 'aaa'"
SET @@global.ROCKSDB_ENABLE_2PC = 'aaa';
Got one of the listed errors
SELECT @@global.ROCKSDB_DISABLE_2PC;
@@global.ROCKSDB_DISABLE_2PC
SELECT @@global.ROCKSDB_ENABLE_2PC;
@@global.ROCKSDB_ENABLE_2PC
1
"Trying to set variable @@global.ROCKSDB_DISABLE_2PC to 'bbb'"
SET @@global.ROCKSDB_DISABLE_2PC = 'bbb';
"Trying to set variable @@global.ROCKSDB_ENABLE_2PC to 'bbb'"
SET @@global.ROCKSDB_ENABLE_2PC = 'bbb';
Got one of the listed errors
SELECT @@global.ROCKSDB_DISABLE_2PC;
@@global.ROCKSDB_DISABLE_2PC
SELECT @@global.ROCKSDB_ENABLE_2PC;
@@global.ROCKSDB_ENABLE_2PC
1
SET @@global.ROCKSDB_DISABLE_2PC = @start_global_value;
SELECT @@global.ROCKSDB_DISABLE_2PC;
@@global.ROCKSDB_DISABLE_2PC
SET @@global.ROCKSDB_ENABLE_2PC = @start_global_value;
SELECT @@global.ROCKSDB_ENABLE_2PC;
@@global.ROCKSDB_ENABLE_2PC
1
DROP TABLE valid_values;
DROP TABLE invalid_values;
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO valid_values VALUES(1);
INSERT INTO valid_values VALUES(64);
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO invalid_values VALUES('\'abc\'');
SET @start_global_value = @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS;
SELECT @start_global_value;
@start_global_value
1
"Trying to set variable @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS to 444. It should fail because it is readonly."
SET @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS = 444;
ERROR HY000: Variable 'rocksdb_max_background_compactions' is a read only variable
'# Setting to valid values in global scope#'
"Trying to set variable @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS to 1"
SET @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS = 1;
SELECT @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS;
@@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS
1
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS = DEFAULT;
SELECT @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS;
@@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS
1
"Trying to set variable @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS to 64"
SET @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS = 64;
SELECT @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS;
@@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS
64
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS = DEFAULT;
SELECT @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS;
@@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS
1
"Trying to set variable @@session.ROCKSDB_MAX_BACKGROUND_COMPACTIONS to 444. It should fail because it is not session."
SET @@session.ROCKSDB_MAX_BACKGROUND_COMPACTIONS = 444;
ERROR HY000: Variable 'rocksdb_max_background_compactions' is a GLOBAL variable and should be set with SET GLOBAL
'# Testing with invalid values in global scope #'
"Trying to set variable @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS to 'abc'"
SET @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS = 'abc';
Got one of the listed errors
SELECT @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS;
@@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS
1
SET @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS = @start_global_value;
SELECT @@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS;
@@global.ROCKSDB_MAX_BACKGROUND_COMPACTIONS
1
DROP TABLE valid_values;
DROP TABLE invalid_values;
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO valid_values VALUES('abc');
INSERT INTO valid_values VALUES('def');
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
SET @start_global_value = @@global.ROCKSDB_PERSISTENT_CACHE_PATH;
SELECT @start_global_value;
@start_global_value
"Trying to set variable @@global.ROCKSDB_PERSISTENT_CACHE_PATH to 444. It should fail because it is readonly."
SET @@global.ROCKSDB_PERSISTENT_CACHE_PATH = 444;
ERROR HY000: Variable 'rocksdb_persistent_cache_path' is a read only variable
DROP TABLE valid_values;
DROP TABLE invalid_values;
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO valid_values VALUES(1);
INSERT INTO valid_values VALUES(1024);
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO invalid_values VALUES('\'aaa\'');
SET @start_global_value = @@global.ROCKSDB_PERSISTENT_CACHE_SIZE;
SELECT @start_global_value;
@start_global_value
0
"Trying to set variable @@global.ROCKSDB_PERSISTENT_CACHE_SIZE to 444. It should fail because it is readonly."
SET @@global.ROCKSDB_PERSISTENT_CACHE_SIZE = 444;
ERROR HY000: Variable 'rocksdb_persistent_cache_size' is a read only variable
DROP TABLE valid_values;
DROP TABLE invalid_values;
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO valid_values VALUES(1);
INSERT INTO valid_values VALUES(0);
INSERT INTO valid_values VALUES('on');
INSERT INTO valid_values VALUES('off');
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO invalid_values VALUES('\'aaa\'');
SET @start_global_value = @@global.ROCKSDB_RPL_SKIP_TX_API;
SELECT @start_global_value;
@start_global_value
1
'# Setting to valid values in global scope#'
"Trying to set variable @@global.ROCKSDB_RPL_SKIP_TX_API to 1"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = 1;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = DEFAULT;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
"Trying to set variable @@global.ROCKSDB_RPL_SKIP_TX_API to 0"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = 0;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
0
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = DEFAULT;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
"Trying to set variable @@global.ROCKSDB_RPL_SKIP_TX_API to on"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = on;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = DEFAULT;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
"Trying to set variable @@global.ROCKSDB_RPL_SKIP_TX_API to off"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = off;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
0
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = DEFAULT;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
"Trying to set variable @@session.ROCKSDB_RPL_SKIP_TX_API to 444. It should fail because it is not session."
SET @@session.ROCKSDB_RPL_SKIP_TX_API = 444;
ERROR HY000: Variable 'rocksdb_rpl_skip_tx_api' is a GLOBAL variable and should be set with SET GLOBAL
'# Testing with invalid values in global scope #'
"Trying to set variable @@global.ROCKSDB_RPL_SKIP_TX_API to 'aaa'"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = 'aaa';
Got one of the listed errors
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
SET @@global.ROCKSDB_RPL_SKIP_TX_API = @start_global_value;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
DROP TABLE valid_values;
DROP TABLE invalid_values;
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO valid_values VALUES(0);
INSERT INTO valid_values VALUES(1);
INSERT INTO valid_values VALUES('on');
INSERT INTO valid_values VALUES('off');
INSERT INTO valid_values VALUES('true');
INSERT INTO valid_values VALUES('false');
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO invalid_values VALUES('\'aaa\'');
INSERT INTO invalid_values VALUES('\'bbb\'');
SET @start_global_value = @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
SELECT @start_global_value;
@start_global_value
0
SET @start_session_value = @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
SELECT @start_session_value;
@start_session_value
0
'# Setting to valid values in global scope#'
"Trying to set variable @@global.ROCKSDB_SKIP_UNIQUE_CHECK to 0"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = 0;
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = DEFAULT;
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Trying to set variable @@global.ROCKSDB_SKIP_UNIQUE_CHECK to 1"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = 1;
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
1
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = DEFAULT;
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Trying to set variable @@global.ROCKSDB_SKIP_UNIQUE_CHECK to on"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = on;
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
1
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = DEFAULT;
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Trying to set variable @@global.ROCKSDB_SKIP_UNIQUE_CHECK to off"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = off;
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = DEFAULT;
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Trying to set variable @@global.ROCKSDB_SKIP_UNIQUE_CHECK to true"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = true;
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
1
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = DEFAULT;
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Trying to set variable @@global.ROCKSDB_SKIP_UNIQUE_CHECK to false"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = false;
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = DEFAULT;
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
0
'# Setting to valid values in session scope#'
"Trying to set variable @@session.ROCKSDB_SKIP_UNIQUE_CHECK to 0"
SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK = 0;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Setting the session scope variable back to default"
SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK = DEFAULT;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Trying to set variable @@session.ROCKSDB_SKIP_UNIQUE_CHECK to 1"
SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK = 1;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK
1
"Setting the session scope variable back to default"
SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK = DEFAULT;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Trying to set variable @@session.ROCKSDB_SKIP_UNIQUE_CHECK to on"
SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK = on;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK
1
"Setting the session scope variable back to default"
SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK = DEFAULT;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Trying to set variable @@session.ROCKSDB_SKIP_UNIQUE_CHECK to off"
SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK = off;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Setting the session scope variable back to default"
SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK = DEFAULT;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Trying to set variable @@session.ROCKSDB_SKIP_UNIQUE_CHECK to true"
SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK = true;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK
1
"Setting the session scope variable back to default"
SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK = DEFAULT;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Trying to set variable @@session.ROCKSDB_SKIP_UNIQUE_CHECK to false"
SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK = false;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Setting the session scope variable back to default"
SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK = DEFAULT;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK
0
'# Testing with invalid values in global scope #'
"Trying to set variable @@global.ROCKSDB_SKIP_UNIQUE_CHECK to 'aaa'"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = 'aaa';
Got one of the listed errors
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
0
"Trying to set variable @@global.ROCKSDB_SKIP_UNIQUE_CHECK to 'bbb'"
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = 'bbb';
Got one of the listed errors
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
0
SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK = @start_global_value;
SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK;
@@global.ROCKSDB_SKIP_UNIQUE_CHECK
0
SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK = @start_session_value;
SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK;
@@session.ROCKSDB_SKIP_UNIQUE_CHECK
0
DROP TABLE valid_values;
DROP TABLE invalid_values;
......@@ -10,7 +10,7 @@ CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO invalid_values VALUES('\'aaa\'');
INSERT INTO invalid_values VALUES('\'bbb\'');
--let $sys_var=ROCKSDB_DISABLE_2PC
--let $sys_var=ROCKSDB_ENABLE_2PC
--let $read_only=0
--let $session=0
--let $sticky=1
......
--source include/have_rocksdb.inc
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO valid_values VALUES(1);
INSERT INTO valid_values VALUES(64);
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO invalid_values VALUES('\'abc\'');
--let $sys_var=ROCKSDB_MAX_BACKGROUND_COMPACTIONS
--let $read_only=1
--let $read_only=0
--let $session=0
--source suite/sys_vars/inc/rocksdb_sys_var.inc
DROP TABLE valid_values;
DROP TABLE invalid_values;
--source include/have_rocksdb.inc
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO valid_values VALUES(0);
INSERT INTO valid_values VALUES(1);
INSERT INTO valid_values VALUES('on');
INSERT INTO valid_values VALUES('off');
INSERT INTO valid_values VALUES('true');
INSERT INTO valid_values VALUES('false');
INSERT INTO valid_values VALUES('abc');
INSERT INTO valid_values VALUES('def');
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO invalid_values VALUES('\'aaa\'');
INSERT INTO invalid_values VALUES('\'bbb\'');
--let $sys_var=ROCKSDB_SKIP_UNIQUE_CHECK
--let $read_only=0
--let $session=1
--let $sys_var=ROCKSDB_PERSISTENT_CACHE_PATH
--let $read_only=1
--let $session=0
--let $sticky=1
--source suite/sys_vars/inc/rocksdb_sys_var.inc
DROP TABLE valid_values;
......
......@@ -2,15 +2,13 @@
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO valid_values VALUES(1);
INSERT INTO valid_values VALUES(0);
INSERT INTO valid_values VALUES('on');
INSERT INTO valid_values VALUES('off');
INSERT INTO valid_values VALUES(1024);
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO invalid_values VALUES('\'aaa\'');
--let $sys_var=ROCKSDB_RPL_SKIP_TX_API
--let $read_only=0
--let $sys_var=ROCKSDB_PERSISTENT_CACHE_SIZE
--let $read_only=1
--let $session=0
--source suite/sys_vars/inc/rocksdb_sys_var.inc
......
This diff is collapsed.
......@@ -40,102 +40,87 @@ extern std::atomic<uint64_t> rocksdb_num_sst_entry_merge;
extern std::atomic<uint64_t> rocksdb_num_sst_entry_other;
extern my_bool rocksdb_compaction_sequential_deletes_count_sd;
struct Rdb_compact_params
{
struct Rdb_compact_params {
uint64_t m_deletes, m_window, m_file_size;
};
struct Rdb_index_stats
{
enum {
INDEX_STATS_VERSION_INITIAL= 1,
INDEX_STATS_VERSION_ENTRY_TYPES= 2,
struct Rdb_index_stats {
enum {
INDEX_STATS_VERSION_INITIAL = 1,
INDEX_STATS_VERSION_ENTRY_TYPES = 2,
};
GL_INDEX_ID m_gl_index_id;
int64_t m_data_size, m_rows, m_actual_disk_size;
int64_t m_entry_deletes, m_entry_single_deletes;
int64_t m_entry_merges, m_entry_others;
std::vector<int64_t> m_distinct_keys_per_prefix;
std::string m_name; // name is not persisted
std::string m_name; // name is not persisted
static std::string materialize(const std::vector<Rdb_index_stats>& stats,
static std::string materialize(const std::vector<Rdb_index_stats> &stats,
const float card_adj_extra);
static int unmaterialize(const std::string& s,
std::vector<Rdb_index_stats>* const ret);
static int unmaterialize(const std::string &s,
std::vector<Rdb_index_stats> *const ret);
Rdb_index_stats() : Rdb_index_stats({0, 0}) {}
explicit Rdb_index_stats(GL_INDEX_ID gl_index_id) :
m_gl_index_id(gl_index_id),
m_data_size(0),
m_rows(0),
m_actual_disk_size(0),
m_entry_deletes(0),
m_entry_single_deletes(0),
m_entry_merges(0),
m_entry_others(0) {}
void merge(const Rdb_index_stats& s, const bool &increment = true,
explicit Rdb_index_stats(GL_INDEX_ID gl_index_id)
: m_gl_index_id(gl_index_id), m_data_size(0), m_rows(0),
m_actual_disk_size(0), m_entry_deletes(0), m_entry_single_deletes(0),
m_entry_merges(0), m_entry_others(0) {}
void merge(const Rdb_index_stats &s, const bool &increment = true,
const int64_t &estimated_data_len = 0);
};
class Rdb_tbl_prop_coll : public rocksdb::TablePropertiesCollector
{
public:
Rdb_tbl_prop_coll(
Rdb_ddl_manager* const ddl_manager,
const Rdb_compact_params &params,
const uint32_t &cf_id,
const uint8_t &table_stats_sampling_pct
);
class Rdb_tbl_prop_coll : public rocksdb::TablePropertiesCollector {
public:
Rdb_tbl_prop_coll(Rdb_ddl_manager *const ddl_manager,
const Rdb_compact_params &params, const uint32_t &cf_id,
const uint8_t &table_stats_sampling_pct);
/*
Override parent class's virtual methods of interest.
*/
virtual rocksdb::Status AddUserKey(
const rocksdb::Slice& key, const rocksdb::Slice& value,
rocksdb::EntryType type, rocksdb::SequenceNumber seq,
uint64_t file_size);
virtual rocksdb::Status AddUserKey(const rocksdb::Slice &key,
const rocksdb::Slice &value,
rocksdb::EntryType type,
rocksdb::SequenceNumber seq,
uint64_t file_size);
virtual rocksdb::Status Finish(rocksdb::UserCollectedProperties* properties) override;
virtual rocksdb::Status
Finish(rocksdb::UserCollectedProperties *properties) override;
virtual const char* Name() const override {
return "Rdb_tbl_prop_coll";
}
virtual const char *Name() const override { return "Rdb_tbl_prop_coll"; }
rocksdb::UserCollectedProperties GetReadableProperties() const override;
bool NeedCompact() const override;
public:
uint64_t GetMaxDeletedRows() const {
return m_max_deleted_rows;
}
public:
uint64_t GetMaxDeletedRows() const { return m_max_deleted_rows; }
static void read_stats_from_tbl_props(
const std::shared_ptr<const rocksdb::TableProperties>& table_props,
std::vector<Rdb_index_stats>* out_stats_vector);
const std::shared_ptr<const rocksdb::TableProperties> &table_props,
std::vector<Rdb_index_stats> *out_stats_vector);
private:
static std::string GetReadableStats(const Rdb_index_stats& it);
private:
static std::string GetReadableStats(const Rdb_index_stats &it);
bool ShouldCollectStats();
void CollectStatsForRow(const rocksdb::Slice& key,
const rocksdb::Slice& value, const rocksdb::EntryType &type,
const uint64_t &file_size);
Rdb_index_stats* AccessStats(const rocksdb::Slice& key);
void CollectStatsForRow(const rocksdb::Slice &key,
const rocksdb::Slice &value,
const rocksdb::EntryType &type,
const uint64_t &file_size);
Rdb_index_stats *AccessStats(const rocksdb::Slice &key);
void AdjustDeletedRows(rocksdb::EntryType type);
private:
private:
uint32_t m_cf_id;
std::shared_ptr<const Rdb_key_def> m_keydef;
Rdb_ddl_manager* m_ddl_manager;
Rdb_ddl_manager *m_ddl_manager;
std::vector<Rdb_index_stats> m_stats;
Rdb_index_stats* m_last_stats;
static const char* INDEXSTATS_KEY;
Rdb_index_stats *m_last_stats;
static const char *INDEXSTATS_KEY;
// last added key
std::string m_last_key;
......@@ -150,34 +135,33 @@ class Rdb_tbl_prop_coll : public rocksdb::TablePropertiesCollector
float m_card_adj_extra;
};
class Rdb_tbl_prop_coll_factory
: public rocksdb::TablePropertiesCollectorFactory {
public:
Rdb_tbl_prop_coll_factory(const Rdb_tbl_prop_coll_factory&) = delete;
Rdb_tbl_prop_coll_factory& operator=(const Rdb_tbl_prop_coll_factory&) = delete;
public:
Rdb_tbl_prop_coll_factory(const Rdb_tbl_prop_coll_factory &) = delete;
Rdb_tbl_prop_coll_factory &
operator=(const Rdb_tbl_prop_coll_factory &) = delete;
explicit Rdb_tbl_prop_coll_factory(Rdb_ddl_manager* ddl_manager)
: m_ddl_manager(ddl_manager) {
}
explicit Rdb_tbl_prop_coll_factory(Rdb_ddl_manager *ddl_manager)
: m_ddl_manager(ddl_manager) {}
/*
Override parent class's virtual methods of interest.
*/
virtual rocksdb::TablePropertiesCollector* CreateTablePropertiesCollector(
virtual rocksdb::TablePropertiesCollector *CreateTablePropertiesCollector(
rocksdb::TablePropertiesCollectorFactory::Context context) override {
return new Rdb_tbl_prop_coll(
m_ddl_manager, m_params, context.column_family_id,
m_table_stats_sampling_pct);
return new Rdb_tbl_prop_coll(m_ddl_manager, m_params,
context.column_family_id,
m_table_stats_sampling_pct);
}
virtual const char* Name() const override {
virtual const char *Name() const override {
return "Rdb_tbl_prop_coll_factory";
}
public:
void SetCompactionParams(const Rdb_compact_params& params) {
public:
void SetCompactionParams(const Rdb_compact_params &params) {
m_params = params;
}
......@@ -185,10 +169,10 @@ class Rdb_tbl_prop_coll_factory
m_table_stats_sampling_pct = table_stats_sampling_pct;
}
private:
Rdb_ddl_manager* const m_ddl_manager;
private:
Rdb_ddl_manager *const m_ddl_manager;
Rdb_compact_params m_params;
uint8_t m_table_stats_sampling_pct;
};
} // namespace myrocks
} // namespace myrocks
This diff is collapsed.
......@@ -15,7 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#pragma implementation // gcc: Class implementation
#endif
/* This C++ files header file */
......@@ -28,8 +28,7 @@
namespace myrocks {
/* Check if ColumnFamily name says it's a reverse-ordered CF */
bool Rdb_cf_manager::is_cf_name_reverse(const char* const name)
{
bool Rdb_cf_manager::is_cf_name_reverse(const char *const name) {
/* nullptr means the default CF is used.. (TODO: can the default CF be
* reverse?) */
if (name && !strncmp(name, "rev:", 4))
......@@ -43,9 +42,8 @@ static PSI_mutex_key ex_key_cfm;
#endif
void Rdb_cf_manager::init(
Rdb_cf_options* const cf_options,
std::vector<rocksdb::ColumnFamilyHandle*>* const handles)
{
Rdb_cf_options *const cf_options,
std::vector<rocksdb::ColumnFamilyHandle *> *const handles) {
mysql_mutex_init(ex_key_cfm, &m_mutex, MY_MUTEX_INIT_FAST);
DBUG_ASSERT(cf_options != nullptr);
......@@ -61,33 +59,28 @@ void Rdb_cf_manager::init(
}
}
void Rdb_cf_manager::cleanup()
{
void Rdb_cf_manager::cleanup() {
for (auto it : m_cf_name_map) {
delete it.second;
}
mysql_mutex_destroy(&m_mutex);
}
/**
Generate Column Family name for per-index column families
@param res OUT Column Family name
*/
void Rdb_cf_manager::get_per_index_cf_name(const std::string& db_table_name,
const char* const index_name,
std::string* const res)
{
void Rdb_cf_manager::get_per_index_cf_name(const std::string &db_table_name,
const char *const index_name,
std::string *const res) {
DBUG_ASSERT(index_name != nullptr);
DBUG_ASSERT(res != nullptr);
*res = db_table_name + "." + index_name;
}
/*
@brief
Find column family by name. If it doesn't exist, create it
......@@ -95,53 +88,50 @@ void Rdb_cf_manager::get_per_index_cf_name(const std::string& db_table_name,
@detail
See Rdb_cf_manager::get_cf
*/
rocksdb::ColumnFamilyHandle*
Rdb_cf_manager::get_or_create_cf(rocksdb::DB* const rdb,
const char *cf_name,
const std::string& db_table_name,
const char* const index_name,
bool* const is_automatic)
{
rocksdb::ColumnFamilyHandle *
Rdb_cf_manager::get_or_create_cf(rocksdb::DB *const rdb, const char *cf_name,
const std::string &db_table_name,
const char *const index_name,
bool *const is_automatic) {
DBUG_ASSERT(rdb != nullptr);
DBUG_ASSERT(is_automatic != nullptr);
rocksdb::ColumnFamilyHandle* cf_handle;
rocksdb::ColumnFamilyHandle *cf_handle;
mysql_mutex_lock(&m_mutex);
*is_automatic= false;
*is_automatic = false;
if (cf_name == nullptr)
cf_name= DEFAULT_CF_NAME;
cf_name = DEFAULT_CF_NAME;
std::string per_index_name;
if (!strcmp(cf_name, PER_INDEX_CF_NAME))
{
if (!strcmp(cf_name, PER_INDEX_CF_NAME)) {
get_per_index_cf_name(db_table_name, index_name, &per_index_name);
cf_name= per_index_name.c_str();
*is_automatic= true;
cf_name = per_index_name.c_str();
*is_automatic = true;
}
const auto it = m_cf_name_map.find(cf_name);
if (it != m_cf_name_map.end())
cf_handle= it->second;
else
{
cf_handle = it->second;
else {
/* Create a Column Family. */
const std::string cf_name_str(cf_name);
rocksdb::ColumnFamilyOptions opts;
m_cf_options->get_cf_options(cf_name_str, &opts);
sql_print_information("RocksDB: creating column family %s", cf_name_str.c_str());
sql_print_information(" write_buffer_size=%ld", opts.write_buffer_size);
sql_print_information("RocksDB: creating column family %s",
cf_name_str.c_str());
sql_print_information(" write_buffer_size=%ld", opts.write_buffer_size);
sql_print_information(" target_file_size_base=%" PRIu64,
opts.target_file_size_base);
const rocksdb::Status s=
rdb->CreateColumnFamily(opts, cf_name_str, &cf_handle);
const rocksdb::Status s =
rdb->CreateColumnFamily(opts, cf_name_str, &cf_handle);
if (s.ok()) {
m_cf_name_map[cf_handle->GetName()] = cf_handle;
m_cf_id_map[cf_handle->GetID()] = cf_handle;
} else {
cf_handle= nullptr;
cf_handle = nullptr;
}
}
mysql_mutex_unlock(&m_mutex);
......@@ -149,7 +139,6 @@ Rdb_cf_manager::get_or_create_cf(rocksdb::DB* const rdb,
return cf_handle;
}
/*
Find column family by its cf_name.
......@@ -162,27 +151,24 @@ Rdb_cf_manager::get_or_create_cf(rocksdb::DB* const rdb,
db_table_name and index_name.
*/
rocksdb::ColumnFamilyHandle*
Rdb_cf_manager::get_cf(const char *cf_name,
const std::string& db_table_name,
const char* const index_name,
bool* const is_automatic) const
{
rocksdb::ColumnFamilyHandle *
Rdb_cf_manager::get_cf(const char *cf_name, const std::string &db_table_name,
const char *const index_name,
bool *const is_automatic) const {
DBUG_ASSERT(is_automatic != nullptr);
rocksdb::ColumnFamilyHandle* cf_handle;
rocksdb::ColumnFamilyHandle *cf_handle;
*is_automatic= false;
*is_automatic = false;
mysql_mutex_lock(&m_mutex);
if (cf_name == nullptr)
cf_name= DEFAULT_CF_NAME;
cf_name = DEFAULT_CF_NAME;
std::string per_index_name;
if (!strcmp(cf_name, PER_INDEX_CF_NAME))
{
if (!strcmp(cf_name, PER_INDEX_CF_NAME)) {
get_per_index_cf_name(db_table_name, index_name, &per_index_name);
cf_name= per_index_name.c_str();
*is_automatic= true;
cf_name = per_index_name.c_str();
*is_automatic = true;
}
const auto it = m_cf_name_map.find(cf_name);
......@@ -193,9 +179,8 @@ Rdb_cf_manager::get_cf(const char *cf_name,
return cf_handle;
}
rocksdb::ColumnFamilyHandle* Rdb_cf_manager::get_cf(const uint32_t &id) const
{
rocksdb::ColumnFamilyHandle* cf_handle = nullptr;
rocksdb::ColumnFamilyHandle *Rdb_cf_manager::get_cf(const uint32_t &id) const {
rocksdb::ColumnFamilyHandle *cf_handle = nullptr;
mysql_mutex_lock(&m_mutex);
const auto it = m_cf_id_map.find(id);
......@@ -206,9 +191,7 @@ rocksdb::ColumnFamilyHandle* Rdb_cf_manager::get_cf(const uint32_t &id) const
return cf_handle;
}
std::vector<std::string>
Rdb_cf_manager::get_cf_names(void) const
{
std::vector<std::string> Rdb_cf_manager::get_cf_names(void) const {
std::vector<std::string> names;
mysql_mutex_lock(&m_mutex);
......@@ -219,10 +202,9 @@ Rdb_cf_manager::get_cf_names(void) const
return names;
}
std::vector<rocksdb::ColumnFamilyHandle*>
Rdb_cf_manager::get_all_cf(void) const
{
std::vector<rocksdb::ColumnFamilyHandle*> list;
std::vector<rocksdb::ColumnFamilyHandle *>
Rdb_cf_manager::get_all_cf(void) const {
std::vector<rocksdb::ColumnFamilyHandle *> list;
mysql_mutex_lock(&m_mutex);
for (auto it : m_cf_id_map) {
......@@ -233,4 +215,4 @@ Rdb_cf_manager::get_all_cf(void) const
return list;
}
} // namespace myrocks
} // namespace myrocks
......@@ -46,33 +46,32 @@ namespace myrocks {
- CFs are created in a synchronized way. We can't remove them, yet.
*/
class Rdb_cf_manager
{
std::map<std::string, rocksdb::ColumnFamilyHandle*> m_cf_name_map;
std::map<uint32_t, rocksdb::ColumnFamilyHandle*> m_cf_id_map;
class Rdb_cf_manager {
std::map<std::string, rocksdb::ColumnFamilyHandle *> m_cf_name_map;
std::map<uint32_t, rocksdb::ColumnFamilyHandle *> m_cf_id_map;
mutable mysql_mutex_t m_mutex;
static
void get_per_index_cf_name(const std::string& db_table_name,
const char* const index_name,
std::string* const res);
static void get_per_index_cf_name(const std::string &db_table_name,
const char *const index_name,
std::string *const res);
Rdb_cf_options* m_cf_options= nullptr;
Rdb_cf_options *m_cf_options = nullptr;
public:
Rdb_cf_manager(const Rdb_cf_manager&) = delete;
Rdb_cf_manager& operator=(const Rdb_cf_manager&) = delete;
Rdb_cf_manager(const Rdb_cf_manager &) = delete;
Rdb_cf_manager &operator=(const Rdb_cf_manager &) = delete;
Rdb_cf_manager() = default;
static bool is_cf_name_reverse(const char* const name);
static bool is_cf_name_reverse(const char *const name);
/*
This is called right after the DB::Open() call. The parameters describe column
This is called right after the DB::Open() call. The parameters describe
column
families that are present in the database. The first CF is the default CF.
*/
void init(Rdb_cf_options* cf_options,
std::vector<rocksdb::ColumnFamilyHandle*>* const handles);
void init(Rdb_cf_options *cf_options,
std::vector<rocksdb::ColumnFamilyHandle *> *const handles);
void cleanup();
/*
......@@ -80,33 +79,33 @@ class Rdb_cf_manager
- cf_name=nullptr means use default column family
- cf_name=_auto_ means use 'dbname.tablename.indexname'
*/
rocksdb::ColumnFamilyHandle* get_or_create_cf(
rocksdb::DB* const rdb, const char *cf_name,
const std::string& db_table_name, const char* const index_name,
bool* const is_automatic);
rocksdb::ColumnFamilyHandle *
get_or_create_cf(rocksdb::DB *const rdb, const char *cf_name,
const std::string &db_table_name,
const char *const index_name, bool *const is_automatic);
/* Used by table open */
rocksdb::ColumnFamilyHandle* get_cf(const char *cf_name,
const std::string& db_table_name,
const char* const index_name,
bool* const is_automatic) const;
rocksdb::ColumnFamilyHandle *get_cf(const char *cf_name,
const std::string &db_table_name,
const char *const index_name,
bool *const is_automatic) const;
/* Look up cf by id; used by datadic */
rocksdb::ColumnFamilyHandle* get_cf(const uint32_t &id) const;
rocksdb::ColumnFamilyHandle *get_cf(const uint32_t &id) const;
/* Used to iterate over column families for show status */
std::vector<std::string> get_cf_names(void) const;
/* Used to iterate over column families */
std::vector<rocksdb::ColumnFamilyHandle*> get_all_cf(void) const;
std::vector<rocksdb::ColumnFamilyHandle *> get_all_cf(void) const;
// void drop_cf(); -- not implemented so far.
void get_cf_options(
const std::string &cf_name,
rocksdb::ColumnFamilyOptions* const opts) __attribute__((__nonnull__)) {
m_cf_options->get_cf_options(cf_name, opts);
void get_cf_options(const std::string &cf_name,
rocksdb::ColumnFamilyOptions *const opts)
MY_ATTRIBUTE((__nonnull__)) {
m_cf_options->get_cf_options(cf_name, opts);
}
};
} // namespace myrocks
} // namespace myrocks
This diff is collapsed.
......@@ -38,47 +38,47 @@ namespace myrocks {
and also there is a default value which applies to column
families not found in the map.
*/
class Rdb_cf_options
{
public:
Rdb_cf_options(const Rdb_cf_options&) = delete;
Rdb_cf_options& operator=(const Rdb_cf_options&) = delete;
class Rdb_cf_options {
public:
Rdb_cf_options(const Rdb_cf_options &) = delete;
Rdb_cf_options &operator=(const Rdb_cf_options &) = delete;
Rdb_cf_options() = default;
void get(const std::string &cf_name, rocksdb::ColumnFamilyOptions* const opts);
void get(const std::string &cf_name,
rocksdb::ColumnFamilyOptions *const opts);
bool init(
const rocksdb::BlockBasedTableOptions& table_options,
std::shared_ptr<rocksdb::TablePropertiesCollectorFactory> prop_coll_factory,
const char* const default_cf_options,
const char* const override_cf_options);
bool init(const rocksdb::BlockBasedTableOptions &table_options,
std::shared_ptr<rocksdb::TablePropertiesCollectorFactory>
prop_coll_factory,
const char *const default_cf_options,
const char *const override_cf_options);
const rocksdb::ColumnFamilyOptions& get_defaults() const {
const rocksdb::ColumnFamilyOptions &get_defaults() const {
return m_default_cf_opts;
}
static const rocksdb::Comparator* get_cf_comparator(
const std::string& cf_name);
static const rocksdb::Comparator *
get_cf_comparator(const std::string &cf_name);
void get_cf_options(
const std::string &cf_name,
rocksdb::ColumnFamilyOptions* const opts) __attribute__((__nonnull__));
void get_cf_options(const std::string &cf_name,
rocksdb::ColumnFamilyOptions *const opts)
MY_ATTRIBUTE((__nonnull__));
private:
private:
bool set_default(const std::string &default_config);
bool set_override(const std::string &overide_config);
/* Helper string manipulation functions */
static void skip_spaces(const std::string& input, size_t* const pos);
static bool find_column_family(const std::string& input, size_t* const pos,
std::string* const key);
static bool find_options(const std::string& input, size_t* const pos,
std::string* const options);
static bool find_cf_options_pair(const std::string& input, size_t* const pos,
std::string* const cf,
std::string* const opt_str);
private:
static void skip_spaces(const std::string &input, size_t *const pos);
static bool find_column_family(const std::string &input, size_t *const pos,
std::string *const key);
static bool find_options(const std::string &input, size_t *const pos,
std::string *const options);
static bool find_cf_options_pair(const std::string &input, size_t *const pos,
std::string *const cf,
std::string *const opt_str);
private:
static Rdb_pk_comparator s_pk_comparator;
static Rdb_rev_comparator s_rev_pk_comparator;
......@@ -93,4 +93,4 @@ class Rdb_cf_options
rocksdb::ColumnFamilyOptions m_default_cf_opts;
};
} // namespace myrocks
} // namespace myrocks
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -26,10 +26,10 @@ extern struct st_mysql_plugin rdb_i_s_dbstats;
extern struct st_mysql_plugin rdb_i_s_perf_context;
extern struct st_mysql_plugin rdb_i_s_perf_context_global;
extern struct st_mysql_plugin rdb_i_s_cfoptions;
extern struct st_mysql_plugin rdb_i_s_compact_stats;
extern struct st_mysql_plugin rdb_i_s_global_info;
extern struct st_mysql_plugin rdb_i_s_ddl;
extern struct st_mysql_plugin rdb_i_s_index_file_map;
extern struct st_mysql_plugin rdb_i_s_lock_info;
extern struct st_mysql_plugin rdb_i_s_trx_info;
} // namespace myrocks
} // namespace myrocks
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment