Commit 43d5edf9 authored by Sergei Petrunia's avatar Sergei Petrunia

Copy of

commit 394d0712d3d46a87a8063e14e998e9c22336e3a6
Author: Anca Agape <anca@fb.com>
Date:   Thu Jul 27 15:43:07 2017 -0700

    Fix rpl.rpl_4threads_deadlock test broken by D5005670

    Summary:
    In D5005670 in fill_fields_processlist() function we introduced a point
    where we were trying to take the LOCK_thd_data before the
    synchronization point used by test
    processlist_after_LOCK_thd_count_before_LOCK_thd_data. This was
    happening in get_attached_srv_session() function called. Replaced this
    with get_attached_srv_session_safe() and moved it after lock is aquired.

    Reviewed By: tianx

    Differential Revision: D5505992

    fbshipit-source-id: bc53924
parent 65d01da2
...@@ -6,7 +6,7 @@ ENDIF() ...@@ -6,7 +6,7 @@ ENDIF()
CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU) CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU)
IF(HAVE_SCHED_GETCPU) IF(HAVE_SCHED_GETCPU)
ADD_DEFINITIONS(-DHAVE_SCHED_GETCPU=1) ADD_DEFINITIONS(-DHAVE_SCHED_GETCPU=1 -DROCKSDB_SCHED_GETCPU_PRESENT)
ENDIF() ENDIF()
# get a list of rocksdb library source files # get a list of rocksdb library source files
...@@ -25,14 +25,34 @@ INCLUDE_DIRECTORIES( ...@@ -25,14 +25,34 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/rocksdb/third-party/gtest-1.7.0/fused-src ${CMAKE_SOURCE_DIR}/rocksdb/third-party/gtest-1.7.0/fused-src
) )
ADD_DEFINITIONS(-DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX # This is a strong requirement coming from RocksDB. No conditional checks here.
-DZLIB) ADD_DEFINITIONS(-DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX)
CHECK_FUNCTION_EXISTS(fallocate HAVE_FALLOCATE) IF(UNIX)
IF(HAVE_FALLOCATE) IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
ADD_DEFINITIONS(-DOS_LINUX)
CHECK_INCLUDE_FILES(linux/falloc.h HAVE_LINUX_FALLOC_H)
CHECK_FUNCTION_EXISTS(fallocate HAVE_FALLOCATE)
IF(HAVE_FALLOCATE AND HAVE_LINUX_FALLOC_H)
ADD_DEFINITIONS(-DROCKSDB_FALLOCATE_PRESENT) ADD_DEFINITIONS(-DROCKSDB_FALLOCATE_PRESENT)
ENDIF()
ENDIF()
ENDIF() ENDIF()
CHECK_CXX_SOURCE_COMPILES("
#if defined(_MSC_VER) && !defined(__thread)
#define __thread __declspec(thread)
#endif
int main() {
static __thread int tls;
}
" HAVE_THREAD_LOCAL)
if(HAVE_THREAD_LOCAL)
ADD_DEFINITIONS(-DROCKSDB_SUPPORT_THREAD_LOCAL)
endif()
SET(ROCKSDB_SOURCES SET(ROCKSDB_SOURCES
ha_rocksdb.cc ha_rocksdb.h ha_rocksdb_proto.h ha_rocksdb.cc ha_rocksdb.h ha_rocksdb_proto.h
logger.h logger.h
...@@ -44,6 +64,7 @@ SET(ROCKSDB_SOURCES ...@@ -44,6 +64,7 @@ SET(ROCKSDB_SOURCES
event_listener.cc event_listener.h event_listener.cc event_listener.h
rdb_i_s.cc rdb_i_s.h rdb_i_s.cc rdb_i_s.h
rdb_index_merge.cc rdb_index_merge.h rdb_index_merge.cc rdb_index_merge.h
rdb_io_watchdog.cc rdb_io_watchdog.h
rdb_perf_context.cc rdb_perf_context.h rdb_perf_context.cc rdb_perf_context.h
rdb_mutex_wrapper.cc rdb_mutex_wrapper.h rdb_mutex_wrapper.cc rdb_mutex_wrapper.h
rdb_psi.h rdb_psi.cc rdb_psi.h rdb_psi.cc
...@@ -85,7 +106,14 @@ IF (NOT "$ENV{WITH_ZSTD}" STREQUAL "") ...@@ -85,7 +106,14 @@ IF (NOT "$ENV{WITH_ZSTD}" STREQUAL "")
ADD_DEFINITIONS(-DZSTD) ADD_DEFINITIONS(-DZSTD)
ENDIF() ENDIF()
SET(rocksdb_static_libs ${rocksdb_static_libs} ${ZLIB_LIBRARY} "-lrt") CHECK_INCLUDE_FILES(zlib.h HAVE_ZLIB_H)
IF (HAVE_ZLIB_H)
ADD_DEFINITIONS(-DZLIB)
SET(rocksdb_static_libs ${rocksdb_static_libs} ${ZLIB_LIBRARY})
ENDIF()
SET(rocksdb_static_libs ${rocksdb_static_libs} "-lrt")
MYSQL_ADD_PLUGIN(rocksdb_se ${ROCKSDB_SOURCES} STORAGE_ENGINE DEFAULT STATIC_ONLY MYSQL_ADD_PLUGIN(rocksdb_se ${ROCKSDB_SOURCES} STORAGE_ENGINE DEFAULT STATIC_ONLY
LINK_LIBRARIES ${rocksdb_static_libs} LINK_LIBRARIES ${rocksdb_static_libs}
......
== Summary == == Summary ==
This directory contains RocksDB-based Storage Engine (RDBSE) for MySQL = "MyRocks". This directory contains RocksDB-based Storage Engine (RDBSE) for MySQL,
also known as "MyRocks".
== Resources == == Resources ==
See https://github.com/facebook/mysql-5.6/wiki/Getting-Started-with-MyRocks https://github.com/facebook/mysql-5.6/wiki/Getting-Started-with-MyRocks
Facebook group: https://www.facebook.com/groups/mysqlonrocksdb/ https://www.facebook.com/groups/MyRocks/
== Coding Conventions == == Coding Conventions ==
The baseline for MyRocks coding conventions is the MySQL set, available at The baseline for MyRocks coding conventions for the code in storage/rocksdb/
is based on the default clang format with a few minor changes. The file
storage/rocksdb/.clang-format describes conventions and can be integrated
with Vim or Emacs as described here:
http://releases.llvm.org/3.6.0/tools/clang/docs/ClangFormat.html#vim-integration
All code outside of storage/rocksdb/ should conform to the MySQL coding
conventions:
http://dev.mysql.com/doc/internals/en/coding-guidelines.html. http://dev.mysql.com/doc/internals/en/coding-guidelines.html.
Several refinements: Several refinements:
...@@ -34,5 +42,9 @@ Several refinements: ...@@ -34,5 +42,9 @@ Several refinements:
"_vect" for a std::vector etc. "_vect" for a std::vector etc.
== Running Tests == == Running Tests ==
To run tests from rocksdb, rocksd_rpl or rocksdb_sys_vars packages, use the following parameters: To run tests from rocksdb, rocksdb_rpl or other rocksdb_* packages, use the
--mysqld=--default-storage-engine=rocksdb --mysqld=--skip-innodb --mysqld=--default-tmp-storage-engine=MyISAM --mysqld=--rocksdb following parameters:
\ No newline at end of file --default-storage-engine=rocksdb
--skip-innodb
--default-tmp-storage-engine=MyISAM
--rocksdb
This diff is collapsed.
This diff is collapsed.
...@@ -69,7 +69,18 @@ rocksdb::TransactionDB *rdb_get_rocksdb_db(); ...@@ -69,7 +69,18 @@ rocksdb::TransactionDB *rdb_get_rocksdb_db();
class Rdb_cf_manager; class Rdb_cf_manager;
Rdb_cf_manager &rdb_get_cf_manager(); Rdb_cf_manager &rdb_get_cf_manager();
rocksdb::BlockBasedTableOptions &rdb_get_table_options(); const rocksdb::BlockBasedTableOptions &rdb_get_table_options();
bool rdb_is_ttl_enabled();
bool rdb_is_ttl_read_filtering_enabled();
#ifndef NDEBUG
int rdb_dbug_set_ttl_rec_ts();
int rdb_dbug_set_ttl_snapshot_ts();
int rdb_dbug_set_ttl_read_filter_ts();
#endif
enum operation_type : int;
void rdb_update_global_stats(const operation_type &type, uint count,
bool is_system_table = false);
class Rdb_dict_manager; class Rdb_dict_manager;
Rdb_dict_manager *rdb_get_dict_manager(void) Rdb_dict_manager *rdb_get_dict_manager(void)
...@@ -82,5 +93,4 @@ Rdb_ddl_manager *rdb_get_ddl_manager(void) ...@@ -82,5 +93,4 @@ Rdb_ddl_manager *rdb_get_ddl_manager(void)
class Rdb_binlog_manager; class Rdb_binlog_manager;
Rdb_binlog_manager *rdb_get_binlog_manager(void) Rdb_binlog_manager *rdb_get_binlog_manager(void)
MY_ATTRIBUTE((__warn_unused_result__)); MY_ATTRIBUTE((__warn_unused_result__));
} // namespace myrocks } // namespace myrocks
...@@ -394,3 +394,46 @@ select 1300 < 1300 * 1.5 as "same"; ...@@ -394,3 +394,46 @@ select 1300 < 1300 * 1.5 as "same";
same same
1 1
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (
a INT PRIMARY KEY,
b INT,
c INT,
KEY kbc(b,c)) ENGINE = ROCKSDB;
INSERT INTO t1 (a,b,c) VALUES (1,1,1);
INSERT INTO t1 (a,b,c) VALUES (2,2,2);
INSERT INTO t1 (a,b,c) VALUES (3,3,3);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `kbc` (`b`,`c`)
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
ALTER TABLE t1 DROP INDEX kbc, ADD INDEX kbc(b,c), ALGORITHM=INPLACE;
ALTER TABLE t1 DROP INDEX kbc;
DROP TABLE t1;
CREATE TABLE t1 (
a INT PRIMARY KEY,
b varchar(10),
index kb(b(5))
) ENGINE = ROCKSDB charset utf8 collate utf8_bin;
INSERT INTO t1 (a,b) VALUES (1,'1111122222');
INSERT INTO t1 (a,b) VALUES (2,'2222233333');
INSERT INTO t1 (a,b) VALUES (3,'3333344444');
ALTER TABLE t1 DROP INDEX kb, ADD INDEX kb(b(8)), ALGORITHM=INPLACE;
SELECT * FROM t1 FORCE INDEX(kb);
a b
1 1111122222
2 2222233333
3 3333344444
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` varchar(10) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `kb` (`b`(8))
) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
...@@ -79,11 +79,25 @@ INSERT INTO t1 (a, b) VALUES (1, 5); ...@@ -79,11 +79,25 @@ INSERT INTO t1 (a, b) VALUES (1, 5);
INSERT INTO t1 (a, b) VALUES (2, 6); INSERT INTO t1 (a, b) VALUES (2, 6);
INSERT INTO t1 (a, b) VALUES (3, 7); INSERT INTO t1 (a, b) VALUES (3, 7);
ALTER TABLE t1 ADD UNIQUE INDEX kb(b); ALTER TABLE t1 ADD UNIQUE INDEX kb(b);
ERROR HY000: Unique index support is disabled when the table has no primary key. INSERT INTO t1 (a, b) VALUES (4, 8);
INSERT INTO t1 (a, b) VALUES (5, 5);
ERROR 23000: Duplicate entry '5' for key 'kb'
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL `b` int(11) DEFAULT NULL,
UNIQUE KEY `kb` (`b`)
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 ) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (
a INT PRIMARY KEY,
b INT,
c INT,
KEY kbc(b,c)) ENGINE = ROCKSDB;
INSERT INTO t1 (a,b,c) VALUES (1,1,1);
INSERT INTO t1 (a,b,c) VALUES (2,2,2);
INSERT INTO t1 (a,b,c) VALUES (3,2,2);
ALTER TABLE t1 DROP INDEX kbc, ADD UNIQUE INDEX kbc(b,c), ALGORITHM=INPLACE;
ERROR 23000: Duplicate entry '2-2' for key 'kbc'
DROP TABLE t1;
...@@ -229,7 +229,20 @@ Table Op Msg_type Msg_text ...@@ -229,7 +229,20 @@ Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
DROP TABLE t1, t2; DROP TABLE t1, t2;
CREATE TABLE t1 (a INT, b CHAR(8), UNIQUE INDEX(a)) ENGINE=rocksdb; CREATE TABLE t1 (a INT, b CHAR(8), UNIQUE INDEX(a)) ENGINE=rocksdb;
ERROR HY000: Unique index support is disabled when the table has no primary key. INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
INSERT INTO t1 (a,b) VALUES (1,'c');
ERROR 23000: Duplicate entry '1' for key 'a'
SELECT * FROM t1;
a b
1 a
2 b
SELECT * FROM t1 WHERE a = 2;
a b
2 b
EXPLAIN SELECT * FROM t1 WHERE a = 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const a a 5 const 1 NULL
DROP TABLE t1;
CREATE TABLE t1 (a INT, b CHAR(8)) ENGINE=rocksdb; CREATE TABLE t1 (a INT, b CHAR(8)) ENGINE=rocksdb;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
......
DROP TABLE IF EXISTS t1, t2, t3; DROP TABLE IF EXISTS t1, t2, t3;
CREATE TABLE t1(pk CHAR(5) PRIMARY KEY, a char(30), b char(30), key(a)) COLLATE 'latin1_bin'; Data will be ordered in ascending order
CREATE TABLE t2(pk CHAR(5) PRIMARY KEY, a char(30), b char(30), key(a)) COLLATE 'latin1_bin'; CREATE TABLE t1(
CREATE TABLE t3(pk CHAR(5) PRIMARY KEY, a char(30), b char(30), key(a)) COLLATE 'latin1_bin' pk CHAR(5),
PARTITION BY KEY() PARTITIONS 4; a CHAR(30),
b CHAR(30),
PRIMARY KEY(pk) COMMENT "cf1",
KEY(a)
) COLLATE 'latin1_bin';
CREATE TABLE t2(
pk CHAR(5),
a CHAR(30),
b CHAR(30),
PRIMARY KEY(pk) COMMENT "cf1",
KEY(a)
) COLLATE 'latin1_bin';
CREATE TABLE t3(
pk CHAR(5),
a CHAR(30),
b CHAR(30),
PRIMARY KEY(pk) COMMENT "cf1",
KEY(a)
) COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4;
set session transaction isolation level repeatable read; set session transaction isolation level repeatable read;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS'; select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE STAT_TYPE VALUE
......
CREATE TABLE t1(pk INT, PRIMARY KEY(pk));
SET rocksdb_bulk_load=1;
INSERT INTO t1 VALUES(10);
INSERT INTO t1 VALUES(11);
INSERT INTO t1 VALUES(9);
ERROR HY000: Rows must be inserted in primary key order during bulk load operation
SET rocksdb_bulk_load=0;
SELECT * FROM t1;
pk
10
11
SET rocksdb_bulk_load=1;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(20);
INSERT INTO t1 VALUES(21);
SET rocksdb_bulk_load=0;
ERROR HY000: Lost connection to MySQL server during query
DROP TABLE t1;
DROP TABLE IF EXISTS t1, t2, t3;
Data will be ordered in ascending order
CREATE TABLE t1(
pk CHAR(5),
a CHAR(30),
b CHAR(30),
PRIMARY KEY(pk) COMMENT "rev:cf1",
KEY(a)
) COLLATE 'latin1_bin';
CREATE TABLE t2(
pk CHAR(5),
a CHAR(30),
b CHAR(30),
PRIMARY KEY(pk) COMMENT "rev:cf1",
KEY(a)
) COLLATE 'latin1_bin';
CREATE TABLE t3(
pk CHAR(5),
a CHAR(30),
b CHAR(30),
PRIMARY KEY(pk) COMMENT "rev:cf1",
KEY(a)
) COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4;
set session transaction isolation level repeatable read;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 0
start transaction with consistent snapshot;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 1
set rocksdb_bulk_load=1;
set rocksdb_bulk_load_size=100000;
LOAD DATA INFILE <input_file> INTO TABLE t1;
LOAD DATA INFILE <input_file> INTO TABLE t2;
LOAD DATA INFILE <input_file> INTO TABLE t3;
set rocksdb_bulk_load=0;
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL
t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL
t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned
ANALYZE TABLE t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
test.t3 analyze status OK
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL
t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL
t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned
select count(pk) from t1;
count(pk)
5000000
select count(a) from t1;
count(a)
5000000
select count(b) from t1;
count(b)
5000000
select count(pk) from t2;
count(pk)
5000000
select count(a) from t2;
count(a)
5000000
select count(b) from t2;
count(b)
5000000
select count(pk) from t3;
count(pk)
5000000
select count(a) from t3;
count(a)
5000000
select count(b) from t3;
count(b)
5000000
longfilenamethatvalidatesthatthiswillgetdeleted.bulk_load.tmp
test.bulk_load.tmp
DROP TABLE t1, t2, t3;
DROP TABLE IF EXISTS t1, t2, t3;
Data will be ordered in descending order
CREATE TABLE t1(
pk CHAR(5),
a CHAR(30),
b CHAR(30),
PRIMARY KEY(pk) COMMENT "rev:cf1",
KEY(a)
) COLLATE 'latin1_bin';
CREATE TABLE t2(
pk CHAR(5),
a CHAR(30),
b CHAR(30),
PRIMARY KEY(pk) COMMENT "rev:cf1",
KEY(a)
) COLLATE 'latin1_bin';
CREATE TABLE t3(
pk CHAR(5),
a CHAR(30),
b CHAR(30),
PRIMARY KEY(pk) COMMENT "rev:cf1",
KEY(a)
) COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4;
set session transaction isolation level repeatable read;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 0
start transaction with consistent snapshot;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 1
set rocksdb_bulk_load=1;
set rocksdb_bulk_load_size=100000;
LOAD DATA INFILE <input_file> INTO TABLE t1;
LOAD DATA INFILE <input_file> INTO TABLE t2;
LOAD DATA INFILE <input_file> INTO TABLE t3;
set rocksdb_bulk_load=0;
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL
t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL
t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned
ANALYZE TABLE t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
test.t3 analyze status OK
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL
t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL
t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned
select count(pk) from t1;
count(pk)
5000000
select count(a) from t1;
count(a)
5000000
select count(b) from t1;
count(b)
5000000
select count(pk) from t2;
count(pk)
5000000
select count(a) from t2;
count(a)
5000000
select count(b) from t2;
count(b)
5000000
select count(pk) from t3;
count(pk)
5000000
select count(a) from t3;
count(a)
5000000
select count(b) from t3;
count(b)
5000000
longfilenamethatvalidatesthatthiswillgetdeleted.bulk_load.tmp
test.bulk_load.tmp
DROP TABLE t1, t2, t3;
DROP TABLE IF EXISTS t1, t2, t3;
Data will be ordered in descending order
CREATE TABLE t1(
pk CHAR(5),
a CHAR(30),
b CHAR(30),
PRIMARY KEY(pk) COMMENT "cf1",
KEY(a)
) COLLATE 'latin1_bin';
CREATE TABLE t2(
pk CHAR(5),
a CHAR(30),
b CHAR(30),
PRIMARY KEY(pk) COMMENT "cf1",
KEY(a)
) COLLATE 'latin1_bin';
CREATE TABLE t3(
pk CHAR(5),
a CHAR(30),
b CHAR(30),
PRIMARY KEY(pk) COMMENT "cf1",
KEY(a)
) COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4;
set session transaction isolation level repeatable read;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 0
start transaction with consistent snapshot;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 1
set rocksdb_bulk_load=1;
set rocksdb_bulk_load_size=100000;
LOAD DATA INFILE <input_file> INTO TABLE t1;
LOAD DATA INFILE <input_file> INTO TABLE t2;
LOAD DATA INFILE <input_file> INTO TABLE t3;
set rocksdb_bulk_load=0;
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL
t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL
t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned
ANALYZE TABLE t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
test.t3 analyze status OK
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL
t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL
t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned
select count(pk) from t1;
count(pk)
5000000
select count(a) from t1;
count(a)
5000000
select count(b) from t1;
count(b)
5000000
select count(pk) from t2;
count(pk)
5000000
select count(a) from t2;
count(a)
5000000
select count(b) from t2;
count(b)
5000000
select count(pk) from t3;
count(pk)
5000000
select count(a) from t3;
count(a)
5000000
select count(b) from t3;
count(b)
5000000
longfilenamethatvalidatesthatthiswillgetdeleted.bulk_load.tmp
test.bulk_load.tmp
DROP TABLE t1, t2, t3;
...@@ -5,7 +5,7 @@ connection con1; ...@@ -5,7 +5,7 @@ connection con1;
CREATE TABLE t1 (a INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=ROCKSDB; CREATE TABLE t1 (a INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=ROCKSDB;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 1105 ERROR: 1938
connection con2; connection con2;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS'; select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE STAT_TYPE VALUE
...@@ -18,7 +18,7 @@ STAT_TYPE VALUE ...@@ -18,7 +18,7 @@ STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 0 DB_NUM_SNAPSHOTS 0
connection con1; connection con1;
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 1105 ERROR: 1938
connection con2; connection con2;
INSERT INTO t1 (a) VALUES (1); INSERT INTO t1 (a) VALUES (1);
connection con1; connection con1;
...@@ -69,7 +69,7 @@ id value value2 ...@@ -69,7 +69,7 @@ id value value2
5 5 5 5 5 5
6 6 6 6 6 6
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 1105 ERROR: 1938
connection con2; connection con2;
INSERT INTO r1 values (7,7,7); INSERT INTO r1 values (7,7,7);
connection con1; connection con1;
...@@ -107,12 +107,12 @@ id value value2 ...@@ -107,12 +107,12 @@ id value value2
7 7 7 7 7 7
8 8 8 8 8 8
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 1105 ERROR: 1938
connection con2; connection con2;
INSERT INTO r1 values (9,9,9); INSERT INTO r1 values (9,9,9);
connection con1; connection con1;
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 1105 ERROR: 1938
connection con2; connection con2;
INSERT INTO r1 values (10,10,10); INSERT INTO r1 values (10,10,10);
connection con1; connection con1;
...@@ -129,7 +129,7 @@ id value value2 ...@@ -129,7 +129,7 @@ id value value2
9 9 9 9 9 9
10 10 10 10 10 10
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 1105 ERROR: 1938
INSERT INTO r1 values (11,11,11); INSERT INTO r1 values (11,11,11);
ERROR: 0 ERROR: 0
SELECT * FROM r1; SELECT * FROM r1;
......
...@@ -125,7 +125,7 @@ id value value2 ...@@ -125,7 +125,7 @@ id value value2
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 0 ERROR: 0
INSERT INTO r1 values (11,11,11); INSERT INTO r1 values (11,11,11);
ERROR: 1105 ERROR: 1935
SELECT * FROM r1; SELECT * FROM r1;
id value value2 id value value2
1 1 1 1 1 1
......
...@@ -20,7 +20,7 @@ set @tmp1=@@rocksdb_verify_row_debug_checksums; ...@@ -20,7 +20,7 @@ set @tmp1=@@rocksdb_verify_row_debug_checksums;
set rocksdb_verify_row_debug_checksums=1; set rocksdb_verify_row_debug_checksums=1;
set session debug= "+d,myrocks_simulate_bad_row_read1"; set session debug= "+d,myrocks_simulate_bad_row_read1";
select * from t1 where pk=1; select * from t1 where pk=1;
ERROR HY000: Got error 122 from storage engine ERROR HY000: Got error 199 'Found data corruption.' from ROCKSDB
set session debug= "-d,myrocks_simulate_bad_row_read1"; set session debug= "-d,myrocks_simulate_bad_row_read1";
set rocksdb_verify_row_debug_checksums=@tmp1; set rocksdb_verify_row_debug_checksums=@tmp1;
select * from t1 where pk=1; select * from t1 where pk=1;
...@@ -28,11 +28,11 @@ pk col1 ...@@ -28,11 +28,11 @@ pk col1
1 1 1 1
set session debug= "+d,myrocks_simulate_bad_row_read2"; set session debug= "+d,myrocks_simulate_bad_row_read2";
select * from t1 where pk=1; select * from t1 where pk=1;
ERROR HY000: Got error 122 from storage engine ERROR HY000: Got error 199 'Found data corruption.' from ROCKSDB
set session debug= "-d,myrocks_simulate_bad_row_read2"; set session debug= "-d,myrocks_simulate_bad_row_read2";
set session debug= "+d,myrocks_simulate_bad_row_read3"; set session debug= "+d,myrocks_simulate_bad_row_read3";
select * from t1 where pk=1; select * from t1 where pk=1;
ERROR HY000: Got error 122 from storage engine ERROR HY000: Got error 199 'Found data corruption.' from ROCKSDB
set session debug= "-d,myrocks_simulate_bad_row_read3"; set session debug= "-d,myrocks_simulate_bad_row_read3";
insert into t1 values(4,'0123456789'); insert into t1 values(4,'0123456789');
select * from t1; select * from t1;
...@@ -56,7 +56,7 @@ pk col1 ...@@ -56,7 +56,7 @@ pk col1
ABCD 1 ABCD 1
set session debug= "+d,myrocks_simulate_bad_pk_read1"; set session debug= "+d,myrocks_simulate_bad_pk_read1";
select * from t2; select * from t2;
ERROR HY000: Got error 122 from storage engine ERROR HY000: Got error 199 'Found data corruption.' from ROCKSDB
set session debug= "-d,myrocks_simulate_bad_pk_read1"; set session debug= "-d,myrocks_simulate_bad_pk_read1";
drop table t2; drop table t2;
create table t2 ( create table t2 (
...@@ -69,6 +69,6 @@ pk col1 ...@@ -69,6 +69,6 @@ pk col1
ABCD 1 ABCD 1
set session debug= "+d,myrocks_simulate_bad_pk_read1"; set session debug= "+d,myrocks_simulate_bad_pk_read1";
select * from t2; select * from t2;
ERROR HY000: Got error 122 from storage engine ERROR HY000: Got error 199 'Found data corruption.' from ROCKSDB
set session debug= "-d,myrocks_simulate_bad_pk_read1"; set session debug= "-d,myrocks_simulate_bad_pk_read1";
drop table t2; drop table t2;
set @prior_lock_wait_timeout = @@rocksdb_lock_wait_timeout; set @prior_deadlock_detect = @@rocksdb_deadlock_detect; set global rocksdb_deadlock_detect = on; set global rocksdb_lock_wait_timeout = 100000;;
create table t (i int primary key) engine=rocksdb;
insert into t values (1), (2), (3);
begin;
select * from t where i=1 for update;
i
1
begin;
select * from t where i=2 for update;
i
2
select * from t where i=2 for update;
select * from t where i=1 for update;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
rollback;
i
2
rollback;
select row_lock_deadlocks from information_schema.table_statistics where
table_name = "t";
row_lock_deadlocks
1
select row_lock_deadlocks from information_schema.table_statistics where
table_name = "t";
row_lock_deadlocks
1
begin;
select * from t where i=1 for update;
i
1
begin;
select * from t where i=2 for update;
i
2
select * from t where i=2 for update;
select * from t where i=1 for update;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
rollback;
i
2
rollback;
select row_lock_deadlocks from information_schema.table_statistics where
table_name = "t";
row_lock_deadlocks
2
select row_lock_deadlocks from information_schema.table_statistics where
table_name = "t";
row_lock_deadlocks
2
set global rocksdb_lock_wait_timeout = @prior_lock_wait_timeout; set global rocksdb_deadlock_detect = @prior_deadlock_detect;;
drop table t;
...@@ -52,20 +52,4 @@ drop table t5; ...@@ -52,20 +52,4 @@ drop table t5;
set global rocksdb_compact_cf = 'cf1'; set global rocksdb_compact_cf = 'cf1';
set global rocksdb_compact_cf = 'rev:cf2'; set global rocksdb_compact_cf = 'rev:cf2';
set global rocksdb_signal_drop_index_thread = 1; set global rocksdb_signal_drop_index_thread = 1;
Begin filtering dropped index+ 0
Begin filtering dropped index+ 1
Begin filtering dropped index+ 1
Begin filtering dropped index+ 1
Begin filtering dropped index+ 1
Begin filtering dropped index+ 1
Begin filtering dropped index+ 1
Begin filtering dropped index+ 1
Finished filtering dropped index+ 0
Finished filtering dropped index+ 1
Finished filtering dropped index+ 1
Finished filtering dropped index+ 1
Finished filtering dropped index+ 1
Finished filtering dropped index+ 1
Finished filtering dropped index+ 1
Finished filtering dropped index+ 1
drop table t1; drop table t1;
...@@ -45,9 +45,15 @@ primary key (a,b) comment 'cf1', ...@@ -45,9 +45,15 @@ primary key (a,b) comment 'cf1',
key (b) comment 'rev:cf2' key (b) comment 'rev:cf2'
) ENGINE=RocksDB; ) ENGINE=RocksDB;
DELETE FROM t5; DELETE FROM t5;
set @@global.rocksdb_compact_cf = 'cf1';
set @@global.rocksdb_compact_cf = 'rev:cf2';
set @@global.rocksdb_compact_cf = 'default';
drop table t1; drop table t1;
drop table t2; drop table t2;
drop table t3; drop table t3;
drop table t4; drop table t4;
drop table t5; drop table t5;
set @@global.rocksdb_compact_cf = 'cf1';
set @@global.rocksdb_compact_cf = 'rev:cf2';
set @@global.rocksdb_compact_cf = 'default';
Compacted Compacted
DROP TABLE IF EXISTS t1, t2; DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (b INT PRIMARY KEY); CREATE TABLE t1 (b INT PRIMARY KEY);
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, FOREIGN KEY (b) REFERENCES t1(b)); CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, FOREIGN KEY (b) REFERENCES t1(b));
ERROR 42000: MyRocks does not currently support foreign key constraints ERROR 42000: This version of MySQL doesn't yet support 'FOREIGN KEY for the RocksDB storage engine'
CREATE TABLE t2 (a INT NOT NULL, bforeign INT NOT NULL); CREATE TABLE t2 (a INT NOT NULL, bforeign INT NOT NULL);
DROP TABLE t2; DROP TABLE t2;
CREATE TABLE t2 (a INT NOT NULL, foreignkey INT NOT NULL); CREATE TABLE t2 (a INT NOT NULL, foreignkey INT NOT NULL);
DROP TABLE t2; DROP TABLE t2;
CREATE TABLE t2 (a INT NOT NULL, bforeign INT not null, FOREIGN KEY (bforeign) REFERENCES t1(b)); CREATE TABLE t2 (a INT NOT NULL, bforeign INT not null, FOREIGN KEY (bforeign) REFERENCES t1(b));
ERROR 42000: MyRocks does not currently support foreign key constraints ERROR 42000: This version of MySQL doesn't yet support 'FOREIGN KEY for the RocksDB storage engine'
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL); CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL);
ALTER TABLE t2 ADD FOREIGN KEY (b) REFERENCES t1(b); ALTER TABLE t2 ADD FOREIGN KEY (b) REFERENCES t1(b);
ERROR 42000: MyRocks does not currently support foreign key constraints ERROR 42000: This version of MySQL doesn't yet support 'FOREIGN KEY for the RocksDB storage engine'
DROP TABLE t2; DROP TABLE t2;
CREATE TABLE t2 (a INT NOT NULL); CREATE TABLE t2 (a INT NOT NULL);
ALTER TABLE t2 ADD bforeign INT NOT NULL; ALTER TABLE t2 ADD bforeign INT NOT NULL;
...@@ -20,6 +20,6 @@ ALTER TABLE t2 ADD foreignkey INT NOT NULL; ...@@ -20,6 +20,6 @@ ALTER TABLE t2 ADD foreignkey INT NOT NULL;
DROP TABLE t2; DROP TABLE t2;
CREATE TABLE t2 (a INT NOT NULL); CREATE TABLE t2 (a INT NOT NULL);
ALTER TABLE t2 ADD bforeign INT NOT NULL, ADD FOREIGN KEY (bforeign) REFERENCES t1(b); ALTER TABLE t2 ADD bforeign INT NOT NULL, ADD FOREIGN KEY (bforeign) REFERENCES t1(b);
ERROR 42000: MyRocks does not currently support foreign key constraints ERROR 42000: This version of MySQL doesn't yet support 'FOREIGN KEY for the RocksDB storage engine'
DROP TABLE t2; DROP TABLE t2;
DROP TABLE t1; DROP TABLE t1;
...@@ -483,7 +483,7 @@ delete from test where value = 20; ...@@ -483,7 +483,7 @@ delete from test where value = 20;
connection con1; connection con1;
commit; commit;
connection con2; connection con2;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_snapshot_conflict_errors'; select variable_value-@a from information_schema.global_status where variable_name='rocksdb_snapshot_conflict_errors';
variable_value-@a variable_value-@a
1 1
...@@ -511,7 +511,7 @@ update test set value = 12 where id = 1; ...@@ -511,7 +511,7 @@ update test set value = 12 where id = 1;
connection con1; connection con1;
commit; commit;
connection con2; connection con2;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
commit; commit;
connection con1; connection con1;
truncate table test; truncate table test;
...@@ -582,7 +582,7 @@ update test set value = 18 where id = 2; ...@@ -582,7 +582,7 @@ update test set value = 18 where id = 2;
commit; commit;
connection con1; connection con1;
delete from test where value = 20; delete from test where value = 20;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
commit; commit;
connection con1; connection con1;
truncate table test; truncate table test;
......
...@@ -8,10 +8,10 @@ PRIMARY KEY (z, y) COMMENT 'zy_cf', ...@@ -8,10 +8,10 @@ PRIMARY KEY (z, y) COMMENT 'zy_cf',
KEY (x)) ENGINE = ROCKSDB; KEY (x)) ENGINE = ROCKSDB;
SELECT TABLE_SCHEMA,TABLE_NAME,PARTITION_NAME,INDEX_NAME,INDEX_TYPE,KV_FORMAT_VERSION,CF FROM INFORMATION_SCHEMA.ROCKSDB_DDL WHERE TABLE_NAME like 'is_ddl_t%'; SELECT TABLE_SCHEMA,TABLE_NAME,PARTITION_NAME,INDEX_NAME,INDEX_TYPE,KV_FORMAT_VERSION,CF FROM INFORMATION_SCHEMA.ROCKSDB_DDL WHERE TABLE_NAME like 'is_ddl_t%';
TABLE_SCHEMA TABLE_NAME PARTITION_NAME INDEX_NAME INDEX_TYPE KV_FORMAT_VERSION CF TABLE_SCHEMA TABLE_NAME PARTITION_NAME INDEX_NAME INDEX_TYPE KV_FORMAT_VERSION CF
test is_ddl_t2 NULL PRIMARY 1 11 zy_cf test is_ddl_t2 NULL PRIMARY 1 13 zy_cf
test is_ddl_t2 NULL x 2 11 default test is_ddl_t2 NULL x 2 12 default
test is_ddl_t1 NULL PRIMARY 1 11 default test is_ddl_t1 NULL PRIMARY 1 13 default
test is_ddl_t1 NULL j 2 11 default test is_ddl_t1 NULL j 2 12 default
test is_ddl_t1 NULL k 2 11 kl_cf test is_ddl_t1 NULL k 2 12 kl_cf
DROP TABLE is_ddl_t1; DROP TABLE is_ddl_t1;
DROP TABLE is_ddl_t2; DROP TABLE is_ddl_t2;
CREATE TABLE t1
(
/* fields/keys for row retrieval tests */
key1 INT,
key2 INT,
key3 INT,
key4 INT,
/* make rows much bigger then keys */
filler1 CHAR(200),
KEY(key1),
KEY(key2)
) ENGINE=ROCKSDB;
CREATE TABLE t0 AS SELECT * FROM t1;
# Printing of many insert into t0 values (....) disabled.
# Printing of many insert into t1 select .... from t0 disabled.
# Printing of many insert into t1 (...) values (....) disabled.
SELECT COUNT(*) FROM t1;
COUNT(*)
7201
SET GLOBAL rocksdb_force_flush_memtable_now = 1;
EXPLAIN UPDATE t1 SET filler1='to be deleted' WHERE key1=100 AND key2=100;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL # Using intersect(key1,key2); Using where
UPDATE t1 SET filler1='to be deleted' WHERE key1=100 and key2=100;
DROP TABLE t0, t1;
create table t1 (key1 int, key2 int, key3 int, key (key1), key (key2), key(key3)) engine=rocksdb;
insert into t1 values (1, 100, 100), (1, 200, 200), (1, 300, 300);
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
set global rocksdb_force_flush_memtable_now=1;
explain select * from t1 where key1 = 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref key1 key1 5 const # NULL
explain select key1,key2 from t1 where key1 = 1 or key2 = 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL # Using union(key1,key2); Using where
select * from t1 where key1 = 1;
key1 key2 key3
1 100 100
1 200 200
1 300 300
select key1,key2 from t1 where key1 = 1 or key2 = 1;
key1 key2
1 100
1 200
1 300
drop table t1;
...@@ -39,12 +39,10 @@ a int, ...@@ -39,12 +39,10 @@ a int,
b int, b int,
c int, c int,
d int, d int,
e int,
PRIMARY KEY (a) COMMENT "cf_a", PRIMARY KEY (a) COMMENT "cf_a",
KEY (b) COMMENT "cf_b", KEY (b) COMMENT "cf_b",
KEY (c) COMMENT "cf_c", KEY (c) COMMENT "cf_c",
KEY (d) COMMENT "$per_index_cf", KEY (d) COMMENT "rev:cf_d") ENGINE=ROCKSDB;
KEY (e) COMMENT "rev:cf_d") ENGINE=ROCKSDB;
select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where TYPE = 'CF_FLAGS'; select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where TYPE = 'CF_FLAGS';
TYPE NAME VALUE TYPE NAME VALUE
CF_FLAGS 0 default [0] CF_FLAGS 0 default [0]
...@@ -52,8 +50,7 @@ CF_FLAGS 1 __system__ [0] ...@@ -52,8 +50,7 @@ CF_FLAGS 1 __system__ [0]
CF_FLAGS 2 cf_a [0] CF_FLAGS 2 cf_a [0]
CF_FLAGS 3 cf_b [0] CF_FLAGS 3 cf_b [0]
CF_FLAGS 4 cf_c [0] CF_FLAGS 4 cf_c [0]
CF_FLAGS 5 test.t2.d [2] CF_FLAGS 5 rev:cf_d [1]
CF_FLAGS 6 rev:cf_d [1]
CREATE TABLE t3 (a INT, PRIMARY KEY (a)) ENGINE=ROCKSDB; CREATE TABLE t3 (a INT, PRIMARY KEY (a)) ENGINE=ROCKSDB;
insert into t3 (a) values (1), (2), (3); insert into t3 (a) values (1), (2), (3);
SET @ORIG_ROCKSDB_PAUSE_BACKGROUND_WORK = @@GLOBAL.ROCKSDB_PAUSE_BACKGROUND_WORK; SET @ORIG_ROCKSDB_PAUSE_BACKGROUND_WORK = @@GLOBAL.ROCKSDB_PAUSE_BACKGROUND_WORK;
...@@ -69,7 +66,7 @@ SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK'; ...@@ -69,7 +66,7 @@ SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK';
Variable_name Value Variable_name Value
rocksdb_pause_background_work ON rocksdb_pause_background_work ON
DROP TABLE t3; DROP TABLE t3;
cf_id:0,index_id:268 cf_id:0,index_id:267
SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=0; SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=0;
SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK'; SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK';
Variable_name Value Variable_name Value
......
...@@ -28,5 +28,5 @@ begin; ...@@ -28,5 +28,5 @@ begin;
update t1 set col2=123456 where pk=0; update t1 set col2=123456 where pk=0;
commit; commit;
update t1 set col2=col2+1 where col1 < 10 limit 5; update t1 set col2=col2+1 where col1 < 10 limit 5;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
drop table t1, ten, one_k; drop table t1, ten, one_k;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
id INT,
val1 INT,
val2 INT,
PRIMARY KEY (id)
) ENGINE=rocksdb;
INSERT INTO t1 VALUES(1,1,1),(2,1,2);
SELECT * FROM t1;
id val1 val2
1 1 1
2 1 2
UPDATE t1 SET val1=2 WHERE id=2;
SELECT * FROM t1;
id val1 val2
1 1 1
2 2 2
SHOW ENGINE rocksdb TRANSACTION STATUS;
Type Name Status
SNAPSHOTS rocksdb
============================================================
TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
============================================================
---------
SNAPSHOTS
---------
LIST OF SNAPSHOTS FOR EACH SESSION:
-----------------------------------------
END OF ROCKSDB TRANSACTION MONITOR OUTPUT
=========================================
SET AUTOCOMMIT=0;
START TRANSACTION;
INSERT INTO t1 VALUES(20,1,1),(30,30,30);
SELECT * FROM t1;
id val1 val2
1 1 1
2 2 2
20 1 1
30 30 30
UPDATE t1 SET val1=20, val2=20 WHERE id=20;
SELECT * FROM t1;
id val1 val2
1 1 1
2 2 2
20 20 20
30 30 30
DELETE FROM t1 WHERE id=30;
SHOW ENGINE rocksdb TRANSACTION STATUS;
Type Name Status
SNAPSHOTS rocksdb
============================================================
TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
============================================================
---------
SNAPSHOTS
---------
LIST OF SNAPSHOTS FOR EACH SESSION:
---SNAPSHOT, ACTIVE NUM sec
MySQL thread id TID, OS thread handle PTR, query id QID localhost root ACTION
SHOW ENGINE rocksdb TRANSACTION STATUS
lock count 8, write count 4
insert count 2, update count 1, delete count 1
-----------------------------------------
END OF ROCKSDB TRANSACTION MONITOR OUTPUT
=========================================
ROLLBACK;
SHOW ENGINE rocksdb TRANSACTION STATUS;
Type Name Status
SNAPSHOTS rocksdb
============================================================
TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
============================================================
---------
SNAPSHOTS
---------
LIST OF SNAPSHOTS FOR EACH SESSION:
-----------------------------------------
END OF ROCKSDB TRANSACTION MONITOR OUTPUT
=========================================
START TRANSACTION;
INSERT INTO t1 VALUES(40,40,40);
SHOW ENGINE rocksdb TRANSACTION STATUS;
Type Name Status
SNAPSHOTS rocksdb
============================================================
TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
============================================================
---------
SNAPSHOTS
---------
LIST OF SNAPSHOTS FOR EACH SESSION:
---SNAPSHOT, ACTIVE NUM sec
MySQL thread id TID, OS thread handle PTR, query id QID localhost root ACTION
SHOW ENGINE rocksdb TRANSACTION STATUS
lock count 2, write count 1
insert count 1, update count 0, delete count 0
-----------------------------------------
END OF ROCKSDB TRANSACTION MONITOR OUTPUT
=========================================
COMMIT;
SHOW ENGINE rocksdb TRANSACTION STATUS;
Type Name Status
SNAPSHOTS rocksdb
============================================================
TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
============================================================
---------
SNAPSHOTS
---------
LIST OF SNAPSHOTS FOR EACH SESSION:
-----------------------------------------
END OF ROCKSDB TRANSACTION MONITOR OUTPUT
=========================================
SET AUTOCOMMIT=1;
DROP TABLE t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t2 (
id1 INT,
id2 INT,
value INT,
PRIMARY KEY (id1),
KEY (id2)
) ENGINE=rocksdb;
SET AUTOCOMMIT=0;
START TRANSACTION;
INSERT INTO t2 VALUES(1,2,0),(10,20,30);
UPDATE t2 SET value=3 WHERE id2=2;
DELETE FROM t2 WHERE id1=10;
SHOW ENGINE rocksdb TRANSACTION STATUS;
Type Name Status
SNAPSHOTS rocksdb
============================================================
TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
============================================================
---------
SNAPSHOTS
---------
LIST OF SNAPSHOTS FOR EACH SESSION:
---SNAPSHOT, ACTIVE NUM sec
MySQL thread id TID, OS thread handle PTR, query id QID localhost root ACTION
SHOW ENGINE rocksdb TRANSACTION STATUS
lock count 9, write count 7
insert count 2, update count 1, delete count 1
-----------------------------------------
END OF ROCKSDB TRANSACTION MONITOR OUTPUT
=========================================
ROLLBACK;
SET AUTOCOMMIT=1;
DROP TABLE t2;
CREATE TABLE t1 (pk BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT);
INSERT INTO t1 VALUES (5);
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB # Fixed 1 # # # # # 6 NULL NULL NULL latin1_swedish_ci NULL
INSERT INTO t1 VALUES ('538647864786478647864');
Warnings:
Warning 1264 Out of range value for column 'pk' at row 1
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB # Fixed 2 # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL
INSERT INTO t1 VALUES ();
ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY'
SELECT * FROM t1;
pk
5
9223372036854775807
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB # Fixed 2 # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL
DROP TABLE t1;
drop table if exists t; drop table if exists t;
Warnings:
Note 1051 Unknown table 'test.t'
create table t ( create table t (
a int, a int,
b int, b int,
......
create table t (a int primary key) engine=rocksdb;
begin;
insert into t values (0);
set @@rocksdb_lock_wait_timeout=1;
select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
ROW_LOCK_WAIT_TIMEOUTS
0
begin;
set @@rocksdb_lock_wait_timeout=1;
begin;
insert into t values(0);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on index: test.t.PRIMARY
select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
ROW_LOCK_WAIT_TIMEOUTS
1
select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
ROW_LOCK_WAIT_TIMEOUTS
1
insert into t values(0);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on index: test.t.PRIMARY
select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
ROW_LOCK_WAIT_TIMEOUTS
2
select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
ROW_LOCK_WAIT_TIMEOUTS
2
drop table t;
...@@ -47,6 +47,7 @@ help_relation help_keyword_id NULL NULL ...@@ -47,6 +47,7 @@ help_relation help_keyword_id NULL NULL
help_relation help_topic_id NULL NULL help_relation help_topic_id NULL NULL
help_topic help_topic_id NULL NULL help_topic help_topic_id NULL NULL
help_topic name NULL NULL help_topic name NULL NULL
native_proc name NULL NULL
ndb_binlog_index epoch NULL NULL ndb_binlog_index epoch NULL NULL
ndb_binlog_index orig_epoch NULL NULL ndb_binlog_index orig_epoch NULL NULL
ndb_binlog_index orig_server_id NULL NULL ndb_binlog_index orig_server_id NULL NULL
......
This diff is collapsed.
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (id1 BIGINT, id2 BIGINT, id3 BIGINT, id4 BIGINT, PRIMARY KEY (id1, id2, id3, id4) comment 'cf1') ENGINE=rocksdb collate latin1_bin;
set global rocksdb_force_flush_memtable_now = 1;
Original Prefix Extractor:
SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';
CF_NAME OPTION_TYPE VALUE
__system__ PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
cf1 PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
default PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
COUNT(*)
1
select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
variable_value-@u
1
Prefix Extractor (after override_cf_options set, should not be changed):
SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';
CF_NAME OPTION_TYPE VALUE
__system__ PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
cf1 PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
default PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
Restarting with new Prefix Extractor...
Changed Prefix Extractor (after restart):
SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';
CF_NAME OPTION_TYPE VALUE
__system__ PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
cf1 PREFIX_EXTRACTOR rocksdb.CappedPrefix.26
default PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
COUNT(*)
1
select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
variable_value-@u
0
set global rocksdb_force_flush_memtable_now = 1;
select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
COUNT(*)
1
select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
variable_value-@u
1
SELECT COUNT(*) FROM information_schema.rocksdb_index_file_map WHERE COLUMN_FAMILY != 1;
COUNT(*)
2
UPDATE t1 SET id1=1,id2 = 30,id3 = 30 WHERE id4 >= 0 AND id4 <=10;
set global rocksdb_force_flush_memtable_now = 1;
SELECT COUNT(*) FROM information_schema.rocksdb_index_file_map WHERE COLUMN_FAMILY != 1;
COUNT(*)
3
select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
COUNT(*)
0
select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
variable_value-@u
2
set global rocksdb_compact_cf='cf1';
select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=30 AND id3=30;
COUNT(*)
11
select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
variable_value-@u
1
DROP TABLE t1;
...@@ -348,6 +348,9 @@ ALTER TABLE t2 ADD KEY (`col3`, `col4`) COMMENT 'custom_p5_cfname=another_cf_for ...@@ -348,6 +348,9 @@ ALTER TABLE t2 ADD KEY (`col3`, `col4`) COMMENT 'custom_p5_cfname=another_cf_for
SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='another_cf_for_p5'; SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='another_cf_for_p5';
cf_name cf_name
another_cf_for_p5 another_cf_for_p5
ANALYZE TABLE t2;
Table Op Msg_type Msg_text
test.t2 analyze status OK
EXPLAIN PARTITIONS SELECT * FROM t2 WHERE col3 = 0x4 AND col2 = 0x34567; EXPLAIN PARTITIONS SELECT * FROM t2 WHERE col3 = 0x4 AND col2 = 0x34567;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 custom_p2 ref col3 col3 258 const 1 Using where 1 SIMPLE t2 custom_p2 ref col3 col3 258 const 1 Using where
...@@ -407,3 +410,14 @@ cf_name ...@@ -407,3 +410,14 @@ cf_name
notsharedcf notsharedcf
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2; DROP TABLE IF EXISTS t2;
CREATE TABLE t1 (
a INT NOT NULL,
PRIMARY KEY (a) COMMENT 'p1_cfname=foo;'
) ENGINE=ROCKSDB
PARTITION BY LIST COLUMNS(a)
(PARTITION p1 VALUES IN (1) ENGINE = ROCKSDB);
INSERT INTO t1 values (1);
TRUNCATE TABLE t1;
SELECT * FROM t1;
a
DROP TABLE t1;
...@@ -57,7 +57,7 @@ UPDATE t1 SET value=30 WHERE id=3; ...@@ -57,7 +57,7 @@ UPDATE t1 SET value=30 WHERE id=3;
COMMIT; COMMIT;
connection con1; connection con1;
SELECT * FROM t1 WHERE id=3 FOR UPDATE; SELECT * FROM t1 WHERE id=3 FOR UPDATE;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
ROLLBACK; ROLLBACK;
disconnect con1; disconnect con1;
connection default; connection default;
......
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.
--rocksdb_strict_collation_check=off --binlog_format=row --log-bin
This diff is collapsed.
--rocksdb_strict_collation_check=off --binlog_format=row --log-bin
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.
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.
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