diff options
author | Varun Gupta <varunraiko1803@gmail.com> | 2017-12-31 16:18:39 +0200 |
---|---|---|
committer | Varun Gupta <varunraiko1803@gmail.com> | 2017-12-31 21:58:50 +0200 |
commit | 7703095d2e26a15d4ecbd3683f9779b97f851c98 (patch) | |
tree | 3c6f8b9673a17c382d4f78c6e141fc3d6ae37f54 | |
parent | a118c20c8151a4e95f133b6d5bf92bafc7835e23 (diff) | |
download | mariadb-git-7703095d2e26a15d4ecbd3683f9779b97f851c98.tar.gz |
MDEV-12458: Variable and log records to indicate RocksDB version are missing
Added a system variabe rocsdb_git_hash to MyRocks which tell us the version of RocksDB being used
-rw-r--r-- | cmake/make_dist.cmake.in | 3 | ||||
-rw-r--r-- | storage/rocksdb/CMakeLists.txt | 15 | ||||
-rw-r--r-- | storage/rocksdb/ha_rocksdb.cc | 8 | ||||
-rw-r--r-- | storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result | 1 | ||||
-rw-r--r-- | storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test | 2 | ||||
-rw-r--r-- | storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_git_hash_basic.test | 6 | ||||
-rw-r--r-- | storage/rocksdb/rdb_source_revision.h.in | 1 |
7 files changed, 36 insertions, 0 deletions
diff --git a/cmake/make_dist.cmake.in b/cmake/make_dist.cmake.in index 3cc93d10fb8..2e3dbb987f0 100644 --- a/cmake/make_dist.cmake.in +++ b/cmake/make_dist.cmake.in @@ -52,6 +52,9 @@ IF(GIT_EXECUTABLE) ENDIF() ENDIF() +CONFIGURE_FILE(${CMAKE_BINARY_DIR}/storage/rocksdb/rdb_source_revision.h + ${PACKAGE_DIR}/storage/rocksdb/rdb_source_revision.h COPYONLY) + IF(NOT GIT_EXECUTABLE) MESSAGE(STATUS "git not found or source dir is not a repo, use CPack") diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index 1e20e0fa4a3..6cb7eb1d439 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -220,3 +220,18 @@ IF(MSVC) # Some checks in C++ runtime that make debug build much slower ADD_DEFINITIONS(-D_ITERATOR_DEBUG_LEVEL=0) ENDIF() + +IF(GIT_EXECUTABLE) + EXECUTE_PROCESS( + COMMAND ${GIT_EXECUTABLE} rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/rocksdb + OUTPUT_VARIABLE OUT RESULT_VARIABLE RES) + IF(RES EQUAL 0) + STRING(REGEX REPLACE "\n$" "" ROCKSDB_GIT_HASH "${OUT}") + ENDIF() +ENDIF() +IF(ROCKSDB_GIT_HASH OR + (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/rdb_source_revision.h)) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/rdb_source_revision.h.in + ${CMAKE_CURRENT_BINARY_DIR}/rdb_source_revision.h ) +ENDIF() diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 8857b2e8cba..4a0a3eddb1a 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -70,6 +70,7 @@ #include "rocksdb/utilities/memory_util.h" #include "rocksdb/utilities/sim_cache.h" #include "util/stop_watch.h" +#include "./rdb_source_revision.h" /* MyRocks includes */ #include "./event_listener.h" @@ -494,6 +495,7 @@ static uint32_t rocksdb_table_stats_sampling_pct; static my_bool rocksdb_enable_bulk_load_api = 1; static my_bool rocksdb_print_snapshot_conflict_queries = 0; static my_bool rocksdb_large_prefix = 0; +static char* rocksdb_git_hash; char *compression_types_val= const_cast<char*>(get_rocksdb_supported_compression_types()); @@ -650,6 +652,11 @@ static MYSQL_SYSVAR_BOOL(enable_bulk_load_api, rocksdb_enable_bulk_load_api, "Enables using SstFileWriter for bulk loading", nullptr, nullptr, rocksdb_enable_bulk_load_api); +static MYSQL_SYSVAR_STR(git_hash, rocksdb_git_hash, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "Git revision of the RocksDB library used by MyRocks", + nullptr, nullptr, ROCKSDB_GIT_HASH); + static MYSQL_THDVAR_STR(tmpdir, PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_MEMALLOC, "Directory for temporary files during DDL operations.", nullptr, nullptr, ""); @@ -1633,6 +1640,7 @@ static struct st_mysql_sys_var *rocksdb_system_variables[] = { MYSQL_SYSVAR(table_stats_sampling_pct), MYSQL_SYSVAR(large_prefix), + MYSQL_SYSVAR(git_hash), nullptr}; static rocksdb::WriteOptions diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result index d791cf98bb0..9b084e63cd5 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result @@ -924,6 +924,7 @@ rocksdb_force_compute_memtable_stats_cachetime 0 rocksdb_force_flush_memtable_and_lzero_now OFF rocksdb_force_flush_memtable_now OFF rocksdb_force_index_records_in_range 0 +rocksdb_git_hash # rocksdb_hash_index_allow_collision ON rocksdb_index_type kBinarySearch rocksdb_info_log_level error_level diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test index 5c8fa9ed443..9199c572933 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test @@ -786,6 +786,8 @@ drop table t45; --echo # Now it fails if there is data overlap with what --echo # already exists --echo # + +--replace_regex /[a-f0-9]{40}/#/ show variables where variable_name like 'rocksdb%' and diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_git_hash_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_git_hash_basic.test new file mode 100644 index 00000000000..7b314e47d4b --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_git_hash_basic.test @@ -0,0 +1,6 @@ +--source include/have_rocksdb.inc + +--let $sys_var=ROCKSDB_GIT_HASH +--let $read_only=1 +--let $session=0 +--source include/rocksdb_sys_var.inc diff --git a/storage/rocksdb/rdb_source_revision.h.in b/storage/rocksdb/rdb_source_revision.h.in new file mode 100644 index 00000000000..617b39c9186 --- /dev/null +++ b/storage/rocksdb/rdb_source_revision.h.in @@ -0,0 +1 @@ +#define ROCKSDB_GIT_HASH "@ROCKSDB_GIT_HASH@" |