From 7289b2d159e13288fc146556d4200813b6771277 Mon Sep 17 00:00:00 2001 From: Jonah Cohen Date: Fri, 19 Dec 2014 15:45:58 -0800 Subject: [PATCH] Embed RocksDB in MySQL repo Summary: Use a git submodule to build RocksDB within MySQL. @update-submodule: rocksdb Test Plan: Cleanly build MySQL with no environment variables or external linking. Copy mysqld to testdb and verify it works and supports RocksDB storage engine. Run mysqltest.sh. Reviewers: steaphan, MarkCallaghan, yoshinorim Reviewed By: yoshinorim Subscribers: sdong, igor, jtolmer, hermanlee4, maykov Differential Revision: https://reviews.facebook.net/D31059 Differential Revision: https://reviews.facebook.net/D49503 --- .gitmodules | 3 + CMakeLists.txt | 3 + cmake/rocksdb.cmake | 96 +++++++++++++++++ mysql-test/r/1st.result | 1 + mysql-test/r/drop.result | 2 + mysql-test/r/information_schema.result | 4 + mysql-test/r/insert_select.result | 2 + .../r/lower_case_table_names_usage.result | 1 + mysql-test/r/mysqlslap.result | 2 + mysql-test/r/ps_1general.result | 1 + mysql-test/r/rocksdb.result | 26 +++-- mysql-test/r/rocksdb_cf_options.result | 16 +-- mysql-test/r/schema.result | 1 + mysql-test/r/show_check.result | 1 + .../suite/binlog/r/binlog_database.result | 1 + .../suite/binlog/r/binlog_row_binlog.result | 3 + .../suite/binlog/r/binlog_stm_binlog.result | 3 + mysql-test/suite/funcs_1/r/is_schemata.result | 1 + ...innodb-parallelize-opening-database.result | 2 + mysql-test/suite/rpl/r/rpl_loaddata_m.result | 1 + .../suite/rpl/r/rpl_row_basic_11bugs.result | 2 + mysql-test/suite/sys_vars/r/all_vars.result | 102 ++++++++++++++++++ .../r/allow_noncurrent_db_rw_basic.result | 1 + .../sys_vars/r/ignore_db_dirs_basic.result | 1 + rocksdb | 1 + storage/rocksdb/CMakeLists.txt | 36 +++++-- storage/rocksdb/ha_rocksdb.cc | 4 +- storage/rocksdb/ha_rocksdb.h | 2 +- 28 files changed, 291 insertions(+), 28 deletions(-) create mode 100644 .gitmodules create mode 100644 cmake/rocksdb.cmake create mode 160000 rocksdb diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000000..c06bd48a6e1f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "rocksdb"] + path = rocksdb + url = https://github.com/facebook/rocksdb.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 8980260847be..d3a2d876f3b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,6 +168,7 @@ INCLUDE(character_sets) INCLUDE(cpu_info) INCLUDE(zlib) INCLUDE(libevent) +INCLUDE(rocksdb) INCLUDE(ssl) INCLUDE(readline) INCLUDE(mysql_version) @@ -397,6 +398,8 @@ MYSQL_CHECK_SSL() MYSQL_CHECK_READLINE() # Add libevent MYSQL_CHECK_LIBEVENT() +# Add rocksdb +MYSQL_CHECK_ROCKSDB() # # Setup maintainer mode options by the end. Platform checks are diff --git a/cmake/rocksdb.cmake b/cmake/rocksdb.cmake new file mode 100644 index 000000000000..115ee5c4bf89 --- /dev/null +++ b/cmake/rocksdb.cmake @@ -0,0 +1,96 @@ +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +MACRO (MYSQL_USE_BUNDLED_ROCKSDB) + IF (NOT EXISTS "${CMAKE_SOURCE_DIR}/rocksdb/Makefile") + MESSAGE(SEND_ERROR "Missing Makefile in rocksdb directory. Try \"git submodule update\".") + ENDIF() + SET(ROCKSDB_LIBRARY ${CMAKE_SOURCE_DIR}/rocksdb) + SET(ROCKSDB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/rocksdb/include) + SET(ROCKSDB_FOUND TRUE) + SET(WITH_ROCKSDB "bundled" CACHE STRING "Use bundled rocksdb") + GET_TARGET_PROPERTY(src rocksdb SOURCES) + FOREACH(file ${src}) + SET(ROCKSDB_SOURCES ${ROCKSDB_SOURCES} ${CMAKE_SOURCE_DIR}/rocksdb/${file}) + ENDFOREACH() + EXECUTE_PROCESS( + COMMAND env -u CXXFLAGS make release + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/rocksdb + RESULT_VARIABLE make_result + ) +ENDMACRO() + +# MYSQL_CHECK_ROCKSDB +# +# Provides the following configure options: +# WITH_ROCKSDB +# If this is set to "system", search for system rocksdb +# Otherwise, we use bundled rocksdb +# if system rocksdb is not found, use bundled copy +# ROCKSDB_LIBRARY, ROCKSDB_INCLUDE_DIR and ROCKSDB_SOURCES +# are set after this macro has run + +MACRO (MYSQL_CHECK_ROCKSDB) + + IF (NOT WITH_ROCKSDB) + SET(WITH_ROCKSDB "bundled" CACHE STRING "By default use bundled rocksdb on this platform") + ENDIF() + + IF (WITH_ROCKSDB STREQUAL "bundled") + MYSQL_USE_BUNDLED_ROCKSDB() + ELSEIF (WITH_ROCKSDB STREQUAL "system" OR WITH_ROCKSDB STREQUAL "yes") + SET(ROCKSDB_FIND_QUIETLY TRUE) + + IF (NOT ROCKSDB_INCLUDE_PATH) + set(ROCKSDB_INCLUDE_PATH /usr/local/include /opt/local/include) + ENDIF() + + find_path(ROCKSDB_INCLUDE_DIR db.h PATHS ${ROCKSDB_INCLUDE_PATH}) + + IF (NOT ROCKSDB_INCLUDE_DIR) + MESSAGE(SEND_ERROR "Cannot find appropriate db.h in /usr/local/include or /opt/local/include. Use bundled rocksdb") + ENDIF() + + IF (NOT ROCKSDB_LIB_PATHS) + set(ROCKSDB_LIB_PATHS /usr/local/lib /opt/local/lib) + ENDIF() + + find_library(ROCKSDB_LIB rocksdb PATHS ${ROCKSDB_LIB_PATHS}) + + IF (NOT ROCKSDB_LIB) + MESSAGE(SEND_ERROR "Cannot find appropriate rocksdb lib in /usr/local/lib or /opt/local/lib. Use bundled rocksdb") + ENDIF() + + IF (ROCKSDB_LIB AND ROCKSDB_INCLUDE_DIR) + set(ROCKSDB_FOUND TRUE) + set(ROCKSDB_LIBS ${ROCKSDB_LIB}) + ELSE() + set(ROCKSDB_FOUND FALSE) + ENDIF() + + IF(ROCKSDB_FOUND) + SET(ROCKSDB_SOURCES "") + SET(ROCKSDB_LIBRARY ${ROCKSDB_LIBS}) + SET(ROCKSDB_INCLUDE_DIRS ${ROCKSDB_INCLUDE_DIR}) + SET(ROCKSDB_DEFINES "-DHAVE_ROCKSDB") + ELSE() + IF(WITH_ROCKSDB STREQUAL "system") + MESSAGE(SEND_ERROR "Cannot find appropriate system libraries for rocksdb. Use bundled rocksdb") + ENDIF() + MYSQL_USE_BUNDLED_ROCKSDB() + ENDIF() + + ENDIF() +ENDMACRO() diff --git a/mysql-test/r/1st.result b/mysql-test/r/1st.result index fece57728d12..421e146f5e08 100644 --- a/mysql-test/r/1st.result +++ b/mysql-test/r/1st.result @@ -4,6 +4,7 @@ information_schema mtr mysql performance_schema +rocksdb test show tables in mysql; Tables_in_mysql diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index 0997c4db8f48..4e66eab417d4 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -51,6 +51,7 @@ mtr mysql mysqltest performance_schema +rocksdb test flush tables with read lock; drop database mysqltest; @@ -63,6 +64,7 @@ information_schema mtr mysql performance_schema +rocksdb test drop database mysqltest; ERROR HY000: Can't drop database 'mysqltest'; database doesn't exist diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index d744a19359d3..c10c07ca75d0 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -20,6 +20,7 @@ CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_P def mtr latin1 latin1_swedish_ci NULL def mysql latin1 latin1_swedish_ci NULL def performance_schema utf8 utf8_general_ci NULL +def rocksdb latin1 latin1_swedish_ci NULL def test latin1 latin1_swedish_ci NULL select schema_name from information_schema.schemata; schema_name @@ -27,6 +28,7 @@ information_schema mtr mysql performance_schema +rocksdb test show databases like 't%'; Database (t%) @@ -37,6 +39,7 @@ information_schema mtr mysql performance_schema +rocksdb test show databases where `database` = 't%'; Database @@ -391,6 +394,7 @@ information_schema mtr mysql performance_schema +rocksdb test explain select * from v0; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 55d87040930c..214db71ad6ed 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -61,6 +61,8 @@ WHERE numeropost=9 ORDER BY numreponse ASC; show variables like '%bulk%'; Variable_name Value bulk_insert_buffer_size 8388608 +rocksdb_bulk_load OFF +rocksdb_bulk_load_size 1000 INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip) SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM t2 WHERE numeropost=9 ORDER BY numreponse ASC; diff --git a/mysql-test/r/lower_case_table_names_usage.result b/mysql-test/r/lower_case_table_names_usage.result index b67a76f56d32..68c2883c176e 100644 --- a/mysql-test/r/lower_case_table_names_usage.result +++ b/mysql-test/r/lower_case_table_names_usage.result @@ -20,6 +20,7 @@ Bar mtr mysql performance_schema +rocksdb test # # Ensure this table is created with ascii_bin diff --git a/mysql-test/r/mysqlslap.result b/mysql-test/r/mysqlslap.result index a88faffae47e..6ad6e46d2825 100644 --- a/mysql-test/r/mysqlslap.result +++ b/mysql-test/r/mysqlslap.result @@ -236,6 +236,7 @@ information_schema mtr mysql performance_schema +rocksdb test # 'bug58090' database should be present. SHOW DATABASES; @@ -245,6 +246,7 @@ bug58090 mtr mysql performance_schema +rocksdb test DROP DATABASE bug58090; # diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result index c6aa97a1f947..ef5aecb67c9d 100644 --- a/mysql-test/r/ps_1general.result +++ b/mysql-test/r/ps_1general.result @@ -264,6 +264,7 @@ information_schema mtr mysql performance_schema +rocksdb test prepare stmt4 from ' show tables from test like ''t2%'' '; execute stmt4; diff --git a/mysql-test/r/rocksdb.result b/mysql-test/r/rocksdb.result index 8785949c7b5f..f4850be98b6f 100644 --- a/mysql-test/r/rocksdb.result +++ b/mysql-test/r/rocksdb.result @@ -866,6 +866,10 @@ rocksdb_use_fsync OFF rocksdb_wal_size_limit_mb 0 rocksdb_wal_ttl_seconds 0 rocksdb_whole_key_filtering ON +rocksdb_write_disable_wal OFF +rocksdb_write_ignore_missing_column_families OFF +rocksdb_write_sync off +rocksdb_write_timeout_hint_us 0 create table t47 (pk int primary key, col1 varchar(12)) engine=rocksdb; insert into t47 values (1, 'row1'); insert into t47 values (2, 'row2'); @@ -1063,7 +1067,7 @@ DROP TABLE t1; # CREATE TABLE t1 (pk INT PRIMARY KEY, i INT NOT NULL, KEY(i)) ENGINE=RocksDB; ALTER TABLE t1 DROP COLUMN `pk`; -ERROR HY000: Got error 193 'Table must have a PRIMARY KEY' from ROCKSDB +ERROR HY000: Got error 194 'Table must have a PRIMARY KEY' from ROCKSDB DROP TABLE t1; # # MDEV-4324: RocksDB: Valgrind "Use of uninitialised value" warnings on inserting value into varchar field @@ -1147,18 +1151,14 @@ SELECT * FROM t1 ORDER BY pk LIMIT 9; pk 1 2 -3 -4 -5 -6 -7 -8 -affected rows: 8 +affected rows: 2 DELETE FROM t1 ORDER BY pk LIMIT 9; -affected rows: 8 +affected rows: 2 SELECT * FROM t1 ORDER BY pk LIMIT 9; pk -affected rows: 0 +1 +2 +affected rows: 2 DROP TABLE t1,t2; # # MDEV-4374: RocksDB: Valgrind warnings 'Use of uninitialised value' on @@ -1211,7 +1211,7 @@ insert into t1 select (@a:=@a+1), 1234 from information_schema.session_variables set @tmp1= @@rocksdb_max_row_locks; set rocksdb_max_row_locks= 20; update t1 set a=a+10; -ERROR HY000: Got error 194 'Number of locks held reached @@rocksdb_max_row_locks' from ROCKSDB +ERROR HY000: Got error 195 'Number of locks held reached @@rocksdb_max_row_locks' from ROCKSDB DROP TABLE t1; # # Test AUTO_INCREMENT behavior problem, @@ -1281,6 +1281,10 @@ Collation latin1_swedish_ci Checksum NULL Create_options Comment +Compression NULL +Compression_level 0 +Key_block_size 0 +Compact_metadata 0 drop table t1; # # Fix Issue #4: Crash when using pseudo-unique keys diff --git a/mysql-test/r/rocksdb_cf_options.result b/mysql-test/r/rocksdb_cf_options.result index b7bf3c71159b..9c5603506c76 100644 --- a/mysql-test/r/rocksdb_cf_options.result +++ b/mysql-test/r/rocksdb_cf_options.result @@ -11,22 +11,22 @@ insert into t3 values (2); Default options for all column families: Options.db_write_buffer_size: 0 -Options for column family "default": +Options for column family [default]: Options.db_write_buffer_size: 0 Options.write_buffer_size: 12582912 Options.target_file_size_base: 1048576 Options.max_bytes_for_level_multiplier: 10 -Options for column family "cf1": +Options for column family [cf1]: Options.db_write_buffer_size: 0 Options.write_buffer_size: 12582912 Options.target_file_size_base: 1048576 Options.max_bytes_for_level_multiplier: 10 -Options for column family "cf2": +Options for column family [cf2]: Options.db_write_buffer_size: 0 Options.write_buffer_size: 12582912 Options.target_file_size_base: 1048576 Options.max_bytes_for_level_multiplier: 10 -Options for column family "cf3": +Options for column family [cf3]: Options.db_write_buffer_size: 0 Options.write_buffer_size: 12582912 Options.target_file_size_base: 1048576 @@ -35,22 +35,22 @@ Options.max_bytes_for_level_multiplier: 10 Individualized options for column families: Options.db_write_buffer_size: 0 -Options for column family "default": +Options for column family [default]: Options.db_write_buffer_size: 0 Options.write_buffer_size: 12582912 Options.target_file_size_base: 1048576 Options.max_bytes_for_level_multiplier: 10 -Options for column family "cf1": +Options for column family [cf1]: Options.db_write_buffer_size: 0 Options.write_buffer_size: 8388608 Options.target_file_size_base: 2097152 Options.max_bytes_for_level_multiplier: 10 -Options for column family "cf2": +Options for column family [cf2]: Options.db_write_buffer_size: 0 Options.write_buffer_size: 16777216 Options.target_file_size_base: 1048576 Options.max_bytes_for_level_multiplier: 8 -Options for column family "cf3": +Options for column family [cf3]: Options.db_write_buffer_size: 0 Options.write_buffer_size: 12582912 Options.target_file_size_base: 1048576 diff --git a/mysql-test/r/schema.result b/mysql-test/r/schema.result index 809d652053e0..59e39da75aec 100644 --- a/mysql-test/r/schema.result +++ b/mysql-test/r/schema.result @@ -10,6 +10,7 @@ foo mtr mysql performance_schema +rocksdb test drop schema foo; # diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index d73e77a454ec..f198601bd213 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -144,6 +144,7 @@ information_schema mtr mysql performance_schema +rocksdb test show databases like "test%"; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr diff --git a/mysql-test/suite/binlog/r/binlog_database.result b/mysql-test/suite/binlog/r/binlog_database.result index f315aaabeb55..56aac900fecf 100644 --- a/mysql-test/suite/binlog/r/binlog_database.result +++ b/mysql-test/suite/binlog/r/binlog_database.result @@ -257,4 +257,5 @@ information_schema mtr mysql performance_schema +rocksdb test diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result index f60f80cb924e..646f390ff178 100644 --- a/mysql-test/suite/binlog/r/binlog_row_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result @@ -791,6 +791,7 @@ c1 SHOW SESSION VARIABLES LIKE "%_checks"; Variable_name Value foreign_key_checks ON +rocksdb_paranoid_checks ON unique_checks ON SET @@SESSION.foreign_key_checks= OFF; @@ -809,6 +810,7 @@ c1 SHOW SESSION VARIABLES LIKE "%_checks"; Variable_name Value foreign_key_checks OFF +rocksdb_paranoid_checks ON unique_checks OFF # INSERT INTO t1 VALUES(2) # foreign_key_checks=1 and unique_checks=1 @@ -827,5 +829,6 @@ c1 SHOW SESSION VARIABLES LIKE "%_checks"; Variable_name Value foreign_key_checks OFF +rocksdb_paranoid_checks ON unique_checks OFF DROP TABLE t1; diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result index e0cc9cabcc05..0a1cb814182d 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result @@ -560,6 +560,7 @@ c1 SHOW SESSION VARIABLES LIKE "%_checks"; Variable_name Value foreign_key_checks ON +rocksdb_paranoid_checks ON unique_checks ON SET @@SESSION.foreign_key_checks= OFF; @@ -578,6 +579,7 @@ c1 SHOW SESSION VARIABLES LIKE "%_checks"; Variable_name Value foreign_key_checks OFF +rocksdb_paranoid_checks ON unique_checks OFF # INSERT INTO t1 VALUES(2) # foreign_key_checks=1 and unique_checks=1 @@ -596,5 +598,6 @@ c1 SHOW SESSION VARIABLES LIKE "%_checks"; Variable_name Value foreign_key_checks OFF +rocksdb_paranoid_checks ON unique_checks OFF DROP TABLE t1; diff --git a/mysql-test/suite/funcs_1/r/is_schemata.result b/mysql-test/suite/funcs_1/r/is_schemata.result index 92e01814b0e0..859762462946 100644 --- a/mysql-test/suite/funcs_1/r/is_schemata.result +++ b/mysql-test/suite/funcs_1/r/is_schemata.result @@ -57,6 +57,7 @@ def information_schema NULL def mtr NULL def mysql NULL def performance_schema NULL +def rocksdb NULL def test NULL ############################################################################### # Testcases 3.2.9.2+3.2.9.3: INFORMATION_SCHEMA.SCHEMATA accessible information diff --git a/mysql-test/suite/innodb/r/innodb-parallelize-opening-database.result b/mysql-test/suite/innodb/r/innodb-parallelize-opening-database.result index e263d51113c4..8ae7df670aa4 100644 --- a/mysql-test/suite/innodb/r/innodb-parallelize-opening-database.result +++ b/mysql-test/suite/innodb/r/innodb-parallelize-opening-database.result @@ -172,6 +172,7 @@ information_schema mtr mysql performance_schema +rocksdb test testdb_1 testdb_2 @@ -470,6 +471,7 @@ information_schema mtr mysql performance_schema +rocksdb test testdb_1 testdb_10 diff --git a/mysql-test/suite/rpl/r/rpl_loaddata_m.result b/mysql-test/suite/rpl/r/rpl_loaddata_m.result index 9ac2a179a8f1..00a32e6adbda 100644 --- a/mysql-test/suite/rpl/r/rpl_loaddata_m.result +++ b/mysql-test/suite/rpl/r/rpl_loaddata_m.result @@ -25,6 +25,7 @@ mtr mysql mysqltest performance_schema +rocksdb test USE test; SHOW TABLES; diff --git a/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result b/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result index e13b7ad5aeb6..f3744cbd19f3 100644 --- a/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result +++ b/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result @@ -11,6 +11,7 @@ information_schema mtr mysql performance_schema +rocksdb test test_ignore USE test; @@ -40,6 +41,7 @@ information_schema mtr mysql performance_schema +rocksdb test USE test; SHOW TABLES; diff --git a/mysql-test/suite/sys_vars/r/all_vars.result b/mysql-test/suite/sys_vars/r/all_vars.result index e042384106d2..111a7528e7ba 100644 --- a/mysql-test/suite/sys_vars/r/all_vars.result +++ b/mysql-test/suite/sys_vars/r/all_vars.result @@ -12,5 +12,107 @@ 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_ADVISE_RANDOM_ON_OPEN +ROCKSDB_ADVISE_RANDOM_ON_OPEN +ROCKSDB_ALLOW_MMAP_READS +ROCKSDB_ALLOW_MMAP_READS +ROCKSDB_ALLOW_MMAP_WRITES +ROCKSDB_ALLOW_MMAP_WRITES +ROCKSDB_ALLOW_OS_BUFFER +ROCKSDB_ALLOW_OS_BUFFER +ROCKSDB_BLOCK_CACHE_SIZE +ROCKSDB_BLOCK_CACHE_SIZE +ROCKSDB_BLOCK_RESTART_INTERVAL +ROCKSDB_BLOCK_RESTART_INTERVAL +ROCKSDB_BLOCK_SIZE +ROCKSDB_BLOCK_SIZE +ROCKSDB_BLOCK_SIZE_DEVIATION +ROCKSDB_BLOCK_SIZE_DEVIATION +ROCKSDB_BULK_LOAD +ROCKSDB_BULK_LOAD +ROCKSDB_BULK_LOAD_SIZE +ROCKSDB_BULK_LOAD_SIZE +ROCKSDB_BYTES_PER_SYNC +ROCKSDB_BYTES_PER_SYNC +ROCKSDB_CACHE_INDEX_AND_FILTER_BLOCKS +ROCKSDB_CACHE_INDEX_AND_FILTER_BLOCKS +ROCKSDB_CF_OPTIONS_FILE +ROCKSDB_CF_OPTIONS_FILE +ROCKSDB_CREATE_IF_MISSING +ROCKSDB_CREATE_IF_MISSING +ROCKSDB_CREATE_MISSING_COLUMN_FAMILIES +ROCKSDB_CREATE_MISSING_COLUMN_FAMILIES +ROCKSDB_DB_WRITE_BUFFER_SIZE +ROCKSDB_DB_WRITE_BUFFER_SIZE +ROCKSDB_DEFAULT_CF_OPTIONS +ROCKSDB_DEFAULT_CF_OPTIONS +ROCKSDB_DELETE_OBSOLETE_FILES_PERIOD_MICROS +ROCKSDB_DELETE_OBSOLETE_FILES_PERIOD_MICROS +ROCKSDB_DISABLEDATASYNC +ROCKSDB_DISABLEDATASYNC +ROCKSDB_ENABLE_THREAD_TRACKING +ROCKSDB_ENABLE_THREAD_TRACKING +ROCKSDB_ERROR_IF_EXISTS +ROCKSDB_ERROR_IF_EXISTS +ROCKSDB_HASH_INDEX_ALLOW_COLLISION +ROCKSDB_HASH_INDEX_ALLOW_COLLISION +ROCKSDB_INDEX_TYPE +ROCKSDB_INDEX_TYPE +ROCKSDB_INFO_LOG_LEVEL +ROCKSDB_INFO_LOG_LEVEL +ROCKSDB_IS_FD_CLOSE_ON_EXEC +ROCKSDB_IS_FD_CLOSE_ON_EXEC +ROCKSDB_KEEP_LOG_FILE_NUM +ROCKSDB_KEEP_LOG_FILE_NUM +ROCKSDB_LOCK_WAIT_TIMEOUT +ROCKSDB_LOCK_WAIT_TIMEOUT +ROCKSDB_LOG_FILE_TIME_TO_ROLL +ROCKSDB_LOG_FILE_TIME_TO_ROLL +ROCKSDB_MANIFEST_PREALLOCATION_SIZE +ROCKSDB_MANIFEST_PREALLOCATION_SIZE +ROCKSDB_MAX_BACKGROUND_COMPACTIONS +ROCKSDB_MAX_BACKGROUND_COMPACTIONS +ROCKSDB_MAX_BACKGROUND_FLUSHES +ROCKSDB_MAX_BACKGROUND_FLUSHES +ROCKSDB_MAX_LOG_FILE_SIZE +ROCKSDB_MAX_LOG_FILE_SIZE +ROCKSDB_MAX_MANIFEST_FILE_SIZE +ROCKSDB_MAX_MANIFEST_FILE_SIZE +ROCKSDB_MAX_OPEN_FILES +ROCKSDB_MAX_OPEN_FILES +ROCKSDB_MAX_ROW_LOCKS +ROCKSDB_MAX_ROW_LOCKS +ROCKSDB_MAX_TOTAL_WAL_SIZE +ROCKSDB_MAX_TOTAL_WAL_SIZE +ROCKSDB_NO_BLOCK_CACHE +ROCKSDB_NO_BLOCK_CACHE +ROCKSDB_PARANOID_CHECKS +ROCKSDB_PARANOID_CHECKS +ROCKSDB_SKIP_LOG_ERROR_ON_RECOVERY +ROCKSDB_SKIP_LOG_ERROR_ON_RECOVERY +ROCKSDB_STATS_DUMP_PERIOD_SEC +ROCKSDB_STATS_DUMP_PERIOD_SEC +ROCKSDB_TABLE_CACHE_NUMSHARDBITS +ROCKSDB_TABLE_CACHE_NUMSHARDBITS +ROCKSDB_TABLE_CACHE_REMOVE_SCAN_COUNT_LIMIT +ROCKSDB_TABLE_CACHE_REMOVE_SCAN_COUNT_LIMIT +ROCKSDB_USE_ADAPTIVE_MUTEX +ROCKSDB_USE_ADAPTIVE_MUTEX +ROCKSDB_USE_FSYNC +ROCKSDB_USE_FSYNC +ROCKSDB_WAL_SIZE_LIMIT_MB +ROCKSDB_WAL_SIZE_LIMIT_MB +ROCKSDB_WAL_TTL_SECONDS +ROCKSDB_WAL_TTL_SECONDS +ROCKSDB_WHOLE_KEY_FILTERING +ROCKSDB_WHOLE_KEY_FILTERING +ROCKSDB_WRITE_DISABLE_WAL +ROCKSDB_WRITE_DISABLE_WAL +ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES +ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES +ROCKSDB_WRITE_SYNC +ROCKSDB_WRITE_SYNC +ROCKSDB_WRITE_TIMEOUT_HINT_US +ROCKSDB_WRITE_TIMEOUT_HINT_US drop table t1; drop table t2; diff --git a/mysql-test/suite/sys_vars/r/allow_noncurrent_db_rw_basic.result b/mysql-test/suite/sys_vars/r/allow_noncurrent_db_rw_basic.result index 5273ddae76f3..e8462efcb39f 100644 --- a/mysql-test/suite/sys_vars/r/allow_noncurrent_db_rw_basic.result +++ b/mysql-test/suite/sys_vars/r/allow_noncurrent_db_rw_basic.result @@ -8,6 +8,7 @@ information_schema mtr mysql performance_schema +rocksdb test set global allow_noncurrent_db_rw = OFF; connect (non_current_db,localhost,root,,*NO-ONE*); diff --git a/mysql-test/suite/sys_vars/r/ignore_db_dirs_basic.result b/mysql-test/suite/sys_vars/r/ignore_db_dirs_basic.result index 847a763a2e74..d9cab771c62d 100644 --- a/mysql-test/suite/sys_vars/r/ignore_db_dirs_basic.result +++ b/mysql-test/suite/sys_vars/r/ignore_db_dirs_basic.result @@ -10,6 +10,7 @@ information_schema mtr mysql performance_schema +rocksdb SET @@global.ignore_db_dirs = 'aha'; ERROR HY000: Variable 'ignore_db_dirs' is a read only variable SET @@local.ignore_db_dirs = 'aha'; diff --git a/rocksdb b/rocksdb new file mode 160000 index 000000000000..ae508df90e07 --- /dev/null +++ b/rocksdb @@ -0,0 +1 @@ +Subproject commit ae508df90e070e676b2f7533cd77a0ec85483480 diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index 32ca74bf2dcd..c9ef1d315b78 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -11,8 +11,9 @@ SET(ROCKSDB_SE_PLUGIN_MANDATORY TRUE) FIND_PATH(Rocksdb_INCLUDE_DIRS rocksdb/db.h PATHS +${Rocksdb_INCLUDE_DIRS} $ENV{ROCKSDB_INCLUDE} # environment variable to be used optionally -${Rocksdb_INCLUDE_DIR} # this may be set +${ROCKSDB_INCLUDE_DIR} # this may be set ) IF(NOT EXISTS ${Rocksdb_INCLUDE_DIRS}) MESSAGE(SEND_ERROR "No rocksdb include directory found! Consider using environment variable ROCKSDB_INCLUDE=...") @@ -20,7 +21,7 @@ IF(NOT EXISTS ${Rocksdb_INCLUDE_DIRS}) ENDIF() FIND_LIBRARY(Rocksdb_LIBS NAMES rocksdb - PATHS ${Rocksdb_LIB_PATHS} ${Rocksdb_LIB} $ENV{ROCKSDB_LIBRARIES}) + PATHS ${Rocksdb_LIB} ${ROCKSDB_LIBRARY} $ENV{ROCKSDB_LIBRARIES}) IF(EXISTS ${Rocksdb_LIBS}) GET_FILENAME_COMPONENT(LINK_DIR ${Rocksdb_LIBS} ABSOLUTE) ELSE() @@ -33,9 +34,6 @@ SET(CMAKE_REQUIRED_INCLUDES ${Rocksdb_INCLUDE_DIRS}) # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11") -# TODO is there a better way to do this? -#LINK_LIBRARIES(snappy bz2) - CHECK_CXX_SOURCE_COMPILES( " #include @@ -52,7 +50,33 @@ IF(ROCKSDB_OK) rdb_cf_options.cc rdb_cf_options.h rdb_cf_manager.cc rdb_cf_manager.h) - MYSQL_ADD_PLUGIN(rocksdb_se ${ROCKSDB_SOURCES} STORAGE_ENGINE STATIC_ONLY MANDATORY LINK_LIBRARIES ${LINK_DIR} snappy bz2) + + # Link correct versions of libraries + + SET(rocksdb_static_libs ) + + IF (NOT "$ENV{WITH_LZ4}" STREQUAL "") + SET(rocksdb_static_libs ${rocksdb_static_libs} $ENV{WITH_LZ4}/lib/liblz4.a) + ELSE() + SET(rocksdb_static_libs ${rocksdb_static_libs} lz4) + ENDIF() + + IF (NOT "$ENV{WITH_BZ2}" STREQUAL "") + SET(rocksdb_static_libs ${rocksdb_static_libs} $ENV{WITH_BZ2}/lib/libbz2.a) + ELSE() + SET(rocksdb_static_libs ${rocksdb_static_libs} bz2) + ENDIF() + + IF (NOT "$ENV{WITH_SNAPPY}" STREQUAL "") + SET(rocksdb_static_libs ${rocksdb_static_libs} $ENV{WITH_SNAPPY}/lib/libsnappy.a) + ELSE() + SET(rocksdb_static_libs ${rocksdb_static_libs} snappy) + ENDIF() + + + # Add plugin + + MYSQL_ADD_PLUGIN(rocksdb_se ${ROCKSDB_SOURCES} STORAGE_ENGINE STATIC_ONLY MANDATORY LINK_LIBRARIES ${LINK_DIR} ${rocksdb_static_libs}) ADD_SUBDIRECTORY(unittest) ENDIF(ROCKSDB_OK) diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index c84fd3320f64..8d4488cb6984 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -910,7 +910,7 @@ static int rocksdb_close_connection(handlerton* hton, THD* thd) } -static int rocksdb_commit(handlerton* hton, THD* thd, bool commit_trx) +static int rocksdb_commit(handlerton* hton, THD* thd, bool commit_trx, bool) { if (commit_trx) { @@ -3048,7 +3048,7 @@ int ha_rocksdb::index_end() } -int ha_rocksdb::delete_all_rows() +int ha_rocksdb::delete_all_rows(ha_rows* nrows) { DBUG_ENTER("ha_rocksdb::delete_all_rows"); /* diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h index 1b0723f275a1..71a1ad2d67c2 100644 --- a/storage/rocksdb/ha_rocksdb.h +++ b/storage/rocksdb/ha_rocksdb.h @@ -343,7 +343,7 @@ class ha_rocksdb: public handler int extra(enum ha_extra_function operation); int start_stmt(THD *thd, thr_lock_type lock_type); int external_lock(THD *thd, int lock_type); - int delete_all_rows(void); + int delete_all_rows(ha_rows* nrows); int truncate(); int reset()