diff --git a/include/ut0counter.h b/include/ut0counter.h index e6bdc183384c..4e39dfc117be 100644 --- a/include/ut0counter.h +++ b/include/ut0counter.h @@ -55,7 +55,8 @@ struct generic_indexer_t { }; #ifdef HAVE_SCHED_GETCPU -#include +//#include // Including this causes problems with EMPTY symbol +#include // Include this instead /** Use the cpu id to index into the counter array. If it fails then use the thread id. */ template @@ -66,7 +67,7 @@ struct get_sched_indexer_t : public generic_indexer_t { size_t get_rnd_index() const { size_t cpu = sched_getcpu(); - if (cpu == -1) { + if (cpu == (size_t) -1) { cpu = get_curr_thread_id(); } diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index f2c52ce84c42..638478a23467 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -4,6 +4,11 @@ IF (NOT EXISTS "${CMAKE_SOURCE_DIR}/rocksdb/Makefile") MESSAGE(SEND_ERROR "Missing Makefile in rocksdb directory. Try \"git submodule update\".") ENDIF() +CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU) +IF(HAVE_SCHED_GETCPU) + ADD_DEFINITIONS(-DHAVE_SCHED_GETCPU=1) +ENDIF() + # get a list of rocksdb library source files # run with env -i to avoid passing variables EXECUTE_PROCESS( diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 618d68b27e2f..9a32aa679622 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -3641,6 +3641,18 @@ static int rocksdb_init_func(void *p) rdb->PauseBackgroundWork(); } + // NO_LINT_DEBUG + sql_print_information("RocksDB: global statistics using %s indexer", + STRINGIFY_ARG(RDB_INDEXER)); +#if defined(HAVE_SCHED_GETCPU) + if (sched_getcpu() == -1) + { + // NO_LINT_DEBUG + sql_print_information("RocksDB: sched_getcpu() failed - " + "global statistics will use thread_id_indexer_t instead"); + } +#endif + sql_print_information("RocksDB instance opened"); DBUG_RETURN(0); } diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h index adeb1ccdeeeb..9a2464c835ea 100644 --- a/storage/rocksdb/ha_rocksdb.h +++ b/storage/rocksdb/ha_rocksdb.h @@ -237,13 +237,19 @@ enum operation_type { ROWS_MAX }; +#if defined(HAVE_SCHED_GETCPU) +#define RDB_INDEXER get_sched_indexer_t +#else +#define RDB_INDEXER thread_id_indexer_t +#endif + /* Global statistics struct used inside MyRocks */ struct st_global_stats { - ib_counter_t rows[ROWS_MAX]; + ib_counter_t rows[ROWS_MAX]; // system_rows_ stats are only for system // tables. They are not counted in rows_* stats. - ib_counter_t system_rows[ROWS_MAX]; + ib_counter_t system_rows[ROWS_MAX]; }; /* Struct used for exporting status to MySQL */