Skip to content

Commit 7526df9

Browse files
Yoshinori Matsunobuinikep
authored andcommitted
MyRocks to support both dynamic and static plugins
Upstream commit ID: facebook/mysql-5.6@2a347f6 PS-8755: Merge percona-202301 (https://jira.percona.com/browse/PS-8755) Summary: Prior to this diff, fb-mysql MyRocks only supported static plugins, and used sql_print_* APIs for logging, which was not available on dynamic plugins. This diff allows to create either static or dynamic plugins, depending on -DMYSQL_DYNAMIC_PLUGIN. In addition to that, adding another option to skip building MyRocks by -DWITHOUT_ROCKSDB_STORAGE_ENGINE. Without -DMYSQL_DYNAMIC_PLUGIN, it creates static plugin, basically the same behavior as before. With -DMYSQL_DYNAMIC_PLUGIN, it creates dynamic plugin (ha_rocksdb.so). This diff switched using logging API to LogPluginErrMsg, for both static and dynamic plugins. This slightly changed logging formats, like "[Note] [MY-011071] [Server] Plugin rocksdb reported: 'RocksDB: Column Families at start:'". Prior to the diff, "Plugin rocksdb reported:" was not printed. Ways to link with other libraries such as jemalloc are adjusted accordingly. Reviewed By: lth Differential Revision: D41313174 fbshipit-source-id: 8a8708b71da379daea13fcae90e3bb1af5d60f32
1 parent 6b4de17 commit 7526df9

File tree

5 files changed

+66
-59
lines changed

5 files changed

+66
-59
lines changed

mysql-test/suite/rocksdb/r/truncate_failures.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pk
8989
SET DEBUG = "+d,rocksdb_truncate_failure_crash";
9090
TRUNCATE TABLE t1_crash;
9191
ERROR HY000: Lost connection to MySQL server during query
92-
[MY-000000
92+
1
9393
DROP TABLE IF EXISTS t1_crash;
9494
Warnings:
9595
Warning 1146 Table 'test.t1_crash' doesn't exist

mysql-test/suite/rocksdb/t/rocksdb_datadir.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ let $rdb_ddir = $MYSQLTEST_VARDIR/.rocksdb_datadir.test;
99
let $sql_file = $MYSQLTEST_VARDIR/rocksdb_datadir.sql;
1010
let $rdb_plugin_load = $ROCKSDB_LOAD_PATH;
1111

12+
let $is_dynamic_plugin = `select plugin_library='ha_rocksdb.so' from information_schema.plugins where plugin_name='RocksDB'`;
13+
14+
if ($is_dynamic_plugin == 1) {
15+
--skip "skipping test since bootstrap (initialize) does not support plugin-load."
16+
}
17+
1218
--write_file $sql_file
1319
DROP DATABASE IF EXISTS mysqltest;
1420
CREATE DATABASE mysqltest;

mysql-test/suite/rocksdb/t/truncate_failures.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ TRUNCATE TABLE t1_crash;
104104
--enable_reconnect
105105
--source include/wait_until_connected_again.inc
106106
--disable_reconnect
107-
--exec grep 'Removing truncated leftover' $LOG | cut -d] -f2
107+
--exec grep 'Removing truncated leftover' $LOG | wc -l
108108
DROP TABLE IF EXISTS t1_crash;
109109
--remove_file $LOG
110110

storage/rocksdb/CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# TODO: Copyrights
1+
SET (ROCKSDB_DYNAMIC_PLUGIN 1)
22

33
# by default MyRocks is not built
44
IF (NOT DEFINED WITH_ROCKSDB)
@@ -366,7 +366,7 @@ SET(ROCKSDB_SOURCES
366366
sql_dd.cc sql_dd.h
367367
)
368368

369-
IF(WITH_FB_TSAN)
369+
IF(WITH_FB_TSAN OR ROCKSDB_DYNAMIC_PLUGIN)
370370
SET(PIC_EXT "_pic")
371371
ELSE()
372372
SET(PIC_EXT "")
@@ -381,9 +381,13 @@ IF(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
381381
SET(rocksdb_static_libs ${rocksdb_static_libs} "-lrt")
382382
ENDIF()
383383

384-
MYSQL_ADD_PLUGIN(rocksdb ${ROCKSDB_SOURCES} STORAGE_ENGINE DEFAULT MODULE_ONLY
385-
LINK_LIBRARIES ${rocksdb_static_libs}
386-
)
384+
IF (ROCKSDB_DYNAMIC_PLUGIN)
385+
MYSQL_ADD_PLUGIN(rocksdb ${ROCKSDB_SOURCES} STORAGE_ENGINE DEFAULT
386+
MODULE_ONLY LINK_LIBRARIES ${rocksdb_static_libs})
387+
ELSE()
388+
MYSQL_ADD_PLUGIN(rocksdb_se ${ROCKSDB_SOURCES} STORAGE_ENGINE DEFAULT
389+
STATIC_ONLY LINK_LIBRARIES ${rocksdb_static_libs})
390+
ENDIF()
387391

388392
IF (NOT HAVE_EXTERNAL_ROCKSDB)
389393
# TODO: read this file list from src.mk:TOOL_SOURCES

0 commit comments

Comments
 (0)