[FEAT MERGE] 开源裁减颗粒度优化
Co-authored-by: nroskill <nroskill@gmail.com> Co-authored-by: akaError <lzg020616@163.com> Co-authored-by: yinyj17 <yinyijun92@gmail.com>
This commit is contained in:
parent
a31e422133
commit
9b31f8aa03
6
.gitignore
vendored
6
.gitignore
vendored
@ -172,6 +172,12 @@ src/pl/parser/_gen_pl_parser.output
|
||||
src/pl/parser/pl_parser_mysql_mode.output
|
||||
src/pl/parser/pl_parser_oracle_mode.output
|
||||
|
||||
############# close_modules #############
|
||||
close_modules/oracle_pl/pl/parser/*.output
|
||||
close_modules/oracle_pl/pl/parser/pl_parser_oracle_mode_lex.c
|
||||
close_modules/oracle_pl/pl/parser/pl_parser_oracle_mode_tab.c
|
||||
close_modules/oracle_pl/pl/parser/pl_parser_oracle_mode_tab.h
|
||||
|
||||
############# tools #############
|
||||
tools/ObRestore/mvn_repository
|
||||
tools/agentserver/agentserver
|
||||
|
@ -3,12 +3,20 @@ cmake_minimum_required(VERSION 3.20)
|
||||
include(cmake/Utils.cmake)
|
||||
include(cmake/Env.cmake)
|
||||
|
||||
project("OceanBase_CE"
|
||||
VERSION 4.2.0.0
|
||||
DESCRIPTION "OceanBase distributed database system"
|
||||
HOMEPAGE_URL "https://open.oceanbase.com/"
|
||||
LANGUAGES CXX C ASM)
|
||||
message(STATUS "open source build enabled")
|
||||
if(OB_BUILD_OPENSOURCE)
|
||||
project("OceanBase_CE"
|
||||
VERSION 4.2.0.0
|
||||
DESCRIPTION "OceanBase distributed database system"
|
||||
HOMEPAGE_URL "https://open.oceanbase.com/"
|
||||
LANGUAGES CXX C ASM)
|
||||
message(STATUS "open source build enabled")
|
||||
else()
|
||||
project(OceanBase
|
||||
VERSION 4.2.0.0
|
||||
DESCRIPTION "OceanBase distributed database system"
|
||||
HOMEPAGE_URL "https://www.oceanbase.com/"
|
||||
LANGUAGES CXX C ASM)
|
||||
endif()
|
||||
|
||||
|
||||
if(ENABLE_COMPILE_DLL_MODE)
|
||||
@ -94,6 +102,11 @@ message(STATUS "This is SOURCE dir " ${PROJECT_SOURCE_DIR})
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
if(EXISTS ${CMAKE_SOURCE_DIR}/close_modules)
|
||||
message(STATUS "will add close_modules sub directory")
|
||||
add_subdirectory(close_modules)
|
||||
endif()
|
||||
|
||||
add_subdirectory(deps/easy)
|
||||
add_subdirectory(deps/oblib)
|
||||
add_subdirectory(src/objit)
|
||||
@ -141,10 +154,23 @@ cmake_dependent_option(
|
||||
include(CTest)
|
||||
if (OB_BUILD_UNITTEST)
|
||||
add_subdirectory(unittest)
|
||||
if(OB_BUILD_CLOSE_MODULES)
|
||||
add_subdirectory(mittest)
|
||||
endif()
|
||||
elseif(OB_INCLUDE_UNITTEST)
|
||||
add_subdirectory(unittest EXCLUDE_FROM_ALL)
|
||||
if(OB_BUILD_CLOSE_MODULES)
|
||||
add_subdirectory(mittest EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_CLOSE_MODULES)
|
||||
if (OB_BUILD_TEST)
|
||||
add_subdirectory(test)
|
||||
elseif(OB_INCLUDE_TEST)
|
||||
add_subdirectory(test EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (OB_BUILD_TOOLS)
|
||||
add_subdirectory(tools)
|
||||
|
125
cmake/Env.cmake
125
cmake/Env.cmake
@ -37,6 +37,9 @@ ob_define(OB_MAX_UNITY_BATCH_SIZE 30)
|
||||
# the global switch of unity build, defualt is 'ON'
|
||||
ob_define(OB_ENABLE_UNITY ON)
|
||||
|
||||
ob_define(OB_BUILD_OPENSOURCE ON)
|
||||
|
||||
|
||||
if(WITH_COVERAGE)
|
||||
# -ftest-coverage to generate .gcno file
|
||||
# -fprofile-arcs to generate .gcda file
|
||||
@ -61,6 +64,88 @@ if(ENABLE_THIN_LTO)
|
||||
set(THIN_LTO_CONCURRENCY_LINK "-Wl,--thinlto-jobs=32,--lto-whole-program-visibility")
|
||||
endif()
|
||||
|
||||
set(ob_close_modules_static_name "")
|
||||
set(ob_close_deps_static_name "")
|
||||
|
||||
if (OB_BUILD_OPENSOURCE)
|
||||
# 开源模式
|
||||
set(OB_BUILD_CLOSE_MODULES OFF)
|
||||
else()
|
||||
# 闭源模式
|
||||
set(OB_BUILD_CLOSE_MODULES ON)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_CLOSE_MODULES)
|
||||
# SECURITY, 包含3个功能点
|
||||
ob_define(OB_BUILD_TDE_SECURITY ON)
|
||||
ob_define(OB_BUILD_AUDIT_SECURITY ON)
|
||||
ob_define(OB_BUILD_LABEL_SECURITY ON)
|
||||
# 字符集
|
||||
ob_define(OB_BUILD_FULL_CHARSET ON)
|
||||
# SPM功能
|
||||
ob_define(OB_BUILD_SPM ON)
|
||||
|
||||
# oralce
|
||||
ob_define(OB_BUILD_ORACLE_PARSER ON)
|
||||
ob_define(OB_BUILD_ORACLE_PL ON)
|
||||
ob_define(OB_BUILD_ORACLE_XML ON)
|
||||
# dblink
|
||||
ob_define(OB_BUILD_DBLINK ON)
|
||||
# 仲裁功能
|
||||
ob_define(OB_BUILD_ARBITRATION ON)
|
||||
|
||||
# 默认使用BABASSL
|
||||
ob_define(OB_USE_BABASSL ON)
|
||||
add_definitions(-DOB_USE_BABASSL)
|
||||
# 默认使用OB_USE_DRCMSG
|
||||
ob_define(OB_USE_DRCMSG ON)
|
||||
add_definitions(-DOB_USE_DRCMSG)
|
||||
endif()
|
||||
|
||||
# 下面开始逻辑控制
|
||||
if(OB_BUILD_CLOSE_MODULES)
|
||||
add_definitions(-DOB_BUILD_CLOSE_MODULES)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_TDE_SECURITY)
|
||||
add_definitions(-DOB_BUILD_TDE_SECURITY)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_AUDIT_SECURITY)
|
||||
add_definitions(-DOB_BUILD_AUDIT_SECURITY)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_LABEL_SECURITY)
|
||||
add_definitions(-DOB_BUILD_LABEL_SECURITY)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_FULL_CHARSET)
|
||||
add_definitions(-DOB_BUILD_FULL_CHARSET)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_SPM)
|
||||
add_definitions(-DOB_BUILD_SPM)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_ORACLE_PARSER)
|
||||
add_definitions(-DOB_BUILD_ORACLE_PARSER)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_ORACLE_PL)
|
||||
add_definitions(-DOB_BUILD_ORACLE_PL)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_ORACLE_XML)
|
||||
add_definitions(-DOB_BUILD_ORACLE_XML)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_ARBITRATION)
|
||||
add_definitions(-DOB_BUILD_ARBITRATION)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_DBLINK)
|
||||
add_definitions(-DOB_BUILD_DBLINK)
|
||||
endif()
|
||||
|
||||
# should not use initial-exec for tls-model if building OBCDC.
|
||||
if(NOT OB_BUILD_CDC)
|
||||
@ -125,7 +210,36 @@ if (OB_USE_CLANG)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${LD_OPT} -Wl,-z,noexecstack ${THIN_LTO_CONCURRENCY_LINK} ${REORDER_LINK_OPT}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${LD_OPT} -Wl,-z,noexecstack -pie ${THIN_LTO_CONCURRENCY_LINK} ${REORDER_LINK_OPT} ${CMAKE_COVERAGE_EXE_LINKER_OPTIONS}")
|
||||
else() # not clang, use gcc
|
||||
if(OB_BUILD_OPENSOURCE)
|
||||
message("gcc9 not support currently, please set OB_USE_CLANG ON and we will finish it as soon as possible")
|
||||
else()
|
||||
|
||||
if (OB_CC)
|
||||
message(STATUS "Using OB_CC compiler: ${OB_CC}")
|
||||
else()
|
||||
find_program(OB_CC gcc
|
||||
PATHS ${DEVTOOLS_DIR}/bin
|
||||
NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
if (OB_CXX)
|
||||
message(STATUS "Using OB_CXX compiler: ${OB_CXX}")
|
||||
else()
|
||||
find_program(OB_CXX g++
|
||||
PATHS ${DEVTOOLS_DIR}/bin
|
||||
NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
if (OB_USE_LLD)
|
||||
set(LD_OPT "-B${CMAKE_SOURCE_DIR}/rpm/.compile")
|
||||
set(REORDER_COMP_OPT "-ffunction-sections")
|
||||
set(REORDER_LINK_OPT "-Wl,--no-warn-symbol-ordering,--symbol-ordering-file,${HOTFUNC_PATH}")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS "${LD_OPT} -fdiagnostics-color ${REORDER_COMP_OPT}")
|
||||
set(CMAKE_C_FLAGS "${LD_OPT} -fdiagnostics-color ${REORDER_COMP_OPT}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-z noexecstack ${REORDER_LINK_OPT}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-z noexecstack ${REORDER_LINK_OPT}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (OB_BUILD_CCLS)
|
||||
@ -143,6 +257,15 @@ else()
|
||||
message(FATAL_ERROR "can't find suitable compiler")
|
||||
endif()
|
||||
|
||||
find_program(OB_COMPILE_EXECUTABLE ob-compile)
|
||||
if (NOT OB_COMPILE_EXECUTABLE)
|
||||
message(STATUS "ob-compile not found, compile locally.")
|
||||
else()
|
||||
set(CMAKE_C_COMPILER_LAUNCHER ${OB_COMPILE_EXECUTABLE})
|
||||
set(CMAKE_CXX_COMPILER_LAUNCHER ${OB_COMPILE_EXECUTABLE})
|
||||
set(CMAKE_C_LINKER_LAUNCHER ${OB_COMPILE_EXECUTABLE})
|
||||
set(CMAKE_CXX_LINKER_LAUNCHER ${OB_COMPILE_EXECUTABLE})
|
||||
endif()
|
||||
|
||||
option(OB_ENABLE_AVX2 "enable AVX2 and related instruction set support for x86_64" OFF)
|
||||
|
||||
@ -152,8 +275,6 @@ if( ${ARCHITECTURE} STREQUAL "x86_64" )
|
||||
set(MTUNE_CFLAGS -mtune=core2)
|
||||
set(ARCH_LDFLAGS "")
|
||||
set(OCI_DEVEL_INC "${DEP_3RD_DIR}/usr/include/oracle/11.2/client64")
|
||||
add_compile_options(-DRDMA_ENABLED)
|
||||
set(rdma_lib_deps "reasy" )
|
||||
else()
|
||||
set(MARCH_CFLAGS "-march=armv8-a+crc" )
|
||||
set(MTUNE_CFLAGS "-mtune=generic" )
|
||||
|
@ -17,6 +17,7 @@ set(CPACK_PACKAGING_INSTALL_PREFIX /home/admin/oceanbase)
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OceanBase is a distributed relational database")
|
||||
set(CPACK_PACKAGE_VENDOR "OceanBase Inc.")
|
||||
set(CPACK_RPM_PACKAGE_RELEASE ${OB_RELEASEID})
|
||||
if (OB_BUILD_OPENSOURCE)
|
||||
set(CPACK_PACKAGE_NAME "oceanbase-ce")
|
||||
set(CPACK_PACKAGE_VERSION "${OceanBase_CE_VERSION}")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${OceanBase_CE_VERSION_MAJOR}")
|
||||
@ -30,6 +31,14 @@ set(CPACK_RPM_UTILS_PACKAGE_PREFIX /usr)
|
||||
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/home")
|
||||
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/home/admin")
|
||||
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/home/admin/oceanbase")
|
||||
else()
|
||||
set(CPACK_PACKAGE_NAME "oceanbase")
|
||||
set(CPACK_PACKAGE_VERSION "${OceanBase_VERSION}")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${OceanBase_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${OceanBase_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${OceanBase_VERSION_PATCH}")
|
||||
set(CPACK_RPM_PACKAGE_URL "${OceanBase_HOMEPAGE_URL}")
|
||||
endif()
|
||||
set(CPACK_RPM_PACKAGE_GROUP "Applications/Databases")
|
||||
set(CPACK_RPM_PACKAGE_DESCRIPTION "OceanBase is a distributed relational database")
|
||||
set(CPACK_RPM_PACKAGE_LICENSE "Mulan PubL v2.")
|
||||
@ -54,11 +63,24 @@ set(CPACK_RPM_SPEC_MORE_DEFINE
|
||||
set(BITCODE_TO_ELF_LIST "")
|
||||
|
||||
## server
|
||||
if (OB_BUILD_OPENSOURCE)
|
||||
install(PROGRAMS
|
||||
tools/import_time_zone_info.py
|
||||
${CMAKE_BINARY_DIR}/src/observer/observer
|
||||
DESTINATION bin
|
||||
COMPONENT server)
|
||||
else()
|
||||
install(PROGRAMS
|
||||
script/dooba/dooba
|
||||
tools/import_time_zone_info.py
|
||||
tools/import_srs_data.py
|
||||
${CMAKE_BINARY_DIR}/tools/ob_admin/ob_admin
|
||||
tools/ob_admin/io_bench/bench_io.sh
|
||||
${CMAKE_BINARY_DIR}/src/observer/observer
|
||||
$<$<STREQUAL:"${ARCHITECTURE}","x86_64">:${DEVTOOLS_DIR}/bin/obstack>
|
||||
DESTINATION bin
|
||||
COMPONENT server)
|
||||
endif()
|
||||
|
||||
install(FILES
|
||||
src/sql/fill_help_tables-ob.sql
|
||||
@ -97,12 +119,22 @@ install(
|
||||
COMPONENT cdc
|
||||
)
|
||||
|
||||
if(OB_BUILD_OPENSOURCE)
|
||||
install(
|
||||
FILES
|
||||
${PROJECT_SOURCE_DIR}/src/logservice/libobcdc/tests/libobcdc.conf
|
||||
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}
|
||||
COMPONENT cdc
|
||||
)
|
||||
else()
|
||||
install(
|
||||
FILES
|
||||
${PROJECT_SOURCE_DIR}/src/logservice/libobcdc/tests/libobcdc.conf
|
||||
${PROJECT_SOURCE_DIR}/src/logservice/libobcdc/tests/timezone_info.conf
|
||||
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}
|
||||
COMPONENT cdc
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
## oceanbase-sql-parser
|
||||
@ -331,6 +363,7 @@ if (OB_BUILD_LIBOBTABLE)
|
||||
COMPONENT table)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_OPENSOURCE)
|
||||
## oceanbase-libs
|
||||
install(PROGRAMS
|
||||
deps/3rd/usr/local/oceanbase/deps/devel/lib/libaio.so.1
|
||||
@ -350,6 +383,7 @@ if(OB_BUILD_OBADMIN)
|
||||
COMPONENT utils
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# install cpack to make everything work
|
||||
include(CPack)
|
||||
|
@ -1,3 +1,6 @@
|
||||
if(NOT OB_BUILD_OPENSOURCE)
|
||||
include(cmake/Err.cmake)
|
||||
endif()
|
||||
|
||||
macro(ob_define VAR DEFAULT)
|
||||
if (NOT DEFINED ${VAR})
|
||||
@ -11,27 +14,26 @@ function(ob_replace_in_file INFILE OUTFILE MATCH-STRING REPLACE-STRING)
|
||||
file(WRITE ${OUTFILE} ${NEW-CONTENT})
|
||||
endfunction()
|
||||
|
||||
# ob_set_subtarget usage demo
|
||||
# ob_set_subtarget(ob_sql common
|
||||
# sql1.cpp
|
||||
# sql2.cpp
|
||||
# sql3.cpp
|
||||
# )
|
||||
# ob_set_subtarget(ob_sql executor
|
||||
# executor/ob_executor1.cpp
|
||||
# executor/ob_executor2.cpp
|
||||
# executor/ob_executor3.cpp
|
||||
# )
|
||||
function(ob_set_subtarget target group)
|
||||
list(APPEND "${target}_cache_objects_" ${ARGN})
|
||||
|
||||
list(LENGTH ${target}_cache_objects_ CCLS_TARGET_CURRENT_LENGTH)
|
||||
|
||||
# 需要参与编译的源文件列表
|
||||
set(ARGN_NEED_LIST "")
|
||||
|
||||
FOREACH(item ${ARGN})
|
||||
list(APPEND ARGN_NEED_LIST ${item})
|
||||
ENDFOREACH(item)
|
||||
|
||||
list(APPEND "${target}_cache_objects_" ${ARGN_NEED_LIST})
|
||||
set("${target}_cache_objects_" ${${target}_cache_objects_} PARENT_SCOPE)
|
||||
|
||||
# if need check ob cmake rules
|
||||
if (OB_CMAKE_RULES_CHECK)
|
||||
FOREACH(item ${ARGN})
|
||||
FOREACH(item ${ARGN_NEED_LIST})
|
||||
# [E1001] Header files are not allowed in CMakeLists.txt
|
||||
string(REGEX MATCHALL "^.*\.h$" MATCH_OUTPUT ${item})
|
||||
if(MATCH_OUTPUT)
|
||||
message(FATAL_ERROR "Header files are not allowed in CMakeLists.txt\n")
|
||||
message(FATAL_ERROR "\n${E1001}\n不允许把头文件${item}写到CMakeLists.txt文件中\n")
|
||||
endif()
|
||||
ENDFOREACH(item)
|
||||
endif()
|
||||
@ -41,30 +43,55 @@ function(ob_set_subtarget target group)
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
# ALONE group will not join unity build
|
||||
if(group STREQUAL "ALONE")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(i 0)
|
||||
set(group_id 0)
|
||||
if (NOT OB_BUILD_CCLS)
|
||||
set(i 0)
|
||||
set(group_id 0)
|
||||
else()
|
||||
# ccls构建,将更改分组方法,是以target为单位,而不是以group为单元
|
||||
set(i ${CCLS_TARGET_CURRENT_LENGTH})
|
||||
math(EXPR group_id "(${i} / ${OB_MAX_UNITY_BATCH_SIZE})")
|
||||
endif()
|
||||
|
||||
set(ob_sub_objects "")
|
||||
FOREACH(item ${ARGN})
|
||||
FOREACH(item ${ARGN_NEED_LIST})
|
||||
math(EXPR i "(${i} + 1) % ${OB_MAX_UNITY_BATCH_SIZE}")
|
||||
list(APPEND ob_sub_objects ${item})
|
||||
if (${i} EQUAL 0)
|
||||
set_source_files_properties(${ob_sub_objects} PROPERTIES UNITY_GROUP "${target}_${group}/${group_id}")
|
||||
if (NOT OB_BUILD_CCLS)
|
||||
set_source_files_properties(${ob_sub_objects} PROPERTIES UNITY_GROUP "${target}_${group}/${group_id}")
|
||||
else()
|
||||
set_source_files_properties(${ob_sub_objects} PROPERTIES UNITY_GROUP "${target}/${group_id}")
|
||||
endif()
|
||||
math(EXPR group_id "${group_id} + 1")
|
||||
set(ob_sub_objects "")
|
||||
endif()
|
||||
ENDFOREACH(item)
|
||||
|
||||
if (${i} GREATER 0)
|
||||
set_source_files_properties(${ob_sub_objects} PROPERTIES UNITY_GROUP "${target}_${group}/${group_id}")
|
||||
if (NOT OB_BUILD_CCLS)
|
||||
set_source_files_properties(${ob_sub_objects} PROPERTIES UNITY_GROUP "${target}_${group}/${group_id}")
|
||||
else()
|
||||
set_source_files_properties(${ob_sub_objects} PROPERTIES UNITY_GROUP "${target}/${group_id}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
function (check_need_build_unity_target target need_build)
|
||||
list(LENGTH ${target}_cache_objects_ TARGET_LENGTH)
|
||||
if (TARGET_LENGTH EQUAL 0)
|
||||
set(${need_build} FALSE PARENT_SCOPE)
|
||||
else()
|
||||
set(${need_build} TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
set(unity_after [[
|
||||
#ifdef USING_LOG_PREFIX
|
||||
#undef USING_LOG_PREFIX
|
||||
|
18
deps/easy/CMakeLists.txt
vendored
18
deps/easy/CMakeLists.txt
vendored
@ -20,11 +20,19 @@ set_property(GLOBAL PROPERTY EASY_INCLUDE_DIRS
|
||||
${INNER_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
easy_base INTERFACE
|
||||
${INNER_INCLUDE_DIRS}
|
||||
${DEP_DIR}/include
|
||||
)
|
||||
if(OB_USE_BABASSL)
|
||||
target_include_directories(
|
||||
easy_base INTERFACE
|
||||
${INNER_INCLUDE_DIRS}
|
||||
${DEP_3RD_DIR}/usr/local/babassl-ob/include
|
||||
)
|
||||
else()
|
||||
target_include_directories(
|
||||
easy_base INTERFACE
|
||||
${INNER_INCLUDE_DIRS}
|
||||
${DEP_DIR}/include
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
if (OB_USE_CLANG)
|
||||
|
99
deps/easy/src/io/easy_ssl.c
vendored
99
deps/easy/src/io/easy_ssl.c
vendored
@ -990,6 +990,18 @@ easy_ssl_ctx_t *easy_ssl_ctx_load(easy_pool_t *pool, const char *ssl_ca,
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
#ifdef OB_USE_BABASSL
|
||||
if (is_babassl) {
|
||||
if (!ssl_enc_cert || 0 == strlen(ssl_enc_cert)) {
|
||||
easy_info_log("sm scene, no ssl_enc_cert");
|
||||
goto error_exit;
|
||||
}
|
||||
if (!ssl_enc_key || 0 == strlen(ssl_enc_key)) {
|
||||
easy_info_log("sm scene, no ssl_enc_key");
|
||||
goto error_exit;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((ss = (easy_ssl_ctx_t *)easy_pool_calloc(pool, sizeof(easy_ssl_ctx_t))) == NULL) {
|
||||
easy_error_log("easy_pool_calloc easy_ssl_ctx_t failed, size=%u", sizeof(easy_ssl_ctx_t));
|
||||
@ -1019,6 +1031,33 @@ easy_ssl_ctx_t *easy_ssl_ctx_load(easy_pool_t *pool, const char *ssl_ca,
|
||||
}
|
||||
|
||||
if (is_from_file) {
|
||||
#ifdef OB_USE_BABASSL
|
||||
if (is_babassl) {
|
||||
if (!SSL_CTX_use_sign_PrivateKey_file(ss->ctx, ssl_key,
|
||||
SSL_FILETYPE_PEM)) {
|
||||
easy_info_log("SSL_CTX_use_sign_PrivateKey_file failed!");
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
if (!SSL_CTX_use_sign_certificate_file(ss->ctx, ssl_cert,
|
||||
SSL_FILETYPE_PEM)) {
|
||||
easy_info_log("SSL_CTX_use_sign_certificate_file failed!");
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
if (!SSL_CTX_use_enc_PrivateKey_file(ss->ctx, ssl_enc_key,
|
||||
SSL_FILETYPE_PEM)) {
|
||||
easy_info_log("SSL_CTX_use_enc_PrivateKey_file failed!");
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
if (!SSL_CTX_use_enc_certificate_file(ss->ctx, ssl_enc_cert,
|
||||
SSL_FILETYPE_PEM)) {
|
||||
easy_info_log("SSL_CTX_use_enc_certificate_file failed!");
|
||||
goto error_exit;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(!is_babassl) {
|
||||
if (easy_ssl_client_certificate_for_mysql(ss, ssl_ca, 1) != EASY_OK) {
|
||||
easy_error_log("easy_ssl_client_certificate_for_mysql failed, client_certificate=%s", ssl_ca);
|
||||
@ -1032,6 +1071,42 @@ easy_ssl_ctx_t *easy_ssl_ctx_load(easy_pool_t *pool, const char *ssl_ca,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#ifdef OB_USE_BABASSL
|
||||
if (is_babassl) {
|
||||
if (NULL == (pkey = easy_ssl_read_sm_pkey(ssl_key))) {
|
||||
goto error_exit;
|
||||
}
|
||||
if (!SSL_CTX_use_sign_PrivateKey(ss->ctx, pkey)) {
|
||||
easy_info_log("SSL_CTX_use_sign_PrivateKey failed!");
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
if (NULL == (x509 = easy_ssl_get_sm_cert(ssl_cert))) {
|
||||
goto error_exit;
|
||||
}
|
||||
if (!SSL_CTX_use_sign_certificate(ss->ctx, x509)) {
|
||||
easy_info_log("SSL_CTX_use_sign_certificate failed");
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
if (NULL == (pkey = easy_ssl_read_sm_pkey(ssl_enc_key))) {
|
||||
goto error_exit;
|
||||
}
|
||||
if (!SSL_CTX_use_enc_PrivateKey(ss->ctx, pkey)) {
|
||||
easy_info_log("SSL_CTX_use_enc_PrivateKey failed!");
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
if (NULL == (x509 = easy_ssl_get_sm_cert(ssl_enc_cert))) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
if (!SSL_CTX_use_enc_certificate(ss->ctx, x509)) {
|
||||
easy_info_log("SSL_CTX_use_enc_certificate failed");
|
||||
goto error_exit;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!is_babassl) {
|
||||
if (easy_ssl_client_certificate_for_mysql_memory(ss, ssl_ca) != EASY_OK) {
|
||||
easy_error_log("easy_ssl_client_certificate_for_mysql_memory failed, client_certificate=%s", ssl_ca);
|
||||
@ -1505,8 +1580,19 @@ static int easy_ssl_ctx_create(easy_ssl_ctx_t *ssl)
|
||||
|
||||
static int easy_ssl_ctx_create_for_mysql(easy_ssl_ctx_t *ssl, int is_babassl)
|
||||
{
|
||||
#ifdef OB_USE_BABASSL
|
||||
if (is_babassl) {
|
||||
ssl->ctx = SSL_CTX_new(NTLS_method());
|
||||
if (NULL != ssl->ctx) {
|
||||
SSL_CTX_enable_ntls(ssl->ctx);
|
||||
}
|
||||
} else {
|
||||
ssl->ctx = SSL_CTX_new(SSLv23_method());
|
||||
}
|
||||
#else
|
||||
(void)is_babassl;
|
||||
ssl->ctx = SSL_CTX_new(SSLv23_method());
|
||||
#endif
|
||||
|
||||
if (ssl->ctx == NULL) {
|
||||
easy_ssl_error(EASY_LOG_ERROR, "SSL_CTX_new() failed");
|
||||
@ -1733,6 +1819,7 @@ static int easy_ssl_dhparam(easy_ssl_ctx_t *ssl, char *file)
|
||||
return EASY_ERROR;
|
||||
}
|
||||
|
||||
#ifndef OB_USE_BABASSL
|
||||
dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
|
||||
dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL);
|
||||
|
||||
@ -1741,6 +1828,18 @@ static int easy_ssl_dhparam(easy_ssl_ctx_t *ssl, char *file)
|
||||
DH_free(dh);
|
||||
return EASY_ERROR;
|
||||
}
|
||||
#else
|
||||
if (1 != DH_set0_pqg(dh, BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL), NULL, NULL)) {
|
||||
easy_ssl_error(EASY_LOG_ERROR, "BN_bin2bn() failed");
|
||||
DH_free(dh);
|
||||
return EASY_ERROR;
|
||||
}
|
||||
if (1 != DH_set0_pqg(dh, NULL, NULL, BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL))) {
|
||||
easy_ssl_error(EASY_LOG_ERROR, "BN_bin2bn() failed");
|
||||
DH_free(dh);
|
||||
return EASY_ERROR;
|
||||
}
|
||||
#endif
|
||||
SSL_CTX_set_tmp_dh(ssl->ctx, dh);
|
||||
|
||||
DH_free(dh);
|
||||
|
105
deps/oblib/src/CMakeLists.txt
vendored
105
deps/oblib/src/CMakeLists.txt
vendored
@ -3,11 +3,9 @@ add_library(oblib_base_base_base INTERFACE)
|
||||
|
||||
get_property(EASY_INCLUDE_DIRS GLOBAL PROPERTY "EASY_INCLUDE_DIRS" )
|
||||
|
||||
|
||||
target_include_directories(
|
||||
oblib_base_base_base INTERFACE
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/deps/oblib/src/lib/oracleclient
|
||||
${CMAKE_SOURCE_DIR}/deps/easy/src
|
||||
${CMAKE_SOURCE_DIR}/deps/oblib/src
|
||||
${CMAKE_SOURCE_DIR}/deps/oblib/src/common
|
||||
@ -18,16 +16,88 @@ target_include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src/objit/src
|
||||
${DEP_DIR}/include
|
||||
${DEP_DIR}/include/libxml2
|
||||
${DEP_DIR}/include/mariadb
|
||||
${DEP_3RD_DIR}/usr/local/include
|
||||
${DEVTOOLS_DIR}
|
||||
${DEP_3RD_DIR}/usr/local/include
|
||||
${DEP_3RD_DIR}/usr/include/
|
||||
${DEP_3RD_DIR}/usr/local/include
|
||||
${DEP_DIR}/include/apr-1/
|
||||
${DEP_DIR}/include/icu/common
|
||||
${USSL_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
if(OB_BUILD_OPENSOURCE)
|
||||
target_include_directories(
|
||||
oblib_base_base_base INTERFACE
|
||||
${DEP_DIR}/include/mariadb
|
||||
)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_SPM)
|
||||
target_include_directories(
|
||||
oblib_base_base_base INTERFACE
|
||||
${CMAKE_SOURCE_DIR}/close_modules/spm
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
if(OB_BUILD_DBLINK)
|
||||
target_include_directories(
|
||||
oblib_base_base_base INTERFACE
|
||||
${DEP_3RD_DIR}/u01/obclient/include
|
||||
${CMAKE_SOURCE_DIR}/close_modules/dblink/deps/oblib/src
|
||||
${OCI_DEVEL_INC}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_ARBITRATION)
|
||||
target_include_directories(
|
||||
oblib_base_base_base INTERFACE
|
||||
${CMAKE_SOURCE_DIR}/close_modules/arbitration
|
||||
)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_ORACLE_PL)
|
||||
target_include_directories(
|
||||
oblib_base_base_base INTERFACE
|
||||
${CMAKE_SOURCE_DIR}/close_modules/oracle_pl
|
||||
)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_TDE_SECURITY)
|
||||
target_include_directories(
|
||||
oblib_base_base_base INTERFACE
|
||||
${CMAKE_SOURCE_DIR}/close_modules/tde_security
|
||||
)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_ORACLE_XML)
|
||||
target_include_directories(
|
||||
oblib_base_base_base INTERFACE
|
||||
${CMAKE_SOURCE_DIR}/close_modules/xml
|
||||
${CMAKE_SOURCE_DIR}/close_modules/xml/deps/oblib/src/
|
||||
)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_AUDIT_SECURITY)
|
||||
target_include_directories(
|
||||
oblib_base_base_base INTERFACE
|
||||
${CMAKE_SOURCE_DIR}/close_modules/audit_security
|
||||
)
|
||||
endif()
|
||||
|
||||
if(OB_BUILD_ORACLE_XML)
|
||||
target_include_directories(
|
||||
oblib_base_base_base INTERFACE
|
||||
${CMAKE_SOURCE_DIR}/close_modules/charset
|
||||
${CMAKE_SOURCE_DIR}/close_modules/charset/deps/oblib/src/
|
||||
)
|
||||
endif()
|
||||
|
||||
if(OB_USE_BABASSL)
|
||||
target_include_directories(
|
||||
oblib_base_base_base INTERFACE
|
||||
${DEP_3RD_DIR}/usr/local/babassl-ob/include
|
||||
)
|
||||
endif()
|
||||
|
||||
if (OB_USE_CLANG)
|
||||
# The following clang warnings should be fixed later: -Wno-unused-variable -Wno-invalid-offsetof
|
||||
@ -114,6 +184,7 @@ endif()
|
||||
|
||||
target_compile_features(oblib_base_base INTERFACE cxx_std_11)
|
||||
|
||||
if(OB_BUILD_OPENSOURCE)
|
||||
set(LGPL_DEPS "-L${DEP_DIR}/lib/mariadb -lmariadb")
|
||||
if (OB_STATIC_LINK_LGPL_DEPS)
|
||||
set(LGPL_DEPS "-L${DEP_DIR}/lib/mariadb -l:libmariadbclient.a")
|
||||
@ -140,6 +211,30 @@ target_link_libraries(oblib_base_base_base
|
||||
-laio -lpthread -lcurl -ldl -lrt
|
||||
${ARCH_LDFLAGS}
|
||||
)
|
||||
else()
|
||||
set(ignoreMe OB_STATIC_LINK_LGPL_DEPS)
|
||||
target_link_libraries(oblib_base_base_base
|
||||
INTERFACE
|
||||
oss
|
||||
easy
|
||||
${DEP_DIR}/lib/libisal.a
|
||||
$<$<STREQUAL:"${ARCHITECTURE}","x86_64">:${DEP_DIR}/lib/libunwind.a>
|
||||
${DEP_3RD_DIR}/usr/local/babassl-ob/lib/libssl.a
|
||||
${DEP_3RD_DIR}/usr/local/babassl-ob/lib/libcrypto.a
|
||||
${DEP_3RD_DIR}/u01/obclient/lib/libobclnt.a
|
||||
${DEP_DIR}/lib/libs2.a
|
||||
${DEP_DIR}/lib/libz.a
|
||||
${DEP_DIR}/lib/libicui18n.a
|
||||
${DEP_DIR}/lib/libicustubdata.a
|
||||
${DEP_DIR}/lib/libicuuc.a
|
||||
-L${DEP_DIR}/var/usr/lib64
|
||||
-L${DEP_DIR}/var/usr/lib
|
||||
-L${DEP_3RD_DIR}/usr/lib
|
||||
-L${DEP_3RD_DIR}/usr/lib64
|
||||
-laio -lpthread -lcurl -ldl -lrt
|
||||
${ARCH_LDFLAGS}
|
||||
)
|
||||
endif()
|
||||
target_link_libraries(oblib_base_base INTERFACE oblib_base_base_base)
|
||||
|
||||
add_library(oblib_base INTERFACE)
|
||||
|
12
deps/oblib/src/lib/CMakeLists.txt
vendored
12
deps/oblib/src/lib/CMakeLists.txt
vendored
@ -194,7 +194,6 @@ ob_set_subtarget(oblib_lib oblog
|
||||
oblog/ob_syslog_rate_limiter.cpp
|
||||
)
|
||||
|
||||
|
||||
ob_set_subtarget(oblib_lib signal
|
||||
signal/ob_signal_handlers.cpp
|
||||
signal/ob_signal_processor.cpp
|
||||
@ -287,6 +286,17 @@ add_library(malloc_hook STATIC
|
||||
alloc/malloc_hook.h)
|
||||
target_link_libraries(malloc_hook oblib_base)
|
||||
|
||||
if(OB_BUILD_ORACLE_XML)
|
||||
target_link_libraries(oblib_lib
|
||||
PUBLIC ob_malloc compress restore
|
||||
${DEP_DIR}/lib/libxml2.a
|
||||
${DEP_DIR}/lib/liblzma.a
|
||||
${DEP_3RD_DIR}/usr/local/lib/libxslt.a
|
||||
${DEP_3RD_DIR}/usr/local/lib/libexslt.a
|
||||
${ob_close_deps_static_name}
|
||||
)
|
||||
else()
|
||||
target_link_libraries(oblib_lib
|
||||
PUBLIC ob_malloc
|
||||
)
|
||||
endif()
|
||||
|
3
deps/oblib/src/lib/allocator/ob_mod_define.h
vendored
3
deps/oblib/src/lib/allocator/ob_mod_define.h
vendored
@ -53,7 +53,6 @@ LABEL_ITEM_DEF(OB_FIFO_ALLOC, FifoAlloc)
|
||||
//commonmodules
|
||||
LABEL_ITEM_DEF(OB_OBJ_FREELISTS, ObjFreelists)
|
||||
LABEL_ITEM_DEF(OB_COMMON_NETWORK, CommonNetwork)
|
||||
LABEL_ITEM_DEF(OB_RDMA_MYSQL, MysqlRdmaNet)
|
||||
LABEL_ITEM_DEF(OB_THREAD_BUFFER, ThreadBuffer)
|
||||
LABEL_ITEM_DEF(OB_KVSTORE_CACHE, KvstoreCache)
|
||||
LABEL_ITEM_DEF(OB_KVSTORE_CACHE_ITERATOR, KvstorCacheIter)
|
||||
@ -677,7 +676,7 @@ struct InnerModIds
|
||||
#undef LABEL_ITEM_DEF
|
||||
};
|
||||
enum { LABEL_COUNT_LIMIT = InnerModIds::OB_MOD_END };
|
||||
STATIC_ASSERT(LABEL_COUNT_LIMIT == 453, "forbidden to add new label!!!");
|
||||
STATIC_ASSERT(LABEL_COUNT_LIMIT == 452, "forbidden to add new label!!!");
|
||||
};
|
||||
|
||||
#define ObNewModIds ObModIds
|
||||
|
306
deps/oblib/src/lib/charset/ob_charset.cpp
vendored
306
deps/oblib/src/lib/charset/ob_charset.cpp
vendored
@ -293,8 +293,14 @@ const ObCollationWrapper ObCharset::collation_wrap_arr_[ObCharset::VALID_COLLATI
|
||||
{CS_TYPE_GBK_BIN, CHARSET_GBK, CS_TYPE_GBK_BIN, false, true, 1},
|
||||
{CS_TYPE_UTF16_GENERAL_CI, CHARSET_UTF16, CS_TYPE_UTF16_GENERAL_CI, true, true, 1},
|
||||
{CS_TYPE_UTF16_BIN, CHARSET_UTF16, CS_TYPE_UTF16_BIN, false, true, 1},
|
||||
#ifndef OB_BUILD_FULL_CHARSET
|
||||
{CS_TYPE_INVALID, CHARSET_INVALID, CS_TYPE_INVALID, false, false, 1},
|
||||
{CS_TYPE_INVALID, CHARSET_INVALID, CS_TYPE_INVALID, false, false, 1},
|
||||
#else
|
||||
//{CS_TYPE_UTF8MB4_ZH_0900_AS_CS, CHARSET_UTF8MB4, CS_TYPE_UTF8MB4_ZH_0900_AS_CS, false, true, 0},
|
||||
{CS_TYPE_UTF8MB4_UNICODE_CI, CHARSET_UTF8MB4, CS_TYPE_UTF8MB4_UNICODE_CI, false, true, 1},
|
||||
{CS_TYPE_UTF16_UNICODE_CI, CHARSET_UTF16, CS_TYPE_UTF16_UNICODE_CI, false, true, 1},
|
||||
#endif
|
||||
{CS_TYPE_GB18030_CHINESE_CI, CHARSET_GB18030, CS_TYPE_GB18030_CHINESE_CI, true, true, 1},
|
||||
{CS_TYPE_GB18030_BIN, CHARSET_GB18030, CS_TYPE_GB18030_BIN, false, true, 1},
|
||||
{CS_TYPE_LATIN1_SWEDISH_CI, CHARSET_LATIN1, CS_TYPE_LATIN1_SWEDISH_CI,true, true, 1},
|
||||
@ -330,7 +336,11 @@ ObCharsetInfo *ObCharset::charset_arr[CS_TYPE_MAX] = {
|
||||
&ob_charset_gbk_bin, // 87
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 88
|
||||
NULL, NULL, NULL, NULL, NULL, // 96
|
||||
#ifdef OB_BUILD_FULL_CHARSET
|
||||
&ob_charset_utf16_unicode_ci, // 101
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
NULL, NULL, // 102
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 104
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 112
|
||||
@ -350,7 +360,11 @@ ObCharsetInfo *ObCharset::charset_arr[CS_TYPE_MAX] = {
|
||||
&ob_charset_gb18030_2022_pinyin_cs, &ob_charset_gb18030_2022_radical_ci,// 218
|
||||
&ob_charset_gb18030_2022_radical_cs, &ob_charset_gb18030_2022_stroke_ci, // 220
|
||||
&ob_charset_gb18030_2022_stroke_cs, NULL, // 222
|
||||
#ifdef OB_BUILD_FULL_CHARSET
|
||||
&ob_charset_utf8mb4_unicode_ci, // 224
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 225
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 232
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 240
|
||||
@ -494,6 +508,31 @@ uint64_t ObCharset::strntoullrnd(const char *str,
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef OB_BUILD_FULL_CHARSET
|
||||
/*
|
||||
Convert integer to its string representation in given scale of notation.
|
||||
|
||||
SYNOPSIS
|
||||
int2str()
|
||||
val - value to convert
|
||||
dst - points to buffer where string representation should be stored
|
||||
radix - radix of scale of notation
|
||||
upcase - set to 1 if we should use upper-case digits
|
||||
|
||||
DESCRIPTION
|
||||
Converts the (long) integer value to its character form and moves it to
|
||||
the destination buffer followed by a terminating NUL.
|
||||
If radix is -2..-36, val is taken to be SIGNED, if radix is 2..36, val is
|
||||
taken to be UNSIGNED. That is, val is signed if and only if radix is.
|
||||
All other radixes treated as bad and nothing will be changed in this case.
|
||||
|
||||
For conversion to decimal representation (radix is -10 or 10) one can use
|
||||
optimized int10_to_str() function.
|
||||
|
||||
RETURN VALUE
|
||||
Pointer to ending NUL character or NullS if radix is bad.
|
||||
*/
|
||||
#endif
|
||||
|
||||
//=============================================================
|
||||
char* ObCharset::lltostr(int64_t val, char *dst, int radix, int upcase)
|
||||
@ -1063,6 +1102,10 @@ int ObCharset::well_formed_len(ObCollationType collation_type, const char *str,
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef OB_BUILD_FULL_CHARSET
|
||||
// Be careful with this function. The return value may be out of range.
|
||||
// Refer to
|
||||
#endif
|
||||
size_t ObCharset::charpos(const ObCollationType collation_type,
|
||||
const char *str,
|
||||
const int64_t str_len,
|
||||
@ -1546,6 +1589,14 @@ ObCollationType ObCharset::collation_type(const ObString &cs_name)
|
||||
collation_type = CS_TYPE_UTF16_GENERAL_CI;
|
||||
} else if (0 == cs_name.case_compare(ob_charset_utf16_bin.name)) {
|
||||
collation_type = CS_TYPE_UTF16_BIN;
|
||||
#ifdef OB_BUILD_FULL_CHARSET
|
||||
} else if (0 == cs_name.case_compare("utf8_unicode_ci")) {
|
||||
collation_type = CS_TYPE_UTF8MB4_UNICODE_CI;
|
||||
} else if (0 == cs_name.case_compare(ob_charset_utf16_unicode_ci.name)) {
|
||||
collation_type = CS_TYPE_UTF16_UNICODE_CI;
|
||||
} else if (0 == cs_name.case_compare(ob_charset_utf8mb4_unicode_ci.name)) {
|
||||
collation_type = CS_TYPE_UTF8MB4_UNICODE_CI;
|
||||
#endif
|
||||
} else if (0 == cs_name.case_compare(ob_charset_gb18030_bin.name)) {
|
||||
collation_type = CS_TYPE_GB18030_BIN;
|
||||
} else if (0 == cs_name.case_compare(ob_charset_gb18030_chinese_ci.name)) {
|
||||
@ -1588,6 +1639,9 @@ bool ObCharset::is_valid_collation(ObCharsetType charset_type, ObCollationType c
|
||||
if (CHARSET_UTF8MB4 == charset_type) {
|
||||
if (CS_TYPE_UTF8MB4_BIN == collation_type
|
||||
|| CS_TYPE_UTF8MB4_GENERAL_CI == collation_type
|
||||
#ifdef OB_BUILD_FULL_CHARSET
|
||||
|| CS_TYPE_UTF8MB4_UNICODE_CI == collation_type
|
||||
#endif
|
||||
) {
|
||||
ret = true;
|
||||
}
|
||||
@ -1601,6 +1655,9 @@ bool ObCharset::is_valid_collation(ObCharsetType charset_type, ObCollationType c
|
||||
} else if (CHARSET_UTF16 == charset_type) {
|
||||
if (CS_TYPE_UTF16_GENERAL_CI == collation_type
|
||||
|| CS_TYPE_UTF16_BIN == collation_type
|
||||
#ifdef OB_BUILD_FULL_CHARSET
|
||||
|| CS_TYPE_UTF16_UNICODE_CI == collation_type
|
||||
#endif
|
||||
) {
|
||||
ret = true;
|
||||
}
|
||||
@ -1693,6 +1750,11 @@ bool ObCharset::is_valid_collation(int64_t collation_type_int)
|
||||
|| CS_TYPE_LATIN1_SWEDISH_CI == collation_type
|
||||
|| CS_TYPE_LATIN1_BIN == collation_type
|
||||
|| is_gb18030_2022(collation_type)
|
||||
#ifdef OB_BUILD_FULL_CHARSET
|
||||
|| CS_TYPE_UTF8MB4_UNICODE_CI == collation_type
|
||||
|| CS_TYPE_UTF16_UNICODE_CI == collation_type
|
||||
|| (CS_TYPE_EXTENDED_MARK < collation_type && collation_type < CS_TYPE_MAX)
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
@ -1913,6 +1975,57 @@ int ObCharset::result_collation(
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef OB_BUILD_FULL_CHARSET
|
||||
/** note from mysql:
|
||||
Aggregate two collations together taking
|
||||
into account their coercibility (aka derivation):.
|
||||
|
||||
0 == DERIVATION_EXPLICIT - an explicitly written COLLATE clause @n
|
||||
1 == DERIVATION_NONE - a mix of two different collations @n
|
||||
2 == DERIVATION_IMPLICIT - a column @n
|
||||
3 == DERIVATION_COERCIBLE - a string constant.
|
||||
|
||||
The most important rules are:
|
||||
-# If collations are the same:
|
||||
chose this collation, and the strongest derivation.
|
||||
-# If collations are different:
|
||||
- Character sets may differ, but only if conversion without
|
||||
data loss is possible. The caller provides flags whether
|
||||
character set conversion attempts should be done. If no
|
||||
flags are substituted, then the character sets must be the same.
|
||||
Currently processed flags are:
|
||||
MY_COLL_ALLOW_SUPERSET_CONV - allow conversion to a superset
|
||||
MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
|
||||
- two EXPLICIT collations produce an error, e.g. this is wrong:
|
||||
CONCAT(expr1 collate latin1_swedish_ci, expr2 collate latin1_german_ci)
|
||||
- the side with smaller derivation value wins,
|
||||
i.e. a column is stronger than a string constant,
|
||||
an explicit COLLATE clause is stronger than a column.
|
||||
- if derivations are the same, we have DERIVATION_NONE,
|
||||
we'll wait for an explicit COLLATE clause which possibly can
|
||||
come from another argument later: for example, this is valid,
|
||||
but we don't know yet when collecting the first two arguments:
|
||||
@code
|
||||
CONCAT(latin1_swedish_ci_column,
|
||||
latin1_german1_ci_column,
|
||||
expr COLLATE latin1_german2_ci)
|
||||
@endcode
|
||||
*/
|
||||
|
||||
/** this function is to determine use which charset when compare
|
||||
* We consider only three charsets(binary, gbk and utf8mb4), so the rule is simpler. Especially,
|
||||
* res_level can not be CS_LEVEL_NONE.
|
||||
*
|
||||
* MySQL uses coercibility values with the following rules to resolve ambiguities:
|
||||
* 1. Use the collation with the lowest coercibility value.
|
||||
* 2. If both sides have the same coercibility, then:
|
||||
* 2.a If both sides are Unicode, or both sides are not Unicode, it is an error.
|
||||
* 2.b If one of the sides has a Unicode character set, and another side has a non-Unicode character set, the side with Unicode character set wins,
|
||||
* and automatic character set conversion is applied to the non-Unicode side.
|
||||
* 2.c For an operation with operands from the same character set but that mix a _bin collation and a _ci or _cs collation, the _bin collation is used.
|
||||
* This is similar to how operations that mix nonbinary and binary strings evaluate the operands as binary strings, except that it is for collations rather than data types.
|
||||
*/
|
||||
#endif
|
||||
int ObCharset::aggregate_collation(
|
||||
const ObCollationLevel collation_level1,
|
||||
const ObCollationType collation_type1,
|
||||
@ -3080,6 +3193,7 @@ int ObCharset::get_nls_charset_id_by_charset_type(ObCharsetType charset_type)
|
||||
return static_cast<int>(ret_id);
|
||||
}
|
||||
|
||||
#ifndef OB_BUILD_FULL_CHARSET
|
||||
|
||||
int ObCharset::init_charset()
|
||||
{
|
||||
@ -3090,6 +3204,198 @@ int ObCharset::init_charset()
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void ob_charset_error_reporter(enum loglevel level, uint ecode, ...) {
|
||||
//UNUSED(level);
|
||||
UNUSED(ecode);
|
||||
switch (level) {
|
||||
case ERROR_LEVEL:
|
||||
LIB_LOG_RET(ERROR, OB_ERROR, "fail to init charset", K(ecode));
|
||||
break;
|
||||
case WARNING_LEVEL:
|
||||
LIB_LOG_RET(WARN, OB_ERROR, "fail to init charset", K(ecode));
|
||||
break;
|
||||
case INFORMATION_LEVEL:
|
||||
LIB_LOG(INFO, "fail to init charset", K(ecode));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define CHARSET_INIT_MEM_ATTR "CharsetInit"
|
||||
|
||||
static void *charset_malloc(size_t size) {
|
||||
return ob_malloc(size, CHARSET_INIT_MEM_ATTR);
|
||||
}
|
||||
|
||||
static void *charset_realloc(void *ptr, size_t size) {
|
||||
ObMemAttr attr;
|
||||
attr.label_ = CHARSET_INIT_MEM_ATTR;
|
||||
return ob_realloc(ptr, size, attr);
|
||||
}
|
||||
|
||||
static void charset_free(void *ptr) {
|
||||
return ob_free(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
Initialize character set loader to use mysys memory management functions.
|
||||
@param loader Loader to initialize
|
||||
*/
|
||||
void ob_charset_loader_init_mysys(ObCharsetLoader *loader)
|
||||
{
|
||||
loader->errcode = 0;
|
||||
loader->errarg[0] = '\0';
|
||||
loader->once_alloc = charset_malloc;
|
||||
loader->mem_malloc = charset_malloc;
|
||||
loader->mem_realloc = charset_realloc;
|
||||
loader->mem_free = charset_free;
|
||||
loader->reporter = ob_charset_error_reporter;
|
||||
loader->add_collation = NULL;
|
||||
}
|
||||
|
||||
int ObCharset::copy_zh_cs(ObCharsetInfo *from_cs, ObCollationType to_coll_type, ObCharsetInfo *&to_cs)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
to_cs = NULL;
|
||||
if (OB_ISNULL(to_cs = static_cast<ObCharsetInfo*>(charset_malloc(sizeof(ObCharsetInfo))))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("fail to alloc charset", K(ret));
|
||||
} else {
|
||||
ObCollationType bin_coll = get_default_collation_oracle(charset_type_by_coll(to_coll_type));
|
||||
if (!is_valid_collation(to_coll_type) || !is_valid_collation(bin_coll)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected bin coll", K(ret), K(to_coll_type), K(bin_coll));
|
||||
} else {
|
||||
*to_cs = *charset_arr[bin_coll];
|
||||
to_cs->uca = from_cs->uca;
|
||||
to_cs->tailoring = from_cs->tailoring;
|
||||
to_cs->coll_param = from_cs->coll_param;
|
||||
to_cs->levels_for_compare = 3;
|
||||
to_cs->coll = from_cs->coll;
|
||||
to_cs->pad_attribute = NO_PAD;
|
||||
//TODO
|
||||
//for now, the collations are used for nlssort and not exposed to user
|
||||
//the cs attributes are not all correct, such as names and number
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObCharset::init_charset()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(init_gb18030_2022())) {
|
||||
LOG_WARN("failed to init gb18030 2022", K(ret));
|
||||
}
|
||||
|
||||
auto add_coll = [&ret](ObCollationType coll_type, ObCharsetInfo *cs)->void {
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_ISNULL(cs) || !is_valid_collation(coll_type)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(cs), K(coll_type));
|
||||
} else {
|
||||
charset_arr[coll_type] = cs;
|
||||
cs->state |= OB_CS_COMPILED;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ObCharsetLoader loader;
|
||||
ob_charset_loader_init_mysys(&loader);
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
auto *utf8_pinyin = &ob_charset_utf8mb4_zh_0900_as_cs;
|
||||
ObCollationHandler *pinyin_coll = ob_charset_utf8mb4_zh_0900_as_cs.coll;
|
||||
|
||||
if (pinyin_coll->init(utf8_pinyin, &loader)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to init charset", K(ret));
|
||||
} else {
|
||||
ObCollationType pinyin_colls[] = {
|
||||
CS_TYPE_GBK_ZH_0900_AS_CS, CS_TYPE_UTF8MB4_ZH_0900_AS_CS,
|
||||
CS_TYPE_GB18030_ZH_0900_AS_CS, CS_TYPE_UTF16_ZH_0900_AS_CS,
|
||||
CS_TYPE_GB18030_2022_ZH_0900_AS_CS
|
||||
};
|
||||
add_coll(CS_TYPE_UTF8MB4_ZH_0900_AS_CS, utf8_pinyin);
|
||||
|
||||
for (int i = 0; OB_SUCC(ret) && i < array_elements(pinyin_colls); i++) {
|
||||
if (NULL == charset_arr[pinyin_colls[i]]) {
|
||||
ObCharsetInfo *new_cs = NULL;
|
||||
if (OB_FAIL(copy_zh_cs(utf8_pinyin, pinyin_colls[i], new_cs))) {
|
||||
LOG_WARN("fail to copy zh cs", K(ret));
|
||||
} else {
|
||||
add_coll(pinyin_colls[i], new_cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
auto *utf8_radical = &ob_charset_utf8mb4_zh2_0900_as_cs;
|
||||
ObCollationHandler *radical_coll = ob_charset_utf8mb4_zh2_0900_as_cs.coll;
|
||||
if (radical_coll->init(utf8_radical, &loader)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to init charset", K(ret));
|
||||
} else {
|
||||
ObCollationType radical_colls[] = {
|
||||
CS_TYPE_GBK_ZH2_0900_AS_CS, CS_TYPE_UTF8MB4_ZH2_0900_AS_CS,
|
||||
CS_TYPE_GB18030_ZH2_0900_AS_CS, CS_TYPE_UTF16_ZH2_0900_AS_CS,
|
||||
CS_TYPE_GB18030_2022_ZH2_0900_AS_CS
|
||||
};
|
||||
add_coll(CS_TYPE_UTF8MB4_ZH2_0900_AS_CS, utf8_radical);
|
||||
|
||||
for (int i = 0; OB_SUCC(ret) && i < array_elements(radical_colls); i++) {
|
||||
if (NULL == charset_arr[radical_colls[i]]) {
|
||||
ObCharsetInfo *new_cs = NULL;
|
||||
if (OB_FAIL(copy_zh_cs(utf8_radical, radical_colls[i], new_cs))) {
|
||||
LOG_WARN("fail to copy zh cs", K(ret));
|
||||
} else {
|
||||
add_coll(radical_colls[i], new_cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
auto *utf8_stroke = &ob_charset_utf8mb4_zh3_0900_as_cs;
|
||||
ObCollationHandler *stroke_coll = ob_charset_utf8mb4_zh3_0900_as_cs.coll;
|
||||
if (stroke_coll->init(utf8_stroke, &loader)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to init charset", K(ret));
|
||||
} else {
|
||||
ObCollationType stroke_colls[] = {
|
||||
CS_TYPE_GBK_ZH3_0900_AS_CS, CS_TYPE_UTF8MB4_ZH3_0900_AS_CS,
|
||||
CS_TYPE_GB18030_ZH3_0900_AS_CS, CS_TYPE_UTF16_ZH3_0900_AS_CS,
|
||||
CS_TYPE_GB18030_2022_ZH3_0900_AS_CS
|
||||
};
|
||||
add_coll(CS_TYPE_UTF8MB4_ZH3_0900_AS_CS, utf8_stroke);
|
||||
|
||||
for (int i = 0; OB_SUCC(ret) && i < array_elements(stroke_colls); i++) {
|
||||
if (NULL == charset_arr[stroke_colls[i]]) {
|
||||
ObCharsetInfo *new_cs = NULL;
|
||||
if (OB_FAIL(copy_zh_cs(utf8_stroke, stroke_colls[i], new_cs))) {
|
||||
LOG_WARN("fail to copy zh cs", K(ret));
|
||||
} else {
|
||||
add_coll(stroke_colls[i], new_cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//init utf8_0900_binary
|
||||
add_coll(CS_TYPE_UTF8MB4_0900_BIN, &ob_charset_utf8mb4_0900_bin);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ObString ObCharsetUtils::const_str_for_ascii_[CHARSET_MAX][INT8_MAX + 1];
|
||||
|
||||
|
110
deps/oblib/src/lib/charset/ob_ctype.h
vendored
110
deps/oblib/src/lib/charset/ob_ctype.h
vendored
@ -190,6 +190,79 @@ typedef struct ObUnicaseInfo
|
||||
const ObUnicaseInfoChar **page;
|
||||
} ObUnicaseInfo;
|
||||
|
||||
#ifdef OB_BUILD_FULL_CHARSET
|
||||
// OB_CHARSET_HANDLER
|
||||
// ==================
|
||||
|
||||
// OB_CHARSET_HANDLER is a collection of character-set
|
||||
// related routines. Defined in m_ctype.h. Have the
|
||||
// following set of functions:
|
||||
|
||||
// Multi-byte routines
|
||||
// ------------------
|
||||
// ismbchar() - detects whether the given string is a multi-byte sequence
|
||||
// mbcharlen() - returns length of multi-byte sequence starting with
|
||||
// the given character
|
||||
// numchars() - returns number of characters in the given string, e.g.
|
||||
// in SQL function CHAR_LENGTH().
|
||||
// charpos() - calculates the offset of the given position in the string.
|
||||
// Used in SQL functions LEFT(), RIGHT(), SUBSTRING(),
|
||||
// INSERT()
|
||||
|
||||
// well_formed_len()
|
||||
// - returns length of a given multi-byte string in bytes
|
||||
// Used in INSERTs to shorten the given string so it
|
||||
// a) is "well formed" according to the given character set
|
||||
// b) can fit into the given data type
|
||||
|
||||
// lengthsp() - returns the length of the given string without trailing spaces.
|
||||
|
||||
|
||||
// Unicode conversion routines
|
||||
// ---------------------------
|
||||
// mb_wc - converts the left multi-byte sequence into its Unicode code.
|
||||
// mc_mb - converts the given Unicode code into multi-byte sequence.
|
||||
|
||||
|
||||
// Case and sort conversion
|
||||
// ------------------------
|
||||
// caseup_str - converts the given 0-terminated string to uppercase
|
||||
// casedn_str - converts the given 0-terminated string to lowercase
|
||||
// caseup - converts the given string to lowercase using length
|
||||
// casedn - converts the given string to lowercase using length
|
||||
|
||||
// Number-to-string conversion routines
|
||||
// ------------------------------------
|
||||
// snprintf()
|
||||
// long10_to_str()
|
||||
// longlong10_to_str()
|
||||
|
||||
// The names are pretty self-describing.
|
||||
|
||||
// String padding routines
|
||||
// -----------------------
|
||||
// fill() - writes the given Unicode value into the given string
|
||||
// with the given length. Used to pad the string, usually
|
||||
// with space character, according to the given charset.
|
||||
|
||||
// String-to-number conversion routines
|
||||
// ------------------------------------
|
||||
// strntol()
|
||||
// strntoul()
|
||||
// strntoll()
|
||||
// strntoull()
|
||||
// strntod()
|
||||
|
||||
// These functions are almost the same as their STDLIB counterparts,
|
||||
// but also:
|
||||
// - accept length instead of 0-terminator
|
||||
// - are character set dependent
|
||||
|
||||
// Simple scanner routines
|
||||
// -----------------------
|
||||
// scan() - to skip leading spaces in the given string.
|
||||
// Used when a string value is inserted into a numeric field.
|
||||
#endif
|
||||
typedef struct ObCharsetHandler
|
||||
{
|
||||
//my_bool (*init)(struct ObCharsetInfo *, MY_CHARSET_LOADER *loader);
|
||||
@ -257,8 +330,22 @@ typedef struct ObCharsetHandler
|
||||
size_t (*scan)(const struct ObCharsetInfo *, const char *b,
|
||||
const char *e, int sq);
|
||||
} ObCharsetHandler;
|
||||
|
||||
|
||||
#ifdef OB_BUILD_FULL_CHARSET
|
||||
// OB_COLLATION_HANDLER
|
||||
// ====================
|
||||
// strnncoll() - compares two strings according to the given collation
|
||||
// strnncollsp() - like the above but ignores trailing spaces for PAD SPACE
|
||||
// collations. For NO PAD collations, identical to strnncoll.
|
||||
// strnxfrm() - makes a sort key suitable for memcmp() corresponding
|
||||
// to the given string
|
||||
// like_range() - creates a LIKE range, for optimizer
|
||||
// wildcmp() - wildcard comparison, for LIKE
|
||||
// strcasecmp() - 0-terminated string comparison
|
||||
// instr() - finds the first substring appearance in the string
|
||||
// hash_sort() - calculates hash value taking into account
|
||||
// the collation rules, e.g. case-insensitivity,
|
||||
// accent sensitivity, etc.
|
||||
#endif
|
||||
static const int HASH_BUFFER_LENGTH = 128;
|
||||
|
||||
typedef uint64_t (*hash_algo)(const void* input, uint64_t length, uint64_t seed);
|
||||
@ -353,8 +440,15 @@ struct ObCharsetInfo
|
||||
|
||||
ObCharsetHandler *cset;
|
||||
ObCollationHandler *coll;
|
||||
#ifdef OB_BUILD_FULL_CHARSET
|
||||
/**
|
||||
If this collation is PAD_SPACE, it collates as if all inputs were
|
||||
padded with a given number of spaces at the end (see the "num_codepoints"
|
||||
flag to strnxfrm). NO_PAD simply compares unextended strings.
|
||||
|
||||
|
||||
Note that this is fundamentally about the behavior of coll->strnxfrm.
|
||||
*/
|
||||
#endif
|
||||
enum ObCharsetPadAttr pad_attribute;
|
||||
};
|
||||
|
||||
@ -438,6 +532,16 @@ extern ObCharsetInfo ob_charset_gb18030_2022_radical_cs;
|
||||
extern ObCharsetInfo ob_charset_gb18030_2022_stroke_ci;
|
||||
extern ObCharsetInfo ob_charset_gb18030_2022_stroke_cs;
|
||||
extern ObCharsetInfo ob_charset_gb18030_2022_bin;
|
||||
#ifdef OB_BUILD_FULL_CHARSET
|
||||
extern ObCharsetInfo ob_charset_utf8mb4_unicode_ci;
|
||||
extern ObCharsetInfo ob_charset_utf16_unicode_ci;
|
||||
extern ObCharsetInfo ob_charset_utf8mb4_zh_0900_as_cs;
|
||||
extern ObCharsetInfo ob_charset_utf8mb4_zh2_0900_as_cs;
|
||||
extern ObCharsetInfo ob_charset_utf8mb4_zh3_0900_as_cs;
|
||||
extern ObCharsetInfo ob_charset_utf8mb4_0900_bin;
|
||||
extern ObCharsetInfo ob_charset_latin1;
|
||||
extern ObCharsetInfo ob_charset_latin1_bin;
|
||||
#endif
|
||||
|
||||
extern ObCollationHandler ob_collation_mb_bin_handler;
|
||||
extern ObCharsetHandler ob_charset_utf8mb4_handler;
|
||||
|
@ -18,6 +18,7 @@
|
||||
* - initial release
|
||||
*
|
||||
*/
|
||||
#ifndef OB_BUILD_FULL_CHARSET
|
||||
|
||||
#include "lib/charset/ob_ctype.h"
|
||||
|
||||
@ -522,3 +523,5 @@ ObCharsetInfo ob_charset_bin =
|
||||
|
||||
#undef likeconv
|
||||
#undef INC_PTR
|
||||
|
||||
#endif
|
@ -15,6 +15,7 @@
|
||||
*
|
||||
* Authors:
|
||||
*/
|
||||
#ifndef OB_BUILD_FULL_CHARSET
|
||||
|
||||
#include "lib/charset/ob_ctype.h"
|
||||
#include "lib/charset/ob_charset.h"
|
||||
@ -20760,4 +20761,6 @@ ObCharsetInfo ob_charset_gb18030_2022_stroke_cs =
|
||||
&ob_charset_gb18030_2022_handler,
|
||||
&ob_collation_2022_stroke_cs_handler,
|
||||
PAD_SPACE
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -15,6 +15,7 @@
|
||||
*
|
||||
* Authors:
|
||||
*/
|
||||
#ifndef OB_BUILD_FULL_CHARSET
|
||||
|
||||
#include "lib/charset/ob_ctype.h"
|
||||
|
||||
@ -10940,3 +10941,4 @@ ObCharsetInfo ob_charset_gbk_bin=
|
||||
PAD_SPACE
|
||||
};
|
||||
|
||||
#endif
|
@ -18,6 +18,8 @@
|
||||
* - initial release
|
||||
*
|
||||
*/
|
||||
#ifndef OB_BUILD_FULL_CHARSET
|
||||
|
||||
#include "lib/charset/ob_mysql_global.h"
|
||||
#include "lib/charset/ob_ctype.h"
|
||||
#include "lib/utility/ob_macro_utils.h"
|
||||
@ -406,3 +408,6 @@ ObCharsetInfo ob_charset_latin1_bin = {
|
||||
&ob_charset_latin1_handler,
|
||||
&ob_collation_8bit_bin_handler,
|
||||
PAD_SPACE};
|
||||
|
||||
|
||||
#endif
|
3
deps/oblib/src/lib/charset/ob_ctype_mb_os.cc
vendored
3
deps/oblib/src/lib/charset/ob_ctype_mb_os.cc
vendored
@ -15,6 +15,7 @@
|
||||
*
|
||||
* Authors:
|
||||
*/
|
||||
#ifndef OB_BUILD_FULL_CHARSET
|
||||
|
||||
#include "lib/charset/ob_ctype.h"
|
||||
|
||||
@ -769,3 +770,5 @@ ObCollationHandler ob_collation_mb_bin_handler = {
|
||||
|
||||
#undef INC_PTR
|
||||
#undef likeconv
|
||||
|
||||
#endif
|
3
deps/oblib/src/lib/charset/ob_ctype_os.cc
vendored
3
deps/oblib/src/lib/charset/ob_ctype_os.cc
vendored
@ -15,6 +15,7 @@
|
||||
*
|
||||
* Authors:
|
||||
*/
|
||||
#ifndef OB_BUILD_FULL_CHARSET
|
||||
|
||||
#include "lib/charset/ob_ctype.h"
|
||||
|
||||
@ -120,3 +121,5 @@ ob_convert(char *to, uint32 to_length, const ObCharsetInfo *to_cs,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
@ -18,6 +18,7 @@
|
||||
* - initial release
|
||||
*
|
||||
*/
|
||||
#ifndef OB_BUILD_FULL_CHARSET
|
||||
|
||||
#include "lib/charset/ob_ctype.h"
|
||||
#include "lib/charset/ob_dtoa.h"
|
||||
@ -1097,4 +1098,6 @@ ObCollationHandler ob_collation_8bit_simple_ci_handler = {
|
||||
ob_propagate_simple};
|
||||
|
||||
#undef likeconv
|
||||
#undef INC_PTR
|
||||
#undef INC_PTR
|
||||
|
||||
#endif
|
@ -15,6 +15,7 @@
|
||||
*
|
||||
* Authors:
|
||||
*/
|
||||
#ifndef OB_BUILD_FULL_CHARSET
|
||||
|
||||
#include "lib/charset/ob_ctype.h"
|
||||
#include "lib/charset/ob_dtoa.h"
|
||||
@ -1253,3 +1254,5 @@ ObCharsetInfo ob_charset_utf16_general_ci=
|
||||
&ob_collation_utf16_general_ci_handler,
|
||||
PAD_SPACE
|
||||
};
|
||||
|
||||
#endif
|
@ -18,6 +18,7 @@
|
||||
* - initial release
|
||||
*
|
||||
*/
|
||||
#ifndef OB_BUILD_FULL_CHARSET
|
||||
|
||||
#include "lib/charset/ob_ctype.h"
|
||||
#include "lib/charset/ob_dtoa.h"
|
||||
@ -2579,3 +2580,5 @@ ObCharsetInfo ob_charset_utf8mb4_bin=
|
||||
PAD_SPACE
|
||||
};
|
||||
|
||||
|
||||
#endif
|
3
deps/oblib/src/lib/charset/ob_dtoa_os.cc
vendored
3
deps/oblib/src/lib/charset/ob_dtoa_os.cc
vendored
@ -19,6 +19,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef OB_BUILD_FULL_CHARSET
|
||||
|
||||
#include "lib/charset/ob_dtoa.h"
|
||||
#include "lib/charset/ob_mysql_global.h"
|
||||
@ -2486,3 +2487,5 @@ ret1:
|
||||
}
|
||||
|
||||
#undef P
|
||||
|
||||
#endif
|
@ -134,6 +134,9 @@ int ObMySQLConnection::connect(const char *user, const char *pass, const char *d
|
||||
LOG_INFO("connecting to mysql server", "ip", host, "port", addr.get_port());
|
||||
mysql_init(&mysql_);
|
||||
timeout_ = timeout;
|
||||
#ifdef OB_BUILD_TDE_SECURITY
|
||||
int64_t ssl_enforce = 1;
|
||||
#endif
|
||||
mysql_options(&mysql_, MYSQL_OPT_CONNECT_TIMEOUT, &timeout_);
|
||||
if (read_write_no_timeout) {
|
||||
int64_t zero_second = 0;
|
||||
@ -157,6 +160,9 @@ int ObMySQLConnection::connect(const char *user, const char *pass, const char *d
|
||||
default:
|
||||
mysql_options4(&mysql_, MYSQL_OPT_CONNECT_ATTR_ADD, OB_SQL_REQUEST_LEVEL, OB_SQL_REQUEST_LEVEL0);
|
||||
}
|
||||
#ifdef OB_BUILD_TDE_SECURITY
|
||||
mysql_options(&mysql_, MYSQL_OPT_SSL_ENFORCE, &ssl_enforce);
|
||||
#endif
|
||||
int32_t port = addr.get_port();
|
||||
MYSQL *mysql = mysql_real_connect(&mysql_, host, user, pass, db, port, NULL, 0);
|
||||
if (OB_ISNULL(mysql)) {
|
||||
@ -204,6 +210,12 @@ int ObMySQLConnection::connect(const char *user, const char *pass, const char *d
|
||||
close();
|
||||
LOG_INFO("connecting to mysql server", "ip", host, "port", root_->get_server().get_port());
|
||||
mysql_init(&mysql_);
|
||||
#ifdef OB_BUILD_TDE_SECURITY
|
||||
int64_t ssl_enforce = 1;
|
||||
if (! use_ssl) {
|
||||
ssl_enforce = 0;
|
||||
}
|
||||
#endif
|
||||
mysql_options(&mysql_, MYSQL_OPT_CONNECT_TIMEOUT, &timeout_);
|
||||
if (read_write_no_timeout) {
|
||||
int64_t zero_second = 0;
|
||||
@ -227,6 +239,9 @@ int ObMySQLConnection::connect(const char *user, const char *pass, const char *d
|
||||
default:
|
||||
mysql_options4(&mysql_, MYSQL_OPT_CONNECT_ATTR_ADD, OB_SQL_REQUEST_LEVEL, OB_SQL_REQUEST_LEVEL0);
|
||||
}
|
||||
#ifdef OB_BUILD_TDE_SECURITY
|
||||
mysql_options(&mysql_, MYSQL_OPT_SSL_ENFORCE, &ssl_enforce);
|
||||
#endif
|
||||
int32_t port = root_->get_server().get_port();
|
||||
MYSQL *mysql = mysql_real_connect(&mysql_, host, user, pass, db, port, NULL, 0);
|
||||
if (OB_ISNULL(mysql)) {
|
||||
|
@ -22,6 +22,9 @@
|
||||
#include "lib/mysqlclient/ob_mysql_connection.h"
|
||||
#include "lib/net/ob_addr.h"
|
||||
#include "lib/mysqlclient/ob_isql_connection_pool.h"
|
||||
#ifdef OB_BUILD_DBLINK
|
||||
#include "lib/oracleclient/ob_oracle_oci_connection.h"
|
||||
#endif
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -253,12 +256,18 @@ public:
|
||||
inline void set_link_type(DblinkDriverProto link_type) { link_type_= link_type; }
|
||||
DblinkDriverProto &get_link_type() { return link_type_; }
|
||||
ObMySQLConnectionPool &get_mysql_pool() { return mysql_pool_; }
|
||||
#ifdef OB_BUILD_DBLINK
|
||||
ObOciConnectionPool &get_oci_pool() { return oci_pool_; }
|
||||
#endif
|
||||
inline void stop() {}
|
||||
|
||||
private:
|
||||
// ObISQLConnectionPool &get_pool_from_type(DblinkDriverProto &link_type);
|
||||
// ObDbLinkMySQLConnectionPool mysql_pool_;
|
||||
ObMySQLConnectionPool mysql_pool_;
|
||||
#ifdef OB_BUILD_DBLINK
|
||||
ObOciConnectionPool oci_pool_;
|
||||
#endif
|
||||
DblinkDriverProto link_type_;
|
||||
};
|
||||
|
||||
|
@ -18,6 +18,9 @@
|
||||
#include "lib/mysqlclient/ob_isql_connection_pool.h"
|
||||
#include "lib/mysqlclient/ob_mysql_proxy.h"
|
||||
#include "common/sql_mode/ob_sql_mode_utils.h"
|
||||
#ifdef OB_BUILD_DBLINK
|
||||
#include "lib/oracleclient/ob_oci_environment.h"
|
||||
#endif
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::common::sqlclient;
|
||||
|
||||
@ -411,6 +414,11 @@ int ObDbLinkProxy::switch_dblink_conn_pool(DblinkDriverProto type, ObISQLConnect
|
||||
case DBLINK_DRV_OB:
|
||||
dblink_conn_pool = static_cast<ObISQLConnectionPool *>(&(link_pool_->get_mysql_pool()));
|
||||
break;
|
||||
#ifdef OB_BUILD_DBLINK
|
||||
case DBLINK_DRV_OCI :
|
||||
dblink_conn_pool = static_cast<ObISQLConnectionPool *>(&(link_pool_->get_oci_pool()));
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unknown dblink type", K(ret), K(type));
|
||||
@ -534,6 +542,32 @@ int ObDbLinkProxy::execute_init_sql(const sqlclient::dblink_param_ctx ¶m_ctx
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef OB_BUILD_DBLINK
|
||||
else if (DBLINK_DRV_OCI == param_ctx.link_type_) {
|
||||
static sql_ptr_type sql_ptr_ora[] = {
|
||||
"alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS'",
|
||||
"alter session set nls_timestamp_format = 'YYYY-MM-DD HH24:MI:SS.FF'",
|
||||
"alter session set nls_timestamp_tz_format = 'YYYY-MM-DD HH24:MI:SS.FF TZR TZD'"
|
||||
};
|
||||
// oracle init
|
||||
OciStatement stmt;
|
||||
ObOciConnection *conn = static_cast<ObOciConnection *>(dblink_conn);
|
||||
if (OB_ISNULL(conn)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("null oci connection", K(ret));
|
||||
}
|
||||
int64_t affected_rows = 0; //no use
|
||||
for (int i = 0; OB_SUCC(ret) && i < sizeof(sql_ptr_ora) / sizeof(sql_ptr_type); ++i) {
|
||||
if (OB_FAIL(stmt.init_stmt(conn->get_oci_connection()))) {
|
||||
LOG_WARN("init oci statement failed", K(ret), K(param_ctx));
|
||||
} else if (OB_FAIL(stmt.set_sql_text(ObString(sql_ptr_ora[i])))) {
|
||||
LOG_WARN("failed to set sql text", K(ret), K(ObString(sql_ptr_ora[i])));
|
||||
} else if (OB_FAIL(stmt.execute_update(affected_rows))) {
|
||||
LOG_WARN("execute sql failed", K(ret), K(param_ctx));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -603,6 +637,15 @@ int ObDbLinkProxy::clean_dblink_connection(uint64_t tenant_id)
|
||||
if (OB_FAIL(link_pool_->get_mysql_pool().clean_dblink_connection(tenant_id))) {
|
||||
LOG_WARN("clean mysql pool failed", K(ret));
|
||||
}
|
||||
#ifdef OB_BUILD_DBLINK
|
||||
int tmp_ret = ret;
|
||||
if (OB_FAIL(link_pool_->get_oci_pool().clean_dblink_connection(tenant_id))) {
|
||||
LOG_WARN("clean oci pool failed", K(ret));
|
||||
}
|
||||
if (OB_SUCC(ret) && OB_UNLIKELY(OB_SUCCESS != tmp_ret)) {
|
||||
ret = tmp_ret;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,9 @@
|
||||
#include "lib/mysqlclient/ob_mysql_result.h"
|
||||
#include "lib/mysqlclient/ob_mysql_statement.h"
|
||||
#include "lib/mysqlclient/ob_mysql_connection_pool.h"
|
||||
#ifdef OB_BUILD_DBLINK
|
||||
#include "lib/oracleclient/ob_oracle_oci_connection.h"
|
||||
#endif
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
|
@ -815,6 +815,35 @@ int ObMySQLResultImpl::get_col_meta(const int64_t col_idx, bool old_max_length,
|
||||
ObDataType &data_type) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
#ifdef OB_BUILD_DBLINK
|
||||
ObObjType ob_type;
|
||||
if (OB_ISNULL(fields_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("check fields_ failed", K(ret));
|
||||
} else if (col_idx < 0 || col_idx >= result_column_count_) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid column idx", K(col_idx), K_(result_column_count));
|
||||
} else if (OB_FAIL(get_ob_type(ob_type, static_cast<obmysql::EMySQLFieldType>(fields_[col_idx].type),
|
||||
fields_[col_idx].flags & UNSIGNED_FLAG))) {
|
||||
LOG_WARN("failed to get ob type", K(ret), "mysql_type", fields_[col_idx].type);
|
||||
} else {
|
||||
int16_t precision = fields_[col_idx].precision;
|
||||
int16_t scale = fields_[col_idx].decimals;
|
||||
int32_t length = fields_[col_idx].length;
|
||||
name.assign_ptr(fields_[col_idx].name, STRLEN(fields_[col_idx].name));
|
||||
data_type.meta_.set_type(ob_type);
|
||||
data_type.meta_.set_collation_type(static_cast<ObCollationType>(fields_[col_idx].charsetnr));
|
||||
//data_type.meta_.set_autoincrement(fields_[col_idx].flags & AUTO_INCREMENT_FLAG);
|
||||
data_type.set_zero_fill(fields_[col_idx].flags & ZEROFILL_FLAG);
|
||||
format_precision_scale_length(precision, scale, length,
|
||||
ob_type, data_type.meta_.get_collation_type(),
|
||||
DBLINK_DRV_OB, old_max_length);
|
||||
data_type.set_precision(precision);
|
||||
data_type.set_scale(scale);
|
||||
data_type.set_length(length);
|
||||
LOG_DEBUG("get col type from obclient", K(ob_type), K(data_type), K(ret));
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -6,12 +6,14 @@ namespace common
|
||||
{
|
||||
namespace sqlclient
|
||||
{
|
||||
#ifndef OB_BUILD_DBLINK
|
||||
class ObTenantOciEnvs
|
||||
{
|
||||
public:
|
||||
static int mtl_init(ObTenantOciEnvs *&tenant_oci_envs) { return OB_SUCCESS; }
|
||||
static void mtl_destroy(ObTenantOciEnvs *&tenant_oci_envs) { }
|
||||
};
|
||||
#endif
|
||||
|
||||
} //sqlclient
|
||||
} // namespace common
|
||||
|
5
deps/oblib/src/lib/ob_name_def.h
vendored
5
deps/oblib/src/lib/ob_name_def.h
vendored
@ -844,6 +844,11 @@
|
||||
#define N_DES_ENCRYPT "des_encrypt"
|
||||
#define N_ENCRYPT "encrypt"
|
||||
|
||||
//*********** for spm
|
||||
#define N_SPM_LOAD_PLANS_FROM_PLAN_CACHE "spm_load_plans_from_plan_cache"
|
||||
#define N_SPM_ALTER_BASELINE "spm_alter_baseline"
|
||||
#define N_SPM_DROP_BASELINE "spm_drop_baseline"
|
||||
//*********** for spm end
|
||||
|
||||
#define N_UID "uid"
|
||||
#define N_PL_INTEGER_CHECKER "pl_integer_checker"
|
||||
|
37
deps/oblib/src/lib/oblog/ob_log.cpp
vendored
37
deps/oblib/src/lib/oblog/ob_log.cpp
vendored
@ -1692,6 +1692,43 @@ int64_t ObLogger::get_wait_us(const int32_t level)
|
||||
return ret_timeout_us;
|
||||
}
|
||||
|
||||
#ifdef OB_BUILD_AUDIT_SECURITY
|
||||
int ObLogger::async_audit_dump(const common::ObBasebLogPrint &info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_LIKELY(is_async_log_used())
|
||||
&& OB_LIKELY(info.get_data_length() > 0)) {
|
||||
const int32_t level = OB_LOG_LEVEL_INFO;
|
||||
ObPLogItem *log_item = NULL;
|
||||
set_disable_logging(true);
|
||||
//1. fill log buffer
|
||||
if (OB_FAIL(alloc_log_item(level, MAX_LOG_SIZE, log_item))) {
|
||||
LOG_STDERR("alloc_log_item error, ret=%d\n", ret);
|
||||
} else if (OB_ISNULL(log_item)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
} else {
|
||||
int64_t pos = log_item->get_data_len();
|
||||
log_item->set_timestamp(info.get_timestamp());
|
||||
log_item->set_fd_type(FD_AUDIT_FILE);
|
||||
if (OB_FAIL(info.print_data(log_item->get_buf(), log_item->get_buf_size(), pos))) {
|
||||
LOG_STDERR("print_data error ret = %d\n", ret);
|
||||
} else if (FALSE_IT(check_log_end(*log_item, pos))) {
|
||||
} else if (OB_FAIL(append_log(*log_item))) {
|
||||
LOG_STDERR("append_log error ret = %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
//3. stat
|
||||
if (OB_FAIL(ret)) {
|
||||
inc_dropped_log_count(level);
|
||||
free_log_item(log_item);
|
||||
log_item = NULL;
|
||||
}
|
||||
set_disable_logging(false);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int ObLogger::alloc_log_item(const int32_t level, const int64_t size, ObPLogItem *&log_item)
|
||||
{
|
||||
|
3
deps/oblib/src/lib/oblog/ob_log.h
vendored
3
deps/oblib/src/lib/oblog/ob_log.h
vendored
@ -510,6 +510,9 @@ public:
|
||||
}
|
||||
|
||||
|
||||
#ifdef OB_BUILD_AUDIT_SECURITY
|
||||
int async_audit_dump(const common::ObBasebLogPrint &info);
|
||||
#endif
|
||||
|
||||
//@brief Check whether the level to print.
|
||||
bool __attribute__((weak, noinline, cold)) need_to_print(const int32_t level) { return (level <= get_log_level()); }
|
||||
|
7
deps/oblib/src/lib/oblog/ob_log_module.h
vendored
7
deps/oblib/src/lib/oblog/ob_log_module.h
vendored
@ -67,7 +67,6 @@ DEFINE_LOG_SUB_MOD(EASY) // libeasy
|
||||
DEFINE_LOG_SUB_MOD(DETECT) // dead lock
|
||||
DEFINE_LOG_SUB_MOD(PALF) // palf
|
||||
DEFINE_LOG_SUB_MOD(STANDBY) // primary and standby cluster
|
||||
DEFINE_LOG_SUB_MOD(REASY) // libreasy
|
||||
DEFINE_LOG_SUB_MOD(COORDINATOR) // leader coordinator
|
||||
DEFINE_LOG_SUB_MOD(FLT) // trace
|
||||
DEFINE_LOG_SUB_MOD(OBTRACE) // trace
|
||||
@ -186,6 +185,7 @@ DEFINE_LOG_SUB_MOD(CG) // code_generator
|
||||
DEFINE_LOG_SUB_MOD(MONITOR) // monitor
|
||||
DEFINE_LOG_SUB_MOD(DTL) // data transfer layer
|
||||
DEFINE_LOG_SUB_MOD(DAS) // data access service
|
||||
DEFINE_LOG_SUB_MOD(SPM) // sql plan baseline
|
||||
DEFINE_LOG_SUB_MOD(QRR) // query rewrite rule
|
||||
LOG_MOD_END(SQL)
|
||||
|
||||
@ -784,11 +784,14 @@ LOG_MOD_END(PL)
|
||||
info_string, ##args)
|
||||
#define _SQL_DAS_LOG(level, _fmt_, args...) _OB_SUB_MOD_LOG(SQL, DAS, level, \
|
||||
_fmt_, ##args)
|
||||
#define SQL_SPM_LOG(level, info_string, args...) OB_SUB_MOD_LOG(SQL, SPM, level, \
|
||||
info_string, ##args)
|
||||
#define _SQL_SPM_LOG(level, _fmt_, args...) _OB_SUB_MOD_LOG(SQL, SPM, level, \
|
||||
_fmt_, ##args)
|
||||
#define SQL_QRR_LOG(level, info_string, args...) OB_SUB_MOD_LOG(SQL, QRR, level, \
|
||||
info_string, ##args)
|
||||
#define _SQL_QRR_LOG(level, _fmt_, args...) _OB_SUB_MOD_LOG(SQL, QRR, level, \
|
||||
_fmt_, ##args)
|
||||
|
||||
#define DETECT_LOG_LOG(level, info_string, args...) OB_SUB_MOD_LOG(DETECT, LOG,level, \
|
||||
info_string, ##args)
|
||||
#define _DETECT_LOG_LOG(level, _fmt_, args...) _OB_SUB_MOD_LOG(DETECT, LOG,level, \
|
||||
|
64
deps/oblib/src/lib/ssl/ob_ssl_config.cpp
vendored
64
deps/oblib/src/lib/ssl/ob_ssl_config.cpp
vendored
@ -208,6 +208,44 @@ static int ob_ssl_set_verify_mode_and_load_CA(SSL_CTX* ctx, const ObSSLConfig& s
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef OB_USE_BABASSL
|
||||
static int ob_ssl_load_cert_and_pkey_for_sm_memory(SSL_CTX* ctx, const ObSSLConfig& ssl_config)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
X509 *x509 = NULL;
|
||||
if (NULL == (pkey = ob_ssl_get_sm_pkey_memory(ssl_config.sign_private_key_))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
COMMON_LOG(WARN, "ob_ssl_get_sm_pkey_memory failed", K(ssl_config.sign_private_key_), K(ret));
|
||||
} else if (!SSL_CTX_use_sign_PrivateKey(ctx, pkey)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
EVP_PKEY_free(pkey);
|
||||
COMMON_LOG(WARN, "SSL_CTX_use_sign_PrivateKey failed", K(ssl_config.sign_private_key_), K(ret), K(ERR_error_string(ERR_get_error(), NULL)));
|
||||
} else if (NULL == (x509 = ob_ssl_get_sm_cert_memory(ssl_config.sign_cert_))){
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
COMMON_LOG(WARN, "ob_ssl_get_sm_cert_memory failed", K(ssl_config.sign_cert_), K(ret));
|
||||
} else if (!SSL_CTX_use_sign_certificate(ctx, x509)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
X509_free(x509);
|
||||
COMMON_LOG(WARN, "SSL_CTX_use_sign_certificate failed", K(ssl_config.sign_cert_), K(ret), K(ERR_error_string(ERR_get_error(), NULL)));
|
||||
} else if (NULL == (pkey = ob_ssl_get_sm_pkey_memory(ssl_config.enc_private_key_))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
COMMON_LOG(WARN, "ob_ssl_get_sm_pkey_memory failed", K(ssl_config.enc_private_key_), K(ret));
|
||||
} else if (!SSL_CTX_use_enc_PrivateKey(ctx, pkey)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
EVP_PKEY_free(pkey);
|
||||
COMMON_LOG(WARN, "SSL_CTX_use_enc_PrivateKey failed", K(ssl_config.enc_private_key_), K(ret), K(ERR_error_string(ERR_get_error(), NULL)));
|
||||
} else if (NULL == (x509 = ob_ssl_get_sm_cert_memory(ssl_config.enc_cert_))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
COMMON_LOG(WARN, "ob_ssl_get_sm_cert_memory failed", K(ssl_config.enc_cert_), K(ret));
|
||||
} else if (!SSL_CTX_use_enc_certificate(ctx, x509)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
X509_free(x509);
|
||||
COMMON_LOG(WARN, "SSL_CTX_use_enc_certificate failed", K(ssl_config.enc_cert_), K(ret), K(ERR_error_string(ERR_get_error(), NULL)));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int ob_ssl_load_cert_and_pkey_for_intl_memory(SSL_CTX* ctx, const ObSSLConfig& ssl_config)
|
||||
{
|
||||
@ -280,6 +318,21 @@ static int ob_ssl_load_cert_and_pkey(SSL_CTX* ctx, const ObSSLConfig& ssl_config
|
||||
int ret = OB_SUCCESS;
|
||||
if (ssl_config.is_from_file_) {
|
||||
if (ssl_config.is_sm_) {
|
||||
#ifdef OB_USE_BABASSL
|
||||
if (!SSL_CTX_use_sign_PrivateKey_file(ctx, ssl_config.sign_private_key_, SSL_FILETYPE_PEM)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
COMMON_LOG(WARN, "SSL_CTX_use_sign_PrivateKey_file failed", K(ssl_config.sign_private_key_), K(ret));
|
||||
} else if (!SSL_CTX_use_sign_certificate_file(ctx, ssl_config.sign_cert_, SSL_FILETYPE_PEM)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
COMMON_LOG(WARN, "SSL_CTX_use_sign_certificate_file failed", K(ssl_config.sign_cert_), K(ret));
|
||||
} else if (!SSL_CTX_use_enc_PrivateKey_file(ctx, ssl_config.enc_private_key_, SSL_FILETYPE_PEM)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
COMMON_LOG(WARN, "SSL_CTX_use_enc_PrivateKey_file failed", K(ssl_config.enc_private_key_), K(ret));
|
||||
} else if (!SSL_CTX_use_enc_certificate_file(ctx, ssl_config.enc_cert_, SSL_FILETYPE_PEM)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
COMMON_LOG(WARN, "SSL_CTX_use_enc_certificate_file failed", K(ssl_config.enc_cert_), K(ret));
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (SSL_CTX_use_certificate_chain_file(ctx, ssl_config.sign_cert_) <= 0) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -294,6 +347,11 @@ static int ob_ssl_load_cert_and_pkey(SSL_CTX* ctx, const ObSSLConfig& ssl_config
|
||||
}
|
||||
} else {
|
||||
if (ssl_config.is_sm_) {
|
||||
#ifdef OB_USE_BABASSL
|
||||
if (OB_FAIL(ob_ssl_load_cert_and_pkey_for_sm_memory(ctx, ssl_config))) {
|
||||
COMMON_LOG(WARN, "ob_ssl_load_cert_and_pkey_for_sm_memory failed", K(ret));
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (OB_FAIL(ob_ssl_load_cert_and_pkey_for_intl_memory(ctx, ssl_config))) {
|
||||
COMMON_LOG(WARN, "ob_ssl_load_cert_and_pkey_for_intl_memory failed", K(ret));
|
||||
@ -312,6 +370,12 @@ static SSL_CTX* ob_ssl_create_ssl_ctx(const ObSSLConfig& ssl_config)
|
||||
SSL_CTX *ctx = NULL;
|
||||
|
||||
if (ssl_config.is_sm_) {
|
||||
#ifdef OB_USE_BABASSL
|
||||
ctx = SSL_CTX_new(NTLS_method());
|
||||
if (NULL != ctx) {
|
||||
SSL_CTX_enable_ntls(ctx);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
ctx = SSL_CTX_new(SSLv23_method());
|
||||
}
|
||||
|
2
deps/oblib/src/rpc/ob_request.h
vendored
2
deps/oblib/src/rpc/ob_request.h
vendored
@ -39,7 +39,7 @@ class ObRequest: public common::ObLink
|
||||
public:
|
||||
friend class ObSqlRequestOperator;
|
||||
enum Type { OB_RPC, OB_MYSQL, OB_TASK, OB_TS_TASK, OB_SQL_TASK, OB_SQL_SOCK_TASK };
|
||||
enum TransportProto { TRANSPORT_PROTO_EASY = 0, TRANSPORT_PROTO_POC = 1, TRANSPORT_PROTO_RDMA = 2 };
|
||||
enum TransportProto { TRANSPORT_PROTO_EASY = 0, TRANSPORT_PROTO_POC = 1 };
|
||||
enum Stat {
|
||||
OB_EASY_REQUEST_EZ_RECV = 0,
|
||||
OB_EASY_REQUEST_RPC_DELIVER = 1,
|
||||
|
43
deps/oblib/src/rpc/obmysql/ob_mysql_util.cpp
vendored
43
deps/oblib/src/rpc/obmysql/ob_mysql_util.cpp
vendored
@ -25,6 +25,10 @@
|
||||
#include "lib/json_type/ob_json_bin.h"
|
||||
#include "lib/json_type/ob_json_base.h"
|
||||
#include "lib/geo/ob_geo_bin.h"
|
||||
#ifdef OB_BUILD_ORACLE_XML
|
||||
#include "lib/xml/ob_xml_util.h"
|
||||
#include "lib/xml/ob_xml_bin.h"
|
||||
#endif
|
||||
using namespace oceanbase::common;
|
||||
|
||||
namespace oceanbase
|
||||
@ -1075,7 +1079,46 @@ int ObMySQLUtil::urowid_cell_str(char *buf, const int64_t len, const ObURowIDDat
|
||||
int ObMySQLUtil::sql_utd_cell_str(uint64_t tenant_id, char *buf, const int64_t len, const ObString &val, int64_t &pos)
|
||||
{
|
||||
INIT_SUCC(ret);
|
||||
#ifdef OB_BUILD_ORACLE_XML
|
||||
lib::ObMemAttr mem_attr(tenant_id, "XMLCodeGen");
|
||||
lib::ObMallocHookAttrGuard malloc_guard(mem_attr);
|
||||
ObArenaAllocator allocator(mem_attr);
|
||||
ObMulModeNodeType node_type = M_MAX_TYPE;
|
||||
ObStringBuffer jbuf(&allocator);
|
||||
ParamPrint param_list;
|
||||
param_list.indent = 2;
|
||||
ObIMulModeBase *node = NULL;
|
||||
ObXmlNode *xml_node = NULL;
|
||||
ObMulModeMemCtx* xml_mem_ctx = nullptr;
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
OB_LOG(WARN, "invalid input args", K(ret), KP(buf));
|
||||
} else if (val.length() == 0) {
|
||||
if (OB_FAIL(ObMySQLUtil::store_null(buf, len, pos))) {
|
||||
OB_LOG(WARN, "fail to set null string", K(pos), K(len));
|
||||
}
|
||||
} else {
|
||||
int64_t new_length = val.length();
|
||||
if (OB_LIKELY(new_length < len - pos)) {
|
||||
int64_t pos_bk = pos;
|
||||
if (OB_FAIL(ObMySQLUtil::store_length(buf, len, new_length, pos))) {
|
||||
LOG_WARN("xml_cell_str store length failed", K(ret), K(len), K(new_length), K(pos));
|
||||
} else {
|
||||
if (OB_LIKELY(new_length <= len - pos)) {
|
||||
MEMCPY(buf + pos, val.ptr(), val.length());
|
||||
pos += new_length;
|
||||
} else {
|
||||
pos = pos_bk;
|
||||
ret = OB_SIZE_OVERFLOW;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = OB_SIZE_OVERFLOW;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
104
deps/oblib/src/rpc/obmysql/ob_rdma_server.h
vendored
104
deps/oblib/src/rpc/obmysql/ob_rdma_server.h
vendored
@ -1,104 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_OBMYSQL_OB_RDMA_SERVER_H_
|
||||
#define OCEANBASE_OBMYSQL_OB_RDMA_SERVER_H_
|
||||
#include <hash_map>
|
||||
#include <string>
|
||||
#include "ob_mysql_rdma_handler.h"
|
||||
#include "reasy_header_obp.h"
|
||||
#include "lib/lock/ob_drw_lock.h"
|
||||
|
||||
|
||||
using namespace oceanbase;
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace obmysql
|
||||
{
|
||||
|
||||
#define OB_MYSQL_SESSION_GROUP_COUNT 128
|
||||
#define OB_MYSQL_MCONN_HASHMAP_COUNT 8
|
||||
|
||||
#define OB_MYSQL_HASH_CODE(x, y) \
|
||||
({ \
|
||||
int res; \
|
||||
res = ((x >> 5) + (x >> 10) + y) & (OB_MYSQL_SESSION_GROUP_COUNT - 1); \
|
||||
res; \
|
||||
})
|
||||
|
||||
extern bool checkLogLevel(enum ObRdmaDebugLogLevelReq req);
|
||||
|
||||
typedef common::ObLinkHashMap<ObMysqlSessionID, ObMysqlRdmaConnection, AllocHandle<ObMysqlSessionID, ObMysqlRdmaConnection>, common::RefHandle, 128> ObRdmaConnMap;
|
||||
|
||||
|
||||
struct hash_A{
|
||||
size_t operator()(const class ObMysqlSessionID & A)const{
|
||||
return A.sessid_;
|
||||
}
|
||||
};
|
||||
|
||||
struct equal_A{
|
||||
bool operator()(const class ObMysqlSessionID & a1, const class ObMysqlSessionID & a2)const{
|
||||
return a1.sessid_ == a2.sessid_;
|
||||
}
|
||||
};
|
||||
|
||||
class ObRdmaServer
|
||||
{
|
||||
public:
|
||||
ObRdmaServer();
|
||||
virtual ~ObRdmaServer();
|
||||
int init(ObMySQLRdmaHandler& handler, const common::ObAddr &addr,
|
||||
uint32_t port, int io_thread_count);
|
||||
int start();
|
||||
void wait();
|
||||
int stop();
|
||||
void destroy();
|
||||
|
||||
int create_session(struct reasy_rdma_buffer *req);
|
||||
int destroy_session(struct reasy_rdma_buffer *req);
|
||||
int process(struct reasy_rdma_buffer *req);
|
||||
int update_credit(struct reasy_rdma_buffer *req);
|
||||
int send_keepalive(struct reasy_rdma_buffer *req);
|
||||
int reg_mconn(ObMysqlRdmaConnection& mconn);
|
||||
int unreg_mconn(ObMysqlRdmaConnection& mconn);
|
||||
int get_mconn(struct ObRdmaMysqlHeader *rheader, struct reasy_connection_desc *rdesc, ObMysqlRdmaConnection *&mconn);
|
||||
void put_mconn(ObMysqlRdmaConnection *mconn);
|
||||
static int send_response(ObMysqlRdmaConnection& mconn, char *buffer, size_t length);
|
||||
static int encode_reasy_header(ObMysqlRdmaConnection& mconn, reasy_rdma_buffer *rsp,
|
||||
uint8 type, uint32_t len);
|
||||
static int send_response(ObMysqlRdmaConnection& mconn, reasy_rdma_buffer *rsp,
|
||||
uint8 type, uint32_t len);
|
||||
|
||||
inline int get_map_pos(int64_t ver_id)
|
||||
{
|
||||
return io_thread_count_ == 0 ? 0 : ver_id % io_thread_count_;
|
||||
}
|
||||
|
||||
private:
|
||||
ObMySQLRdmaHandler *handler_;
|
||||
common::ObAddr listen_addr_;
|
||||
uint32_t listen_port_;
|
||||
struct reasy_io_t *rio_;
|
||||
bool is_inited_;
|
||||
bool started_;
|
||||
int io_thread_count_;
|
||||
__gnu_cxx::hash_map<ObMysqlSessionID, ObMysqlRdmaConnection *, hash_A, equal_A> mconn_hmap_[OB_MYSQL_MCONN_HASHMAP_COUNT];
|
||||
common::DRWLock sess_grp_locks_[OB_MYSQL_SESSION_GROUP_COUNT];
|
||||
};
|
||||
extern ObRdmaServer* global_rdma_server;
|
||||
|
||||
}; // end namespace obmysql
|
||||
}; // end namespace oceanbase
|
||||
|
||||
#endif /* #define OCEANBASE_OBMYSQL_OB_RDMA_SERVER_H_ */
|
@ -1,46 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_RPC_OB_REASY_SQL_REQUEST_OPERATOR_H_
|
||||
#define OCEANBASE_RPC_OB_REASY_SQL_REQUEST_OPERATOR_H_
|
||||
#include "rpc/ob_sql_request_operator.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace obmysql
|
||||
{
|
||||
|
||||
class ObReasySqlRequestOperator: public rpc::ObISqlRequestOperator
|
||||
{
|
||||
public:
|
||||
ObReasySqlRequestOperator() {}
|
||||
virtual ~ObReasySqlRequestOperator() {}
|
||||
virtual void *get_sql_session(rpc::ObRequest* req) override;
|
||||
virtual SSL *get_sql_ssl_st(rpc::ObRequest* req) override;
|
||||
virtual char* alloc_sql_response_buffer(rpc::ObRequest* req, int64_t size) override;
|
||||
virtual char *sql_reusable_alloc(rpc::ObRequest* req, const int64_t size) override;
|
||||
virtual common::ObAddr get_peer(const rpc::ObRequest* req) override;
|
||||
virtual void disconnect_sql_conn(rpc::ObRequest* req) override;
|
||||
virtual void finish_sql_request(rpc::ObRequest* req) override;
|
||||
virtual int write_response(rpc::ObRequest* req, const char* buf, int64_t sz) override;
|
||||
virtual int async_write_response(rpc::ObRequest* req, const char* buf, int64_t sz) override;
|
||||
virtual void get_sock_desc(rpc::ObRequest* req, rpc::ObSqlSockDesc& desc) override;
|
||||
virtual void disconnect_by_sql_sock_desc(rpc::ObSqlSockDesc& desc) override;
|
||||
virtual void destroy(rpc::ObRequest* req) override;
|
||||
virtual void set_sql_session_to_sock_desc(rpc::ObRequest* req, void* sess) override;
|
||||
};
|
||||
|
||||
}; // end namespace rpc
|
||||
}; // end namespace oceanbase
|
||||
|
||||
#endif /* OCEANBASE_RPC_OB_EASY_SQL_REQUEST_OPERATOR_H_ */
|
||||
|
21
deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h
vendored
21
deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h
vendored
@ -269,6 +269,12 @@ PCODE_DEF(OB_RUN_UPGRADE_JOB, 0x2A1)
|
||||
PCODE_DEF(OB_ADMIN_WASH_MEMORY_FRAGMENTATION, 0x2A2)
|
||||
PCODE_DEF(OB_CHECKPOINT_SLOG, 0x2A3)
|
||||
PCODE_DEF(OB_UPGRADE_TABLE_SCHEMA, 0x2A4)
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
PCODE_DEF(OB_ADMIN_ADD_ARBITRATION_SERVICE, 0x2A5)
|
||||
PCODE_DEF(OB_ADMIN_REMOVE_ARBITRATION_SERVICE, 0x2A6)
|
||||
PCODE_DEF(OB_ADMIN_REPLACE_ARBITRATION_SERVICE, 0x2A7)
|
||||
PCODE_DEF(OB_REMOVE_CLUSTER_INFO_FROM_ARB_SERVER, 0x2A8)
|
||||
#endif
|
||||
|
||||
PCODE_DEF(OB_CREATE_OUTLINE, 0x350)
|
||||
PCODE_DEF(OB_DROP_OUTLINE, 0x351)
|
||||
@ -556,6 +562,10 @@ PCODE_DEF(OB_RS_CANCEL_EVOLVE_TASK, 0x57B)
|
||||
PCODE_DEF(OB_START_TRANSFER_TASK, 0x57C)
|
||||
PCODE_DEF(OB_FINISH_TRANSFER_TASK, 0x57D)
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
PCODE_DEF(OB_ADD_ARB, 0x57E)
|
||||
PCODE_DEF(OB_REMOVE_ARB, 0x57F)
|
||||
#endif
|
||||
|
||||
//// DTL
|
||||
//
|
||||
@ -777,11 +787,18 @@ PCODE_DEF(OB_CHANGE_LS_ACCESS_MODE, 0x928)
|
||||
PCODE_DEF(OB_IN_TRANS_LOCK_TABLE, 0x929)
|
||||
PCODE_DEF(OB_IN_TRANS_LOCK_TABLET, 0x92A)
|
||||
PCODE_DEF(OB_HIGH_PRIORITY_TABLE_LOCK_TASK, 0x92B)
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
PCODE_DEF(OB_CREATE_ARB, 0x92C)
|
||||
PCODE_DEF(OB_DELETE_ARB, 0x92D)
|
||||
#endif
|
||||
PCODE_DEF(OB_REMOVE_OBJ_LOCK, 0x92E)
|
||||
PCODE_DEF(OB_ARB_GC_NOTIFY, 0x92F)
|
||||
PCODE_DEF(OB_UPDATE_OBJ_LOCK, 0x930)
|
||||
PCODE_DEF(OB_BATCH_TABLE_LOCK_TASK, 0x931)
|
||||
PCODE_DEF(OB_HIGH_PRIORITY_BATCH_TABLE_LOCK_TASK, 0x932)
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
PCODE_DEF(OB_ARB_CLUSTER_OP, 0x933)
|
||||
#endif
|
||||
|
||||
// ddl
|
||||
PCODE_DEF(OB_REMOTE_WRITE_DDL_REDO_LOG, 0x950)
|
||||
@ -943,6 +960,10 @@ PCODE_DEF(OB_LOG_GET_PALF_STAT, 0x151D)
|
||||
PCODE_DEF(OB_LOG_NOTIFY_FETCH_LOG, 0x151E)
|
||||
PCODE_DEF(OB_LOG_GET_STAT, 0x151F)
|
||||
PCODE_DEF(OB_LOG_FORCE_SET_LS_AS_SINGLE_REPLICA, 0x1520)
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
PCODE_DEF(OB_LOG_FORCE_CLEAR_ARB_CLUSTER_INFO, 0x1521)
|
||||
PCODE_DEF(OB_LOG_GET_ARB_MEMBER_INFO, 0x1522)
|
||||
#endif
|
||||
PCODE_DEF(OB_LOG_BATCH_FETCH_RESP, 0X1523)
|
||||
|
||||
// 1531-1550 for obesi
|
||||
|
112
deps/ussl-hook/ssl/ssl_config.c
vendored
112
deps/ussl-hook/ssl/ssl_config.c
vendored
@ -132,7 +132,39 @@ static void __attribute__((constructor(103))) setup()
|
||||
pthread_rwlock_init(&g_ssl_ctx_rwlock, NULL);
|
||||
}
|
||||
|
||||
#ifdef OB_USE_BABASSL
|
||||
static X509 *ob_ssl_get_sm_cert_memory(const char *cert)
|
||||
{
|
||||
BIO *bio = NULL;
|
||||
X509 *x509 = NULL;
|
||||
if (NULL == (bio = BIO_new_mem_buf(cert, -1))) {
|
||||
ussl_log_error("BIO_new_mem_buf failed, errno:%d", errno);
|
||||
} else if (NULL == (x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL))) {
|
||||
ussl_log_error("PEM_read_bio_X509 failed, errno:%d", errno);
|
||||
}
|
||||
if (NULL != bio) {
|
||||
BIO_free(bio);
|
||||
}
|
||||
return x509;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef OB_USE_BABASSL
|
||||
static EVP_PKEY *ob_ssl_get_sm_pkey_memory(const char *key)
|
||||
{
|
||||
BIO *bio = NULL;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
if (NULL == (bio = BIO_new_mem_buf(key, strlen(key)))) {
|
||||
ussl_log_error("BIO_new_mem_buf failed, errno:%d", errno);
|
||||
} else if (NULL == (pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL))) {
|
||||
ussl_log_error("PEM_read_bio_PrivateKey failed, errno:%d", errno);
|
||||
}
|
||||
if (NULL != bio) {
|
||||
BIO_free(bio);
|
||||
}
|
||||
return pkey;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int ob_ssl_config_check(const ssl_config_item_t *ssl_config)
|
||||
{
|
||||
@ -211,6 +243,59 @@ static int ob_ssl_set_verify_mode_and_load_CA(SSL_CTX *ctx, const ssl_config_ite
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef OB_USE_BABASSL
|
||||
static int ob_ssl_load_cert_and_pkey_for_sm_memory(SSL_CTX *ctx,
|
||||
const ssl_config_item_t *ssl_config)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_PKEY *sign_pkey = NULL;
|
||||
EVP_PKEY *enc_pkey = NULL;
|
||||
X509 *sign_x509 = NULL;
|
||||
X509 *enc_x509 = NULL;
|
||||
if (NULL == (sign_pkey = ob_ssl_get_sm_pkey_memory(ssl_config->sign_private_key))) {
|
||||
ret = EINVAL;
|
||||
ussl_log_warn("ob_ssl_get_sm_pkey_memory failed, ret:%d", ret);
|
||||
} else if (!SSL_CTX_use_sign_PrivateKey(ctx, sign_pkey)) {
|
||||
ret = EINVAL;
|
||||
ussl_log_warn("SSL_CTX_use_sign_PrivateKey failed, ret:%d, err:%s", ret,
|
||||
ERR_error_string(ERR_get_error(), NULL));
|
||||
} else if (NULL == (sign_x509 = ob_ssl_get_sm_cert_memory(ssl_config->sign_cert))) {
|
||||
ret = EINVAL;
|
||||
ussl_log_warn("ob_ssl_get_sm_cert_memory failed, ret:%d", ret);
|
||||
} else if (!SSL_CTX_use_sign_certificate(ctx, sign_x509)) {
|
||||
ret = EINVAL;
|
||||
ussl_log_warn("SSL_CTX_use_sign_certificate failed, ret:%d, err:%s", ret,
|
||||
ERR_error_string(ERR_get_error(), NULL));
|
||||
} else if (NULL == (enc_pkey = ob_ssl_get_sm_pkey_memory(ssl_config->enc_private_key))) {
|
||||
ret = EINVAL;
|
||||
ussl_log_warn("ob_ssl_get_sm_pkey_memory failed, ret:%d", ret);
|
||||
} else if (!SSL_CTX_use_enc_PrivateKey(ctx, enc_pkey)) {
|
||||
ret = EINVAL;
|
||||
ussl_log_warn("SSL_CTX_use_enc_PrivateKey failed, ret:%d, err:%s", ret,
|
||||
ERR_error_string(ERR_get_error(), NULL));
|
||||
} else if (NULL == (enc_x509 = ob_ssl_get_sm_cert_memory(ssl_config->enc_cert))) {
|
||||
ret = EINVAL;
|
||||
ussl_log_warn("ob_ssl_get_sm_cert_memory failed, ret:%d", ret);
|
||||
} else if (!SSL_CTX_use_enc_certificate(ctx, enc_x509)) {
|
||||
ret = EINVAL;
|
||||
ussl_log_warn("SSL_CTX_use_enc_certificate failed,ret:%d, err:%s", ret,
|
||||
ERR_error_string(ERR_get_error(), NULL));
|
||||
}
|
||||
if (NULL != sign_pkey) {
|
||||
EVP_PKEY_free(sign_pkey);
|
||||
}
|
||||
if (NULL != enc_pkey) {
|
||||
EVP_PKEY_free(enc_pkey);
|
||||
}
|
||||
if (NULL != sign_x509) {
|
||||
X509_free(sign_x509);
|
||||
}
|
||||
if (NULL != enc_x509) {
|
||||
X509_free(enc_x509);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int ob_ssl_load_cert_and_pkey_for_intl_memory(SSL_CTX *ctx,
|
||||
const ssl_config_item_t *ssl_config)
|
||||
@ -284,6 +369,22 @@ static int ob_ssl_load_cert_and_pkey(SSL_CTX *ctx, const ssl_config_item_t *ssl_
|
||||
int ret = 0;
|
||||
if (ssl_config->is_from_file) {
|
||||
if (ssl_config->is_sm) {
|
||||
#ifdef OB_USE_BABASSL
|
||||
if (!SSL_CTX_use_sign_PrivateKey_file(ctx, ssl_config->sign_private_key, SSL_FILETYPE_PEM)) {
|
||||
ret = EINVAL;
|
||||
ussl_log_warn("SSL_CTX_use_sign_PrivateKey_file failed,ret:%d", ret);
|
||||
} else if (!SSL_CTX_use_sign_certificate_file(ctx, ssl_config->sign_cert, SSL_FILETYPE_PEM)) {
|
||||
ret = EINVAL;
|
||||
ussl_log_warn("SSL_CTX_use_sign_certificate_file failed, ret:%d", ret);
|
||||
} else if (!SSL_CTX_use_enc_PrivateKey_file(ctx, ssl_config->enc_private_key,
|
||||
SSL_FILETYPE_PEM)) {
|
||||
ret = EINVAL;
|
||||
ussl_log_warn("SSL_CTX_use_enc_PrivateKey_file failed, ret:%d", ret);
|
||||
} else if (!SSL_CTX_use_enc_certificate_file(ctx, ssl_config->enc_cert, SSL_FILETYPE_PEM)) {
|
||||
ret = EINVAL;
|
||||
ussl_log_warn("SSL_CTX_use_enc_certificate_file failed, ret:%d", ret);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (SSL_CTX_use_certificate_chain_file(ctx, ssl_config->sign_cert) <= 0) {
|
||||
ret = EINVAL;
|
||||
@ -299,6 +400,11 @@ static int ob_ssl_load_cert_and_pkey(SSL_CTX *ctx, const ssl_config_item_t *ssl_
|
||||
}
|
||||
} else {
|
||||
if (ssl_config->is_sm) {
|
||||
#ifdef OB_USE_BABASSL
|
||||
if (0 != (ret = ob_ssl_load_cert_and_pkey_for_sm_memory(ctx, ssl_config))) {
|
||||
ussl_log_warn("ob_ssl_load_cert_and_pkey_for_sm_memory failed, ret:%d", ret);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (0 != (ret = ob_ssl_load_cert_and_pkey_for_intl_memory(ctx, ssl_config))) {
|
||||
ussl_log_warn("ob_ssl_load_cert_and_pkey_for_intl_memory failed, ret:%d", ret);
|
||||
@ -327,6 +433,12 @@ static SSL_CTX *ob_ssl_create_ssl_ctx(const ssl_config_item_t *ssl_config, int t
|
||||
}
|
||||
|
||||
if (ssl_config->is_sm) {
|
||||
#ifdef OB_USE_BABASSL
|
||||
ctx = SSL_CTX_new(NTLS_method());
|
||||
if (NULL != ctx) {
|
||||
SSL_CTX_enable_ntls(ctx);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
ctx = SSL_CTX_new(SSLv23_method());
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ storage_dml_unittest(test_tablet_status_cache test_tablet_status_cache.cpp)
|
||||
storage_dml_unittest(test_tablet_member_load_and_free test_tablet_member_load_and_free.cpp)
|
||||
storage_dml_unittest(test_ls_migration_param test_ls_migration_param.cpp)
|
||||
storage_dml_unittest(test_ls_tablet_service test_ls_tablet_service.cpp)
|
||||
if(OB_BUILD_CLOSE_MODULES)
|
||||
storage_unittest(test_memtable test_memtable_v2.cpp)
|
||||
endif()
|
||||
#storage_dml_unittest(test_lob_manager test_lob_manager.cpp)
|
||||
storage_unittest(test_trans test_trans.cpp)
|
||||
#storage_unittest(test_ls_restore_task_mgr)
|
||||
|
@ -37,7 +37,7 @@
|
||||
static int64_t const_data_num;
|
||||
int64_t tx_data_num CACHE_ALIGNED = 0;
|
||||
int64_t inserted_cnt = 0;
|
||||
share::SCN insert_start_scn = share::SCN::min_scn();
|
||||
oceanbase::share::SCN insert_start_scn = oceanbase::share::SCN::min_scn();
|
||||
const int64_t ONE_SEC_NS = 1000LL * 1000LL * 1000LL;
|
||||
const int64_t MOD_NS = 1000LL * ONE_SEC_NS;
|
||||
|
||||
|
@ -27,10 +27,9 @@
|
||||
#include "storage/tablet/ob_tablet.h"
|
||||
#include "storage/tx_storage/ob_ls_service.h"
|
||||
|
||||
using namespace unittest;
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace unittest;
|
||||
namespace storage
|
||||
{
|
||||
using namespace share::schema;
|
||||
@ -1121,7 +1120,7 @@ TEST_F(TestTransferHandler, doing_commin_trans_failed)
|
||||
} // namespace oceanbase
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unittest::init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -213,7 +213,7 @@ TEST_F(TestAddRemoveReplaceArbitrationService, test_add_remove_replace)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -300,7 +300,7 @@ TEST_F(TestProxyDefaultValue, test_default_value_is_null)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unittest::init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -350,7 +350,7 @@ TEST_F(TestArbitrationServiceReplicaTaskTableOperator, test_operator)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -93,7 +93,7 @@ TEST_F(TestArbitrationServiceRpc, test_argument)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -204,7 +204,7 @@ TEST_F(TestArbitrationServiceTableOperator, test_single)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -134,7 +134,7 @@ TEST_F(TestChangeArbServiceStatus, test_change_arb_service_status)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -155,7 +155,7 @@ TEST_F(TestAddRemoveReplaceArbitrationService, test_add_remove_replace)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -95,7 +95,7 @@ TEST_F(TestGetStoppedZoneList, GetStoppedZoneList)
|
||||
} // oceanbase
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -20,10 +20,9 @@
|
||||
#include "lib/ob_errno.h"
|
||||
#include "share/location_cache/ob_location_service.h" // ObLocationService
|
||||
|
||||
using namespace unittest;
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace unittest;
|
||||
namespace share
|
||||
{
|
||||
using namespace common;
|
||||
@ -306,7 +305,7 @@ TEST_F(TestLocationService, test_check_ls_exist)
|
||||
} // namespace oceanbase
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unittest::init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -30,8 +30,8 @@ static const char *TEST_FILE_NAME = "test_lock_table_persistence";
|
||||
static const char *BORN_CASE_NAME = "ObLockTableBeforeRestartTest";
|
||||
static const char *RESTART_CASE_NAME = "ObLockTableAfterRestartTest";
|
||||
|
||||
static share::SCN lock_scn;
|
||||
static share::SCN unlock_scn;
|
||||
static oceanbase::share::SCN lock_scn;
|
||||
static oceanbase::share::SCN unlock_scn;
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
|
@ -232,7 +232,7 @@ TEST_F(TestLSReplica, test_text2learnerlist)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -300,7 +300,7 @@ TEST_F(TestLSStatusOperator, add_tenant)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -442,7 +442,7 @@ TEST_F(TestTabletToLSOperatorBatchGet, test_batch_get)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -20,10 +20,9 @@
|
||||
#include "lib/ob_errno.h"
|
||||
#include "share/schema/ob_schema_service_sql_impl.h"
|
||||
|
||||
using namespace unittest;
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace unittest;
|
||||
namespace share
|
||||
{
|
||||
using namespace share::schema;
|
||||
@ -194,7 +193,7 @@ TEST_F(TestSchemaServiceSqlImpl, test_get_table_latest_schema_versions)
|
||||
} // namespace oceanbase
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unittest::init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -192,7 +192,7 @@ TEST_F(TestStandbyBalance, BalanceLSGroup)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -602,7 +602,7 @@ TEST_F(TestBalanceOperator, ls_balance_helper)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -22,10 +22,9 @@
|
||||
#include "share/transfer/ob_transfer_task_operator.h" // ObTransferTaskOperator
|
||||
#include "lib/allocator/page_arena.h"
|
||||
|
||||
using namespace unittest;
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace unittest;
|
||||
namespace rootserver
|
||||
{
|
||||
using namespace share::schema;
|
||||
@ -389,7 +388,7 @@ TEST_F(TestTenantTransferService, test_offline_ddl_hidden_table)
|
||||
} // namespace oceanbase
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unittest::init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -18,10 +18,9 @@
|
||||
#include "lib/ob_errno.h"
|
||||
#include "share/transfer/ob_transfer_task_operator.h"
|
||||
|
||||
using namespace unittest;
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace unittest;
|
||||
namespace share
|
||||
{
|
||||
using namespace schema;
|
||||
@ -45,7 +44,7 @@ public:
|
||||
share::SCN start_scn_;
|
||||
share::SCN finish_scn_;
|
||||
ObTransferStatus status_;
|
||||
TraceId trace_id_;
|
||||
ObCurTraceId::TraceId trace_id_;
|
||||
ObTransferTask task_;
|
||||
transaction::tablelock::ObTableLockOwnerID lock_owner_id_;
|
||||
};
|
||||
@ -382,7 +381,7 @@ TEST_F(TestTransferTaskOperator, test_operator)
|
||||
} // namespace oceanbase
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unittest::init_log_and_gtest(argc, argv);
|
||||
oceanbase::unittest::init_log_and_gtest(argc, argv);
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
@ -2,6 +2,7 @@ add_library(ob_base INTERFACE)
|
||||
target_include_directories(
|
||||
ob_base INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
target_compile_features(ob_base INTERFACE cxx_std_11)
|
||||
target_link_libraries(ob_base INTERFACE oblib_base objit_base
|
||||
${OB_RELRO_FLAG} -Wl,-T,${CMAKE_SOURCE_DIR}/rpm/ld.lds)
|
||||
|
@ -49,6 +49,8 @@ ob_set_subtarget(ob_logservice common
|
||||
ob_server_log_block_mgr.cpp
|
||||
ob_log_flashback_service.cpp
|
||||
ob_net_keepalive_adapter.cpp
|
||||
ob_log_external_storage_handler.cpp
|
||||
ob_log_external_storage_io_task.cpp
|
||||
ob_log_monitor.cpp
|
||||
ob_log_external_storage_handler.cpp
|
||||
ob_log_external_storage_io_task.cpp
|
||||
@ -186,7 +188,6 @@ ob_set_subtarget(ob_logservice restoreservice
|
||||
restoreservice/ob_remote_log_writer.cpp
|
||||
)
|
||||
|
||||
|
||||
ob_set_subtarget(ob_logservice data_dictionary
|
||||
data_dictionary/ob_data_dict_utils.cpp
|
||||
data_dictionary/ob_data_dict_struct.cpp
|
||||
|
@ -189,6 +189,9 @@ int PriorityV1::refresh_(const share::ObLSID &ls_id)
|
||||
LsElectionReferenceInfo election_reference_info;
|
||||
SCN scn = SCN::min_scn();
|
||||
if (observer::ObServer::get_instance().is_arbitration_mode()) {
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
ret = OB_NO_NEED_UPDATE;
|
||||
#endif
|
||||
} else if (OB_ISNULL(coordinator) || OB_ISNULL(detector)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
COORDINATOR_LOG_(ERROR, "unexpected nullptr");
|
||||
|
@ -1,7 +1,13 @@
|
||||
add_library(obcdc_msg STATIC IMPORTED)
|
||||
set_target_properties(obcdc_msg PROPERTIES
|
||||
IMPORTED_LOCATION ${DEP_DIR}/lib/liboblogmsg.a)
|
||||
set_property(GLOBAL PROPERTY CDC_MSG_HEADER_DIR ${DEP_DIR}/include/oblogmsg)
|
||||
if (OB_USE_DRCMSG)
|
||||
set_target_properties(obcdc_msg PROPERTIES
|
||||
IMPORTED_LOCATION ${DEP_DIR}/lib/libdrcmsg.a)
|
||||
set_property(GLOBAL PROPERTY CDC_MSG_HEADER_DIR ${DEP_DIR}/include/drcmsg)
|
||||
else()
|
||||
set_target_properties(obcdc_msg PROPERTIES
|
||||
IMPORTED_LOCATION ${DEP_DIR}/lib/liboblogmsg.a)
|
||||
set_property(GLOBAL PROPERTY CDC_MSG_HEADER_DIR ${DEP_DIR}/include/oblogmsg)
|
||||
endif()
|
||||
|
||||
add_library(rocksdb STATIC IMPORTED)
|
||||
set_target_properties(rocksdb PROPERTIES
|
||||
@ -161,6 +167,7 @@ else()
|
||||
-Wl,-e,so_main
|
||||
easy
|
||||
)
|
||||
if(OB_BUILD_OPENSOURCE)
|
||||
set(LGPL_DEPS "-L${DEP_DIR}/lib/mariadb -lmariadb")
|
||||
if (OB_STATIC_LINK_LGPL_DEPS)
|
||||
set(LGPL_DEPS "-L${DEP_DIR}/lib/mariadb -l:libmariadbclient.a")
|
||||
@ -169,6 +176,7 @@ else()
|
||||
PRIVATE
|
||||
${LGPL_DEPS}
|
||||
)
|
||||
endif()
|
||||
add_dependencies(obcdc obcdc_objects)
|
||||
endif()
|
||||
set_target_properties(obcdc PROPERTIES
|
||||
|
@ -27,8 +27,13 @@
|
||||
#include <fnmatch.h> // FNM_CASEFOLD
|
||||
#include <stdint.h>
|
||||
#include <map>
|
||||
#ifndef OB_USE_DRCMSG
|
||||
#include "oblogmsg/LogRecord.h"
|
||||
typedef oceanbase::logmessage::ILogRecord ICDCRecord;
|
||||
#else
|
||||
#include <drcmsg/BR.h>
|
||||
typedef IBinlogRecord ICDCRecord;
|
||||
#endif
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
|
@ -14,6 +14,9 @@
|
||||
|
||||
#define USING_LOG_PREFIX OBLOG
|
||||
|
||||
#ifdef OB_USE_DRCMSG
|
||||
#include <drcmsg/MD.h> // ITableMeta
|
||||
#endif
|
||||
|
||||
#include "ob_log_binlog_record.h"
|
||||
#include "ob_log_utils.h"
|
||||
|
@ -15,7 +15,12 @@
|
||||
#ifndef OCEANBASE_LIBOBCDC_BINLOG_RECORD_
|
||||
#define OCEANBASE_LIBOBCDC_BINLOG_RECORD_
|
||||
|
||||
#ifndef OB_USE_DRCMSG
|
||||
#include "ob_cdc_msg_convert.h"
|
||||
#else
|
||||
#include <drcmsg/BR.h> // IBinlogRecord
|
||||
#include <drcmsg/DRCMessageFactory.h> // createBinlogRecord
|
||||
#endif
|
||||
#include "lib/queue/ob_link.h" // ObLink
|
||||
|
||||
#include "share/ob_define.h"
|
||||
|
@ -177,6 +177,7 @@ public:
|
||||
// default value '0:not_skip'
|
||||
T_DEF_BOOL(skip_ob_version_compat_check, OB_CLUSTER_PARAMETER, 0, "0:not_skip, 1:skip")
|
||||
|
||||
#ifndef OB_USE_DRCMSG
|
||||
// default DFT_BR(LogRecordImpl), add DFT_BR_PB
|
||||
// passed in via IObLog::init interface
|
||||
// string LogMsgFactory::DFT_ColMeta = "ColMetaImpl";
|
||||
@ -185,6 +186,17 @@ public:
|
||||
// string LogMsgFactory::DFT_METAS = "MetaDataCollectionsImpl";
|
||||
// string LogMsgFactory::DFT_LR = "LogRecordImpl";
|
||||
DEF_STR(drc_message_factory_binlog_record_type, OB_CLUSTER_PARAMETER, "LogRecordImpl", "LogMsgFactory::DFT_BR");
|
||||
#else
|
||||
// default DFT_BR(BinlogRecordImpl), add DFT_BR_PB
|
||||
// passed in via IObLog::init interface
|
||||
// string DRCMessageFactory::DFT_ColMeta = "ColMetaImpl";
|
||||
// string DRCMessageFactory::DFT_TableMeta = "TableMetaImpl";
|
||||
// string DRCMessageFactory::DFT_DBMeta = "DBMetaImpl";
|
||||
// string DRCMessageFactory::DFT_METAS = "MetaDataCollectionsImpl";
|
||||
// string DRCMessageFactory::DFT_BR = "BinlogRecordImpl";
|
||||
// string DRCMessageFactory::DFT_BR_PB = "BinlogRecordProtobuf";
|
||||
DEF_STR(drc_message_factory_binlog_record_type, OB_CLUSTER_PARAMETER, "BinlogRecordImpl", "DRCMessageFactory::DFT_BR");
|
||||
#endif
|
||||
|
||||
// whether to check ObTraceId
|
||||
T_DEF_BOOL(need_verify_ob_trace_id, OB_CLUSTER_PARAMETER, 0, "0:disabled, 1:enabled");
|
||||
|
@ -15,7 +15,11 @@
|
||||
#ifndef OCEANBASE_LIBOBCDC_OB_LOG_DDL_PROCESSOR_H__
|
||||
#define OCEANBASE_LIBOBCDC_OB_LOG_DDL_PROCESSOR_H__
|
||||
|
||||
#ifndef OB_USE_DRCMSG
|
||||
#include "ob_cdc_msg_convert.h"
|
||||
#else
|
||||
#include <drcmsg/BR.h> // IBinlogRecord
|
||||
#endif
|
||||
#include "lib/utility/ob_macro_utils.h" // DISALLOW_COPY_AND_ASSIGN
|
||||
#include "ob_log_utils.h" // _SEC_
|
||||
|
||||
|
@ -15,7 +15,11 @@
|
||||
#ifndef OCEANBASE_LIBOBCDC_FORMATTER_H__
|
||||
#define OCEANBASE_LIBOBCDC_FORMATTER_H__
|
||||
|
||||
#ifndef OB_USE_DRCMSG
|
||||
#include "ob_cdc_msg_convert.h"
|
||||
#else
|
||||
#include <drcmsg/binlogBuf.h> // binlogBuf
|
||||
#endif
|
||||
|
||||
#include "lib/allocator/ob_allocator.h" // ObIAllocator
|
||||
#include "lib/thread/ob_multi_fixed_queue_thread.h" // ObMQThread
|
||||
|
@ -15,7 +15,12 @@
|
||||
#ifndef OCEANBASE_LIBOBCDC_META_MANAGER_H__
|
||||
#define OCEANBASE_LIBOBCDC_META_MANAGER_H__
|
||||
|
||||
#ifndef OB_USE_DRCMSG
|
||||
#include "ob_cdc_msg_convert.h"
|
||||
#else
|
||||
#include <drcmsg/MD.h> // ITableMeta, IDBMeta
|
||||
#include <drcmsg/DRCMessageFactory.h> // DRCMessageFactory
|
||||
#endif
|
||||
#include "share/ob_errno.h" // OB_SUCCESS
|
||||
#include "lib/lock/ob_spin_rwlock.h" // SpinRWLock, SpinRLockGuard, SpinWLockGuard
|
||||
#include "lib/allocator/page_arena.h" // DefaultPageAllocator
|
||||
|
@ -204,6 +204,9 @@ int ObLogMySQLConnector::exec(MySQLQueryBase& query)
|
||||
bool ObLogMySQLConnector::is_oracle_mode() const
|
||||
{
|
||||
bool b_ret = false;
|
||||
#ifdef OB_USE_DRCMSG
|
||||
b_ret = OB_NOT_NULL(mysql_) && mysql_->oracle_mode;
|
||||
#endif
|
||||
return b_ret;
|
||||
}
|
||||
|
||||
@ -262,6 +265,17 @@ int ObLogMySQLConnector::init_conn_(const MySQLConnConfig &cfg,
|
||||
K(mysql_error(mysql_)), K(write_timeout));
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
} else {
|
||||
#ifdef OB_BUILD_TDE_SECURITY
|
||||
if (! enable_ssl_client_authentication) {
|
||||
int64_t ssl_enforce = 0;
|
||||
|
||||
if (0 != (mysql_options(mysql_, MYSQL_OPT_SSL_ENFORCE, &ssl_enforce))) {
|
||||
LOG_ERROR("failed to set ssl mode for mysql conn",
|
||||
K(mysql_error(mysql_)), K(ssl_enforce));
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// CLIENT_MULTI_STATEMENTS: enable multiple-statement execution and multiple-result
|
||||
if (mysql_ != mysql_real_connect(mysql_,
|
||||
|
@ -20,6 +20,9 @@
|
||||
|
||||
#include "ob_log_config.h" // ObLogConfig
|
||||
#include "observer/ob_srv_network_frame.h"
|
||||
#ifdef OB_BUILD_TDE_SECURITY
|
||||
#include "share/ob_encrypt_kms.h" // ObSSLClient
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include "ussl-hook.h"
|
||||
@ -281,8 +284,25 @@ int ObLogRpc::reload_ssl_config()
|
||||
private_key = OB_CLIENT_SSL_KEY_FILE;
|
||||
}
|
||||
} else {
|
||||
#ifndef OB_BUILD_TDE_SECURITY
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("only support local file mode", K(ret));
|
||||
#else
|
||||
share::ObSSLClient client;
|
||||
|
||||
if (OB_FAIL(client.init(ssl_config.ptr(), ssl_config.length()))) {
|
||||
OB_LOG(WARN, "kms client init", K(ret), K(ssl_config));
|
||||
} else if (OB_FAIL(client.check_param_valid())) {
|
||||
OB_LOG(WARN, "kms client param is not valid", K(ret));
|
||||
} else {
|
||||
use_bkmi = client.is_bkmi_mode();
|
||||
use_sm = client.is_sm_scene();
|
||||
ca_cert = client.get_root_ca().ptr();
|
||||
public_cert = client.public_cert_.content_.ptr();
|
||||
private_key = client.private_key_.content_.ptr();
|
||||
ssl_key_expired_time = client.public_cert_.key_expired_time_;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
|
@ -15,7 +15,14 @@
|
||||
#ifndef OCEANBASE_LIBOBCDC_UTILS_H__
|
||||
#define OCEANBASE_LIBOBCDC_UTILS_H__
|
||||
|
||||
#ifndef OB_USE_DRCMSG
|
||||
#include "ob_cdc_msg_convert.h"
|
||||
#else
|
||||
#include <drcmsg/BR.h> // RecordType
|
||||
#include <drcmsg/MsgWrapper.h> // IStrArray
|
||||
#include <drcmsg/MD.h> // ITableMeta
|
||||
#include <drcmsg/DRCMessageFactory.h>
|
||||
#endif
|
||||
|
||||
#include <sys/prctl.h>
|
||||
#include "lib/allocator/ob_allocator.h" // ObIAllocator
|
||||
|
@ -21,6 +21,9 @@
|
||||
#include "sql/engine/expr/ob_datum_cast.h" // padding_char_for_cast
|
||||
#include "lib/alloc/ob_malloc_allocator.h"
|
||||
#include "lib/geo/ob_geo_utils.h"
|
||||
#ifdef OB_BUILD_ORACLE_XML
|
||||
#include "lib/xml/ob_xml_util.h"
|
||||
#endif
|
||||
#include "sql/engine/expr/ob_expr_uuid.h"
|
||||
#include "sql/engine/expr/ob_expr_operator.h"
|
||||
#include "sql/engine/expr/ob_expr_res_type_map.h"
|
||||
@ -452,7 +455,12 @@ int ObObj2strHelper::convert_xmltype_to_text_(
|
||||
common::ObString &str,
|
||||
common::ObIAllocator &allocator) const
|
||||
{
|
||||
#ifdef OB_BUILD_ORACLE_XML
|
||||
const ObString &data = obj.get_string();
|
||||
return ObXmlUtil::xml_bin_to_text(allocator, data, str);
|
||||
#else
|
||||
return OB_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ObObj2strHelper::need_padding_(const lib::Worker::CompatMode &compat_mode,
|
||||
|
@ -15,7 +15,14 @@
|
||||
#ifndef OCEANBASE_LIBOBCDC_TESTS_BINLOG_RECORD_PRINTER_H__
|
||||
#define OCEANBASE_LIBOBCDC_TESTS_BINLOG_RECORD_PRINTER_H__
|
||||
|
||||
#ifndef OB_USE_DRCMSG
|
||||
#include "ob_cdc_msg_convert.h"
|
||||
#else
|
||||
#include <drcmsg/BR.h> // IBinlogRecord
|
||||
#include <drcmsg/MD.h> // ITableMeta
|
||||
#include <drcmsg/MsgWrapper.h> // IStrArray
|
||||
#include <drcmsg/binlogBuf.h> // binlogBuf
|
||||
#endif
|
||||
|
||||
#include "share/ob_define.h" // DISALLOW_COPY_AND_ASSIGN
|
||||
#include "ob_log_config.h" // TCONF
|
||||
|
@ -20,6 +20,9 @@
|
||||
|
||||
#include "ob_log_config.h" // ObLogFetcherConfig
|
||||
#include "observer/ob_srv_network_frame.h"
|
||||
#ifdef OB_BUILD_TDE_SECURITY
|
||||
#include "share/ob_encrypt_kms.h" // ObSSLClient
|
||||
#endif
|
||||
#include "logservice/data_dictionary/ob_data_dict_utils.h"
|
||||
|
||||
/// The rpc proxy executes the RPC function with two error codes:
|
||||
@ -255,8 +258,25 @@ int ObLogRpc::reload_ssl_config()
|
||||
private_key = OB_CLIENT_SSL_KEY_FILE;
|
||||
}
|
||||
} else {
|
||||
#ifndef OB_BUILD_TDE_SECURITY
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("only support local file mode", K(ret));
|
||||
#else
|
||||
share::ObSSLClient client;
|
||||
|
||||
if (OB_FAIL(client.init(ssl_config.ptr(), ssl_config.length()))) {
|
||||
OB_LOG(WARN, "kms client init", K(ret), K(ssl_config));
|
||||
} else if (OB_FAIL(client.check_param_valid())) {
|
||||
OB_LOG(WARN, "kms client param is not valid", K(ret));
|
||||
} else {
|
||||
use_bkmi = client.is_bkmi_mode();
|
||||
use_sm = client.is_sm_scene();
|
||||
ca_cert = client.get_root_ca().ptr();
|
||||
public_cert = client.public_cert_.content_.ptr();
|
||||
private_key = client.private_key_.content_.ptr();
|
||||
ssl_key_expired_time = client.public_cert_.key_expired_time_;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
|
@ -98,6 +98,23 @@ int LogRequestHandler::get_rpc_proxy_(obrpc::ObLogServiceRpcProxy *&rpc_proxy) c
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
int LogRequestHandler::get_arb_service_(ObArbitrationService *&arb_service) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
logservice::ObLogService *log_service = NULL;
|
||||
if (OB_ISNULL(log_service = MTL(logservice::ObLogService*))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
CLOG_LOG(WARN, "get_log_service failed", K(ret));
|
||||
} else if (OB_ISNULL(arb_service = log_service->get_arbitration_service())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
CLOG_LOG(WARN, "log_service.get_arbitration_service failed", K(ret));
|
||||
} else {
|
||||
CLOG_LOG(TRACE, "get_arb_service_", KP(arb_service), KP(log_service), K(MTL_ID()));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int LogRequestHandler::get_flashback_service_(ObLogFlashbackService *&flashback_srv) const
|
||||
{
|
||||
@ -236,6 +253,14 @@ int ConfigChangeCmdHandler::handle_config_change_cmd(const LogConfigChangeCmd &r
|
||||
case REMOVE_MEMBER_CMD:
|
||||
ret = palf_handle_->remove_member(req.removed_member_, req.new_replica_num_, req.timeout_us_);
|
||||
break;
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
case ADD_ARB_MEMBER_CMD:
|
||||
ret = palf_handle_->add_arb_member(req.added_member_, req.timeout_us_);
|
||||
break;
|
||||
case REMOVE_ARB_MEMBER_CMD:
|
||||
ret = palf_handle_->remove_arb_member(req.removed_member_, req.timeout_us_);
|
||||
break;
|
||||
#endif
|
||||
case REPLACE_MEMBER_CMD:
|
||||
ret = palf_handle_->replace_member(req.added_member_, req.removed_member_, req.config_version_, req.timeout_us_);
|
||||
break;
|
||||
@ -277,6 +302,26 @@ int ConfigChangeCmdHandler::handle_config_change_cmd(const LogConfigChangeCmd &r
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
template <>
|
||||
int LogRequestHandler::handle_request<LogServerProbeMsg>(const LogServerProbeMsg &req)
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
ObArbitrationService *arb_service;
|
||||
const common::ObAddr &server = req.src_;
|
||||
if (false == req.is_valid()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
CLOG_LOG(ERROR, "Invalid argument!!!", K(ret), K(req));
|
||||
} else if (OB_FAIL(get_arb_service_(arb_service))) {
|
||||
CLOG_LOG(ERROR, "get_arb_service_ failed", K(ret), K(req));
|
||||
} else if (OB_FAIL(arb_service->handle_server_probe_msg(server, req))) {
|
||||
CLOG_LOG(WARN, "handle_server_probe_msg failed", K(ret), K(req));
|
||||
} else {
|
||||
CLOG_LOG(TRACE, "handle_server_probe_msg success", K(ret), K(server), K(req));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <>
|
||||
int LogRequestHandler::handle_request<LogChangeAccessModeCmd>(const LogChangeAccessModeCmd &req)
|
||||
|
@ -33,6 +33,9 @@ class ObLogServiceRpcProxy;
|
||||
|
||||
namespace logservice
|
||||
{
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
class ObArbitrationService;
|
||||
#endif
|
||||
class ObLogFlashbackService;
|
||||
class ObLogHandler;
|
||||
class ObLogReplayService;
|
||||
@ -48,6 +51,9 @@ public:
|
||||
int handle_request(const ReqType &req);
|
||||
private:
|
||||
int get_palf_handle_guard_(const int64_t palf_id, palf::PalfHandleGuard &palf_handle_guard) const;
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
int get_arb_service_(ObArbitrationService *&arb_service) const;
|
||||
#endif
|
||||
int get_self_addr_(common::ObAddr &self) const;
|
||||
int get_rpc_proxy_(obrpc::ObLogServiceRpcProxy *&rpc_proxy) const;
|
||||
int get_flashback_service_(ObLogFlashbackService *&flashback_srv) const;
|
||||
|
@ -104,6 +104,12 @@ DEFINE_LOGSERVICE_SYNC_RPC_PROCESSOR(LogGetPalfStatReqP,
|
||||
LogGetPalfStatResp,
|
||||
obrpc::OB_LOG_GET_PALF_STAT);
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
DEFINE_LOGSERVICE_RPC_PROCESSOR(LogServerProbeP,
|
||||
obrpc::ObLogServiceRpcProxy,
|
||||
LogServerProbeMsg,
|
||||
obrpc::OB_LOG_ARB_PROBE_MSG);
|
||||
#endif
|
||||
|
||||
DEFINE_LOGSERVICE_RPC_PROCESSOR(LogChangeAccessModeP,
|
||||
obrpc::ObLogServiceRpcProxy,
|
||||
|
@ -33,6 +33,10 @@ public:
|
||||
(logservice::LogChangeAccessModeCmd));
|
||||
RPC_AP(PR3 send_log_flashback_msg, OB_LOG_FLASHBACK_CMD,
|
||||
(logservice::LogFlashbackMsg));
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
RPC_S(PR5 create_arb, OB_CREATE_ARB, (obrpc::ObCreateArbArg), obrpc::ObCreateArbResult);
|
||||
RPC_S(PR5 delete_arb, OB_DELETE_ARB, (obrpc::ObDeleteArbArg), obrpc::ObDeleteArbResult);
|
||||
#endif
|
||||
RPC_S(PR3 get_palf_stat, OB_LOG_GET_PALF_STAT,
|
||||
(logservice::LogGetPalfStatReq), logservice::LogGetPalfStatResp);
|
||||
};
|
||||
|
@ -151,6 +151,9 @@ bool LogConfigChangeCmd::is_valid() const
|
||||
bool LogConfigChangeCmd::is_remove_member_list() const
|
||||
{
|
||||
return REMOVE_MEMBER_CMD == cmd_type_
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
|| REMOVE_ARB_MEMBER_CMD == cmd_type_
|
||||
#endif
|
||||
|| REPLACE_MEMBER_CMD == cmd_type_
|
||||
|| SWITCH_TO_LEARNER_CMD == cmd_type_
|
||||
|| REPLACE_MEMBER_WITH_LEARNER_CMD == cmd_type_;
|
||||
@ -159,6 +162,9 @@ bool LogConfigChangeCmd::is_remove_member_list() const
|
||||
bool LogConfigChangeCmd::is_add_member_list() const
|
||||
{
|
||||
return ADD_MEMBER_CMD == cmd_type_
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
|| ADD_ARB_MEMBER_CMD == cmd_type_
|
||||
#endif
|
||||
|| REPLACE_MEMBER_CMD == cmd_type_
|
||||
|| SWITCH_TO_ACCEPTOR_CMD == cmd_type_
|
||||
|| REPLACE_MEMBER_WITH_LEARNER_CMD == cmd_type_;
|
||||
|
@ -30,6 +30,10 @@ enum LogConfigChangeCmdType {
|
||||
CHANGE_REPLICA_NUM_CMD,
|
||||
ADD_MEMBER_CMD,
|
||||
REMOVE_MEMBER_CMD,
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
ADD_ARB_MEMBER_CMD,
|
||||
REMOVE_ARB_MEMBER_CMD,
|
||||
#endif
|
||||
REPLACE_MEMBER_CMD,
|
||||
ADD_LEARNER_CMD,
|
||||
REMOVE_LEARNER_CMD,
|
||||
@ -50,6 +54,10 @@ inline const char *log_config_change_cmd2str(const LogConfigChangeCmdType state)
|
||||
{
|
||||
CHECK_CMD_TYPE_STR(ADD_MEMBER_CMD);
|
||||
CHECK_CMD_TYPE_STR(REMOVE_MEMBER_CMD);
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
CHECK_CMD_TYPE_STR(ADD_ARB_MEMBER_CMD);
|
||||
CHECK_CMD_TYPE_STR(REMOVE_ARB_MEMBER_CMD);
|
||||
#endif
|
||||
CHECK_CMD_TYPE_STR(REPLACE_MEMBER_CMD);
|
||||
CHECK_CMD_TYPE_STR(ADD_LEARNER_CMD);
|
||||
CHECK_CMD_TYPE_STR(REMOVE_LEARNER_CMD);
|
||||
|
@ -339,6 +339,16 @@ int ObLogHandler::set_initial_member_list(const common::ObMemberList &member_lis
|
||||
return palf_handle_.set_initial_member_list(member_list, paxos_replica_num, learner_list);
|
||||
}
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
int ObLogHandler::set_initial_member_list(const common::ObMemberList &member_list,
|
||||
const common::ObMember &arb_member,
|
||||
const int64_t paxos_replica_num,
|
||||
const common::GlobalLearnerList &learner_list)
|
||||
{
|
||||
RLockGuard guard(lock_);
|
||||
return palf_handle_.set_initial_member_list(member_list, arb_member, paxos_replica_num, learner_list);
|
||||
}
|
||||
#endif
|
||||
|
||||
int ObLogHandler::set_election_priority(palf::election::ElectionPriority *priority)
|
||||
{
|
||||
@ -949,6 +959,199 @@ int ObLogHandler::switch_acceptor_to_learner(const common::ObMember &member,
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
int ObLogHandler::create_arb_member_(const common::ObMember &arb_member,
|
||||
const int64_t timeout_us)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t conn_timeout_us = MIN(timeout_us, MIN_CONN_TIMEOUT_US);
|
||||
int64_t mode_version = -1;
|
||||
AccessMode access_mode = AccessMode::INVALID_ACCESS_MODE;
|
||||
if (OB_FAIL(get_access_mode(mode_version, access_mode))) {
|
||||
CLOG_LOG(WARN, "get_access_mode failed", KR(ret), K_(id), K(access_mode));
|
||||
} else if (AccessMode::INVALID_ACCESS_MODE == access_mode) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
CLOG_LOG(WARN, "invalid access_mode", KR(ret), K_(id), K(access_mode));
|
||||
} else {
|
||||
share::ObTenantRole::Role role = share::ObTenantRole::Role::PRIMARY_TENANT;
|
||||
if (AccessMode::APPEND != access_mode) {
|
||||
role = share::ObTenantRole::Role::STANDBY_TENANT;
|
||||
}
|
||||
share::ObTenantRole tenant_role(role);
|
||||
share::ObLSID ls_id(id_);
|
||||
obrpc::ObCreateArbArg req;
|
||||
obrpc::ObCreateArbResult resp;
|
||||
if (OB_FAIL(req.init(MTL_ID(), ls_id, tenant_role))) {
|
||||
CLOG_LOG(WARN, "ObCreateArbArg init failed", KR(ret), K_(id), K(arb_member), K(timeout_us));
|
||||
} else if (OB_FAIL(rpc_proxy_->to(arb_member.get_server()).timeout(conn_timeout_us).trace_time(true).
|
||||
max_process_handler_time(timeout_us).by(MTL_ID()).create_arb(req, resp))) {
|
||||
CLOG_LOG(WARN, "create_arb failed", KR(ret), K_(id), K(arb_member), K(timeout_us));
|
||||
} else {
|
||||
CLOG_LOG(INFO, "create_arb success", KR(ret), K_(id), K(arb_member), K(timeout_us));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogHandler::delete_arb_member_(const common::ObMember &arb_member,
|
||||
const int64_t timeout_us)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t conn_timeout_us = MIN(timeout_us, MIN_CONN_TIMEOUT_US);
|
||||
obrpc::ObDeleteArbArg req;
|
||||
obrpc::ObDeleteArbResult resp;
|
||||
share::ObLSID ls_id(id_);
|
||||
if (OB_FAIL(req.init(MTL_ID(), ls_id))) {
|
||||
CLOG_LOG(WARN, "ObDeleteArbArg init failed", KR(ret), K_(id), K(arb_member), K(timeout_us));
|
||||
} else if (OB_FAIL(rpc_proxy_->to(arb_member.get_server()).timeout(conn_timeout_us).trace_time(true).
|
||||
max_process_handler_time(timeout_us).by(MTL_ID()).delete_arb(req, resp))) {
|
||||
CLOG_LOG(WARN, "delete arb member failed", KR(ret), K_(id), K(arb_member), K(timeout_us));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// @desc: add_arbitration_member interface
|
||||
// | 1.add_arbitration_member()
|
||||
// V
|
||||
// [any_member] ----> [2. Sync create_arb_member]
|
||||
// |
|
||||
// [3. Sync LogConfigChangeCmd] -------> [leader]
|
||||
// |
|
||||
// [any_member] <----[5. Sync LogConfigChangeCmdResp] <---- | 4. one_stage_config_change_(ADD_ARB_MEMBER)
|
||||
int ObLogHandler::add_arbitration_member(const common::ObMember &added_member,
|
||||
const int64_t timeout_us)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t begin_ts = ObTimeUtility::current_time();
|
||||
int64_t current_timeout_us = timeout_us;
|
||||
const int64_t abs_timeout_us = common::ObTimeUtility::current_time() + timeout_us / 2;
|
||||
WLockGuardWithTimeout deps_guard(deps_lock_, abs_timeout_us, ret);
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
} else if (OB_FAIL(ret)) {
|
||||
CLOG_LOG(WARN, "get_lock failed", KR(ret), K_(id), K(added_member), K(timeout_us));
|
||||
} else if (is_in_stop_state_) {
|
||||
ret = OB_NOT_RUNNING;
|
||||
} else if (!added_member.is_valid() || timeout_us <= 0) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
CLOG_LOG(WARN, "invalid argument", KR(ret), K_(id), K(added_member), K(timeout_us));
|
||||
} else if (OB_FAIL(create_arb_member_(added_member, current_timeout_us))) {
|
||||
CLOG_LOG(WARN, "create_arb_member_ failed", KR(ret), K_(id), K(added_member), K(current_timeout_us));
|
||||
} else if (FALSE_IT(current_timeout_us -= (ObTimeUtility::current_time() - begin_ts))) {
|
||||
} else if (current_timeout_us <= 0) {
|
||||
ret = OB_TIMEOUT;
|
||||
CLOG_LOG(WARN, "add_arbitration_member tiemout", KR(ret), K_(id), K(added_member), K(timeout_us));
|
||||
} else {
|
||||
common::ObMember dummy_member;
|
||||
LogConfigChangeCmd req(self_, id_, added_member, dummy_member, 0, ADD_ARB_MEMBER_CMD, current_timeout_us);
|
||||
if (OB_FAIL(submit_config_change_cmd_(req))) {
|
||||
CLOG_LOG(WARN, " submit_config_change_cmd failed", KR(ret), K_(id), K(req), K(timeout_us), K(current_timeout_us));
|
||||
} else {
|
||||
CLOG_LOG(INFO, "add_arbitration_member success", KR(ret), K_(id), K(added_member));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// @desc: remove_arbitration_member interface
|
||||
// | 1. remove_arbitration_member()
|
||||
// V
|
||||
// [any_member] -----[2. Sync LogConfigChangeCmd]----> [leader]
|
||||
// |
|
||||
// [4. Sync LogConfigChangeCmdResp] ---- | 3. one_stage_config_change_(REMOVE_ARB_MEMBER)
|
||||
// |
|
||||
// [5. Sync delete_arb_member] ----> [any_member]
|
||||
int ObLogHandler::remove_arbitration_member(const common::ObMember &removed_member,
|
||||
const int64_t timeout_us)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t current_timeout_us = timeout_us;
|
||||
const int64_t begin_ts = ObTimeUtility::current_time();
|
||||
const int64_t abs_timeout_us = common::ObTimeUtility::current_time() + timeout_us / 2;
|
||||
WLockGuardWithTimeout deps_guard(deps_lock_, abs_timeout_us, ret);
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
} else if (OB_FAIL(ret)) {
|
||||
CLOG_LOG(WARN, "get_lock failed", KR(ret), K_(id), K(removed_member), K(timeout_us));
|
||||
} else if (is_in_stop_state_) {
|
||||
ret = OB_NOT_RUNNING;
|
||||
} else if (!removed_member.is_valid() || timeout_us <= 0) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
CLOG_LOG(WARN, "invalid argument", KR(ret), K_(id), K(removed_member), K(timeout_us));
|
||||
} else {
|
||||
common::ObMember dummy_member;
|
||||
LogConfigChangeCmd req(self_, id_, dummy_member, removed_member, 0, REMOVE_ARB_MEMBER_CMD, current_timeout_us);
|
||||
if (OB_FAIL(submit_config_change_cmd_(req))) {
|
||||
CLOG_LOG(WARN, " submit_config_change_cmd failed", KR(ret), K_(id), K(req), K(current_timeout_us));
|
||||
} else if (FALSE_IT(current_timeout_us -= (ObTimeUtility::current_time() - begin_ts))) {
|
||||
} else if (current_timeout_us <= 0) {
|
||||
ret = OB_TIMEOUT;
|
||||
CLOG_LOG(WARN, "add_arbitration_member tiemout", KR(ret), K_(id), K(removed_member), K(timeout_us));
|
||||
} else if (OB_FAIL(delete_arb_member_(removed_member, current_timeout_us))) {
|
||||
CLOG_LOG(WARN, "delete_arb_member_ failed", KR(ret), K_(id), K(removed_member), K(current_timeout_us));
|
||||
} else {
|
||||
CLOG_LOG(INFO, "remove_arbitration_member success", KR(ret), K_(id), K(removed_member));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// @desc: degrade_acceptor_to_learner interface
|
||||
// | 1.degrade_acceptor_to_learner()
|
||||
// V
|
||||
// [leader]
|
||||
int ObLogHandler::degrade_acceptor_to_learner(const palf::LogMemberAckInfoList °rade_servers,
|
||||
const int64_t timeout_us)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t abs_timeout_us = common::ObTimeUtility::current_time() + timeout_us / 2;
|
||||
WLockGuardWithTimeout deps_guard(deps_lock_, abs_timeout_us, ret);
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
} else if (OB_FAIL(ret)) {
|
||||
CLOG_LOG(WARN, "get_lock failed", KR(ret), K_(id), K(degrade_servers), K(timeout_us));
|
||||
} else if (is_in_stop_state_) {
|
||||
ret = OB_NOT_RUNNING;
|
||||
} else if (0 == degrade_servers.count() ||
|
||||
timeout_us <= 0) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
CLOG_LOG(WARN, "invalid argument", KR(ret), K_(id), K(degrade_servers), K(timeout_us));
|
||||
} else if (OB_FAIL(palf_handle_.degrade_acceptor_to_learner(degrade_servers, timeout_us))) {
|
||||
CLOG_LOG(WARN, "degrade_acceptor_to_learner failed", KR(ret), K_(id), K(degrade_servers), K(timeout_us));
|
||||
} else {
|
||||
CLOG_LOG(INFO, "degrade_acceptor_to_learner success", KR(ret), K_(id), K(degrade_servers));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// @desc: upgrade_learner_to_acceptor interface
|
||||
// | 1.upgrade_learner_to_acceptor()
|
||||
// V
|
||||
// [leader]
|
||||
int ObLogHandler::upgrade_learner_to_acceptor(const palf::LogMemberAckInfoList &upgrade_servers,
|
||||
const int64_t timeout_us)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t abs_timeout_us = common::ObTimeUtility::current_time() + timeout_us / 2;
|
||||
WLockGuardWithTimeout deps_guard(deps_lock_, abs_timeout_us, ret);
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
} else if (OB_FAIL(ret)) {
|
||||
CLOG_LOG(WARN, "get_lock failed", KR(ret), K_(id), K(upgrade_servers), K(timeout_us));
|
||||
} else if (is_in_stop_state_) {
|
||||
ret = OB_NOT_RUNNING;
|
||||
} else if (0 == upgrade_servers.count() ||
|
||||
timeout_us <= 0) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
CLOG_LOG(WARN, "invalid argument", KR(ret), K_(id), K(upgrade_servers), K(timeout_us));
|
||||
} else if (OB_FAIL(palf_handle_.upgrade_learner_to_acceptor(upgrade_servers, timeout_us))) {
|
||||
CLOG_LOG(WARN, "upgrade_learner_to_acceptor failed", KR(ret), K_(id), K(upgrade_servers), K(timeout_us));
|
||||
} else {
|
||||
CLOG_LOG(INFO, "upgrade_learner_to_acceptor success", KR(ret), K_(id), K(upgrade_servers));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int ObLogHandler::try_lock_config_change(const int64_t lock_owner, const int64_t timeout_us)
|
||||
|
||||
|
@ -88,6 +88,12 @@ public:
|
||||
virtual int set_initial_member_list(const common::ObMemberList &member_list,
|
||||
const int64_t paxos_replica_num,
|
||||
const common::GlobalLearnerList &learner_list) = 0;
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
virtual int set_initial_member_list(const common::ObMemberList &member_list,
|
||||
const common::ObMember &arb_member,
|
||||
const int64_t paxos_replica_num,
|
||||
const common::GlobalLearnerList &learner_list) = 0;
|
||||
#endif
|
||||
virtual int set_region(const common::ObRegion ®ion) = 0;
|
||||
virtual int set_election_priority(palf::election::ElectionPriority *priority) = 0;
|
||||
virtual int reset_election_priority() = 0;
|
||||
@ -141,6 +147,16 @@ public:
|
||||
virtual int switch_acceptor_to_learner(const common::ObMember &member,
|
||||
const int64_t paxos_replica_num,
|
||||
const int64_t timeout_us) = 0;
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
virtual int add_arbitration_member(const common::ObMember &added_member,
|
||||
const int64_t timeout_us) = 0;
|
||||
virtual int remove_arbitration_member(const common::ObMember &removed_member,
|
||||
const int64_t timeout_us) = 0;
|
||||
virtual int degrade_acceptor_to_learner(const palf::LogMemberAckInfoList °rade_servers,
|
||||
const int64_t timeout_us) = 0;
|
||||
virtual int upgrade_learner_to_acceptor(const palf::LogMemberAckInfoList &upgrade_servers,
|
||||
const int64_t timeout_us) = 0;
|
||||
#endif
|
||||
virtual int try_lock_config_change(const int64_t lock_owner, const int64_t timeout_us) = 0;
|
||||
virtual int unlock_config_change(const int64_t lock_owner, const int64_t timeout_us) = 0;
|
||||
virtual int get_config_change_lock_stat(int64_t &lock_owner, bool &is_locked) = 0;
|
||||
@ -275,6 +291,20 @@ public:
|
||||
int set_initial_member_list(const common::ObMemberList &member_list,
|
||||
const int64_t paxos_replica_num,
|
||||
const common::GlobalLearnerList &learner_list) override final;
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
// @brief set the initial member list of paxos group which contains arbitration replica
|
||||
// @param[in] ObMemberList, the initial member list, do not include arbitration replica
|
||||
// @param[in] ObMember, the arbitration replica
|
||||
// @param[in] int64_t, the paxos relica num(including arbitration replica)
|
||||
// @param[in] GlobalLearnerList, the initial learner list
|
||||
// @retval
|
||||
// return OB_SUCCESS if success
|
||||
// else return other errno
|
||||
int set_initial_member_list(const common::ObMemberList &member_list,
|
||||
const common::ObMember &arb_member,
|
||||
const int64_t paxos_replica_num,
|
||||
const common::GlobalLearnerList &learner_list) override final;
|
||||
#endif
|
||||
int set_region(const common::ObRegion ®ion) override final;
|
||||
int set_election_priority(palf::election::ElectionPriority *priority) override final;
|
||||
int reset_election_priority() override final;
|
||||
@ -518,6 +548,54 @@ public:
|
||||
const int64_t new_replica_num,
|
||||
const int64_t timeout_us) override final;
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
// @brief, add an arbitration member to paxos group
|
||||
// @param[in] common::ObMember &member: arbitration member which will be added
|
||||
// @param[in] const int64_t timeout_us: add member timeout, us
|
||||
// @return
|
||||
// - OB_SUCCESS: add arbitration member successfully
|
||||
// - OB_INVALID_ARGUMENT: invalid argumemt or not supported config change
|
||||
// - OB_TIMEOUT: add arbitration member timeout
|
||||
// - other: bug
|
||||
int add_arbitration_member(const common::ObMember &added_member,
|
||||
const int64_t timeout_us) override final;
|
||||
|
||||
// @brief, remove an arbitration member from paxos group
|
||||
// @param[in] common::ObMember &member: arbitration member which will be removed
|
||||
// @param[in] const int64_t timeout_us: remove member timeout, us
|
||||
// @return
|
||||
// - OB_SUCCESS: remove arbitration member successfully
|
||||
// - OB_INVALID_ARGUMENT: invalid argumemt or not supported config change
|
||||
// - OB_TIMEOUT: remove arbitration member timeout
|
||||
// - other: bug
|
||||
int remove_arbitration_member(const common::ObMember &arb_member,
|
||||
const int64_t timeout_us) override final;
|
||||
// @brief: degrade an acceptor(full replica) to learner(special read only replica) in this cluster
|
||||
// @param[in] const common::ObMemberList &member_list: acceptors will be degraded to learner
|
||||
// @param[in] const int64_t timeout_us
|
||||
// @return
|
||||
// - OB_SUCCESS
|
||||
// - OB_INVALID_ARGUMENT: invalid argument
|
||||
// - OB_TIMEOUT: timeout
|
||||
// - OB_NOT_MASTER: not leader
|
||||
// - OB_EAGAIN: need retry
|
||||
// - OB_OP_NOT_ALLOW: can not do degrade because of pre check fails
|
||||
// if last_ack_ts of any server in LogMemberAckInfoList has changed, can not degrade
|
||||
int degrade_acceptor_to_learner(const palf::LogMemberAckInfoList °rade_servers, const int64_t timeout_us) override final;
|
||||
|
||||
// @brief: upgrade a learner(special read only replica) to acceptor(full replica) in this cluster
|
||||
// @param[in] const common::ObMemberList &learner_list: learners will be upgraded to acceptors
|
||||
// @param[in] const int64_t timeout_us
|
||||
// @return
|
||||
// - OB_SUCCESS
|
||||
// - OB_INVALID_ARGUMENT: invalid argument
|
||||
// - OB_TIMEOUT: timeout
|
||||
// - OB_NOT_MASTER: not leader
|
||||
// - OB_EAGAIN: need retry
|
||||
// - OB_OB_NOT_ALLOW: can not do upgrade because of pre check fails
|
||||
// if lsn of any server in LogMemberAckInfoList is less than match_lsn in palf, can not upgrade
|
||||
int upgrade_learner_to_acceptor(const palf::LogMemberAckInfoList &upgrade_servers, const int64_t timeout_us) override final;
|
||||
#endif
|
||||
|
||||
//---------config change lock related--------//
|
||||
//@brief: try lock config change which will forbidden changing on memberlist
|
||||
@ -611,6 +689,10 @@ private:
|
||||
int submit_config_change_cmd_(const LogConfigChangeCmd &req);
|
||||
int submit_config_change_cmd_(const LogConfigChangeCmd &req,
|
||||
LogConfigChangeCmdResp &resp);
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
int create_arb_member_(const common::ObMember &arb_member, const int64_t timeout_us);
|
||||
int delete_arb_member_(const common::ObMember &arb_member, const int64_t timeout_us);
|
||||
#endif
|
||||
DISALLOW_COPY_AND_ASSIGN(ObLogHandler);
|
||||
private:
|
||||
common::ObAddr self_;
|
||||
|
@ -301,6 +301,33 @@ int ObLogMonitor::add_log_write_stat(const int64_t palf_id, const int64_t log_wr
|
||||
}
|
||||
// =========== PALF Performance Statistic ===========
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
// =========== Arbitration Event Reporting ===========
|
||||
#define ARBSRV_MONITOR_EVENT_FMT_PREFIX "ARB", type_to_string_(event), "TENANT_ID", mtl_id, "LS_ID", palf_id
|
||||
int ObLogMonitor::record_degrade_event(const int64_t palf_id, const char *degraded_list, const char *reasons)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t mtl_id = MTL_ID();
|
||||
const EventType event = EventType::DEGRADE;
|
||||
SERVER_EVENT_ADD_WITH_RETRY(ARBSRV_MONITOR_EVENT_FMT_PREFIX,
|
||||
"DEGRADED LIST", degraded_list,
|
||||
"REASONS", reasons);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogMonitor::record_upgrade_event(const int64_t palf_id, const char *upgraded_list, const char *reasons)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t mtl_id = MTL_ID();
|
||||
const EventType event = EventType::UPGRADE;
|
||||
SERVER_EVENT_ADD_WITH_RETRY(ARBSRV_MONITOR_EVENT_FMT_PREFIX,
|
||||
"UPGRADED LIST", upgraded_list,
|
||||
"REASONS", reasons);
|
||||
return ret;
|
||||
}
|
||||
#undef ARBSRV_MONITOR_EVENT_FMT_PREFIX
|
||||
// =========== Arbitration Event Reporting ===========
|
||||
#endif
|
||||
|
||||
#undef LOG_MONITOR_EVENT_FMT_PREFIX
|
||||
} // end namespace logservice
|
||||
|
@ -13,6 +13,9 @@
|
||||
#ifndef OCEANBASE_LOGSERVICE_OB_LOG_MONITOR_H_
|
||||
#define OCEANBASE_LOGSERVICE_OB_LOG_MONITOR_H_
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
#include "logservice/ob_arbitration_service.h"
|
||||
#endif
|
||||
#include "palf/palf_callback.h"
|
||||
|
||||
namespace oceanbase
|
||||
@ -21,6 +24,9 @@ namespace logservice
|
||||
{
|
||||
|
||||
class ObLogMonitor : public palf::PalfMonitorCb
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
, public IObArbitrationMonitor
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
ObLogMonitor() { }
|
||||
@ -79,6 +85,13 @@ public:
|
||||
// =========== PALF Performance Statistic ===========
|
||||
int add_log_write_stat(const int64_t palf_id, const int64_t log_write_size) override final;
|
||||
// =========== PALF Performance Statistic ===========
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
public:
|
||||
// =========== Arbitration Event Reporting ===========
|
||||
int record_degrade_event(const int64_t palf_id, const char *degraded_list, const char *reasons) override final;
|
||||
int record_upgrade_event(const int64_t palf_id, const char *upgraded_list, const char *reasons) override final;
|
||||
// =========== Arbitration Event Reporting ===========
|
||||
#endif
|
||||
private:
|
||||
enum EventType
|
||||
{
|
||||
|
@ -59,6 +59,9 @@ ObLogService::ObLogService() :
|
||||
ls_adapter_(),
|
||||
rpc_proxy_(),
|
||||
reporter_(),
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
arb_service_(),
|
||||
#endif
|
||||
restore_service_(),
|
||||
flashback_service_(),
|
||||
monitor_()
|
||||
@ -127,6 +130,10 @@ int ObLogService::start()
|
||||
CLOG_LOG(WARN, "failed to start cdc_service_", K(ret));
|
||||
} else if (OB_FAIL(restore_service_.start())) {
|
||||
CLOG_LOG(WARN, "failed to start restore_service_", K(ret));
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
} else if (OB_FAIL(arb_service_.start())) {
|
||||
CLOG_LOG(WARN, "failed to start arb_service_", K(ret));
|
||||
#endif
|
||||
} else {
|
||||
is_running_ = true;
|
||||
FLOG_INFO("ObLogService is started");
|
||||
@ -143,6 +150,9 @@ void ObLogService::stop()
|
||||
(void)role_change_service_.stop();
|
||||
(void)cdc_service_.stop();
|
||||
(void)restore_service_.stop();
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
(void)arb_service_.stop();
|
||||
#endif
|
||||
FLOG_INFO("ObLogService is stopped");
|
||||
}
|
||||
|
||||
@ -153,6 +163,9 @@ void ObLogService::wait()
|
||||
role_change_service_.wait();
|
||||
cdc_service_.wait();
|
||||
restore_service_.wait();
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
arb_service_.wait();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ObLogService::destroy()
|
||||
@ -167,6 +180,9 @@ void ObLogService::destroy()
|
||||
rpc_proxy_.destroy();
|
||||
reporter_.destroy();
|
||||
restore_service_.destroy();
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
arb_service_.destroy();
|
||||
#endif
|
||||
flashback_service_.destroy();
|
||||
if (NULL != palf_env_) {
|
||||
PalfEnv::destroy_palf_env(palf_env_);
|
||||
@ -250,6 +266,10 @@ int ObLogService::init(const PalfOptions &options,
|
||||
CLOG_LOG(WARN, "failed to init cdc_service_", K(ret));
|
||||
} else if (OB_FAIL(restore_service_.init(transport, ls_service, this))) {
|
||||
CLOG_LOG(WARN, "failed to init restore_service_", K(ret));
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
} else if (OB_FAIL(arb_service_.init(self, palf_env_, &rpc_proxy_, net_keepalive_adapter, &monitor_))) {
|
||||
CLOG_LOG(WARN, "failed to init arb_service_", K(ret), K(self), KP(palf_env_));
|
||||
#endif
|
||||
} else if (OB_FAIL(flashback_service_.init(self, &location_adapter_, &rpc_proxy_, sql_proxy))) {
|
||||
CLOG_LOG(WARN, "failed to init flashback_service_", K(ret));
|
||||
} else {
|
||||
@ -720,6 +740,22 @@ int ObLogService::diagnose_apply(const share::ObLSID &id,
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
int ObLogService::diagnose_arb_srv(const share::ObLSID &id,
|
||||
LogArbSrvDiagnoseInfo &diagnose_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
CLOG_LOG(WARN, "log_service is not inited", K(ret));
|
||||
} else if (OB_FAIL(arb_service_.diagnose(id, diagnose_info))) {
|
||||
CLOG_LOG(WARN, "arb_service_ diagnose failed", K(ret), K(id));
|
||||
} else {
|
||||
// do nothing
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int ObLogService::get_io_start_time(int64_t &last_working_time)
|
||||
{
|
||||
|
@ -25,7 +25,11 @@
|
||||
#include "rcservice/ob_role_change_service.h"
|
||||
#include "restoreservice/ob_log_restore_service.h" // ObLogRestoreService
|
||||
#include "replayservice/ob_log_replay_service.h"
|
||||
#ifndef OB_BUILD_ARBITRATION
|
||||
#include "ob_net_keepalive_adapter.h"
|
||||
#else
|
||||
#include "logservice/ob_arbitration_service.h"
|
||||
#endif
|
||||
#include "ob_reporter_adapter.h"
|
||||
#include "ob_ls_adapter.h"
|
||||
#include "ob_location_adapter.h"
|
||||
@ -200,6 +204,9 @@ public:
|
||||
int diagnose_role_change(RCDiagnoseInfo &diagnose_info);
|
||||
int diagnose_replay(const share::ObLSID &id, ReplayDiagnoseInfo &diagnose_info);
|
||||
int diagnose_apply(const share::ObLSID &id, ApplyDiagnoseInfo &diagnose_info);
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
int diagnose_arb_srv(const share::ObLSID &id, LogArbSrvDiagnoseInfo &diagnose_info);
|
||||
#endif
|
||||
int get_io_start_time(int64_t &last_working_time);
|
||||
int check_disk_space_enough(bool &is_disk_enough);
|
||||
|
||||
@ -209,6 +216,9 @@ public:
|
||||
cdc::ObCdcService *get_cdc_service() { return &cdc_service_; }
|
||||
ObLogRestoreService *get_log_restore_service() { return &restore_service_; }
|
||||
ObLogReplayService *get_log_replay_service() { return &replay_service_; }
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
ObArbitrationService *get_arbitration_service() { return &arb_service_; }
|
||||
#endif
|
||||
obrpc::ObLogServiceRpcProxy *get_rpc_proxy() { return &rpc_proxy_; }
|
||||
ObLogFlashbackService *get_flashback_service() { return &flashback_service_; }
|
||||
private:
|
||||
@ -235,6 +245,9 @@ private:
|
||||
obrpc::ObLogServiceRpcProxy rpc_proxy_;
|
||||
ObLogReporterAdapter reporter_;
|
||||
cdc::ObCdcService cdc_service_;
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
ObArbitrationService arb_service_;
|
||||
#endif
|
||||
ObLogRestoreService restore_service_;
|
||||
ObLogFlashbackService flashback_service_;
|
||||
ObLogMonitor monitor_;
|
||||
|
@ -485,6 +485,15 @@ uint64_t ElectionImpl::get_ls_biggest_min_cluster_version_ever_seen_() const
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t ls_biggest_min_cluster_version_ever_seen = 0;
|
||||
if (observer::ObServer::get_instance().is_arbitration_mode()) {
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
if (CLUSTER_CURRENT_VERSION < ls_biggest_min_cluster_version_ever_seen_.version_) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_NONE(ERROR, "ls_biggest_min_cluster_version_ever_seen_ greater than arb binary version");
|
||||
} else if (ls_biggest_min_cluster_version_ever_seen_.version_ == 0) {
|
||||
LOG_NONE(WARN, "ls_biggest_min_cluster_version_ever_seen_ not setted yet");
|
||||
}
|
||||
ls_biggest_min_cluster_version_ever_seen = ls_biggest_min_cluster_version_ever_seen_.version_;
|
||||
#endif
|
||||
} else {
|
||||
ls_biggest_min_cluster_version_ever_seen = std::max(GET_MIN_CLUSTER_VERSION(),
|
||||
ls_biggest_min_cluster_version_ever_seen_.version_);
|
||||
|
@ -1008,6 +1008,21 @@ int LogEngine::submit_config_change_pre_check_req(const common::ObAddr &server,
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
int LogEngine::sync_get_arb_member_info(const common::ObAddr &server,
|
||||
const int64_t timeout_us,
|
||||
LogGetArbMemberInfoResp &resp)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
} else {
|
||||
ret = log_net_service_.submit_get_arb_member_info_req(
|
||||
server, timeout_us, resp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int LogEngine::submit_fetch_log_req(const ObAddr &server,
|
||||
const FetchLogType fetch_type,
|
||||
|
@ -330,6 +330,11 @@ public:
|
||||
const bool need_purge_throttling,
|
||||
const int64_t timeout_us,
|
||||
LogGetMCStResp &resp);
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
virtual int sync_get_arb_member_info(const common::ObAddr &server,
|
||||
const int64_t timeout_us,
|
||||
LogGetArbMemberInfoResp &resp);
|
||||
#endif
|
||||
|
||||
// @brief: this function used to submit fetch log request to sepcified server
|
||||
// @param[in] server: the address of remote server(data source)
|
||||
|
@ -274,6 +274,22 @@ int LogNetService::submit_config_change_pre_check_req(
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
int LogNetService::submit_get_arb_member_info_req(
|
||||
const common::ObAddr &server,
|
||||
const int64_t timeout_us,
|
||||
LogGetArbMemberInfoResp &resp)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
} else {
|
||||
LogGetArbMemberInfoReq req(palf_id_);
|
||||
ret = post_sync_request_to_server_(server, timeout_us, req, resp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int LogNetService::submit_register_parent_req(
|
||||
const common::ObAddr &server,
|
||||
|
@ -199,6 +199,12 @@ public:
|
||||
const int64_t timeout_us,
|
||||
LogGetMCStResp &resp);
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
int submit_get_arb_member_info_req(
|
||||
const common::ObAddr &server,
|
||||
const int64_t timeout_us,
|
||||
LogGetArbMemberInfoResp &resp);
|
||||
#endif
|
||||
|
||||
int submit_register_parent_req(
|
||||
const common::ObAddr &server,
|
||||
|
@ -772,6 +772,88 @@ void LogGetStatResp::reset()
|
||||
OB_SERIALIZE_MEMBER(LogGetStatResp, max_scn_, end_lsn_);
|
||||
// ================= LogGetStatResp end ================
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
LogGetArbMemberInfoReq::LogGetArbMemberInfoReq()
|
||||
: palf_id_(-1)
|
||||
{}
|
||||
|
||||
LogGetArbMemberInfoReq::LogGetArbMemberInfoReq(const int64_t palf_id)
|
||||
: palf_id_(palf_id)
|
||||
{}
|
||||
|
||||
LogGetArbMemberInfoReq::~LogGetArbMemberInfoReq()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
bool LogGetArbMemberInfoReq::is_valid() const
|
||||
{
|
||||
return is_valid_palf_id(palf_id_);
|
||||
}
|
||||
|
||||
void LogGetArbMemberInfoReq::reset()
|
||||
{
|
||||
palf_id_ = -1;
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(LogGetArbMemberInfoReq, palf_id_);
|
||||
|
||||
LogGetArbMemberInfoResp::LogGetArbMemberInfoResp()
|
||||
: arb_member_info_()
|
||||
{}
|
||||
|
||||
LogGetArbMemberInfoResp::~LogGetArbMemberInfoResp()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
bool LogGetArbMemberInfoResp::is_valid() const
|
||||
{
|
||||
return arb_member_info_.is_valid();
|
||||
}
|
||||
|
||||
void LogGetArbMemberInfoResp::reset()
|
||||
{
|
||||
arb_member_info_.reset();
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(LogGetArbMemberInfoResp, arb_member_info_);
|
||||
|
||||
ArbMemberInfo::ArbMemberInfo()
|
||||
: palf_id_(INVALID_PALF_ID),
|
||||
arb_server_(),
|
||||
log_proposal_id_(INVALID_PROPOSAL_ID),
|
||||
config_version_(),
|
||||
mode_version_(INVALID_PROPOSAL_ID),
|
||||
access_mode_(AccessMode::INVALID_ACCESS_MODE),
|
||||
paxos_member_list_(),
|
||||
paxos_replica_num_(-1),
|
||||
arbitration_member_(),
|
||||
degraded_list_() { }
|
||||
|
||||
bool ArbMemberInfo::is_valid() const
|
||||
{
|
||||
return (arb_server_.is_valid() && palf_id_ != INVALID_PALF_ID);
|
||||
}
|
||||
|
||||
void ArbMemberInfo::reset()
|
||||
{
|
||||
palf_id_ = INVALID_PALF_ID;
|
||||
arb_server_.reset();
|
||||
log_proposal_id_ = INVALID_PROPOSAL_ID;
|
||||
config_version_.reset();
|
||||
mode_version_ = INVALID_PROPOSAL_ID;
|
||||
access_mode_ = AccessMode::INVALID_ACCESS_MODE;
|
||||
paxos_member_list_.reset();
|
||||
paxos_replica_num_ = -1;
|
||||
arbitration_member_.reset();
|
||||
degraded_list_.reset();
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(ArbMemberInfo, palf_id_, arb_server_, log_proposal_id_,
|
||||
config_version_, mode_version_, access_mode_, paxos_member_list_,
|
||||
paxos_replica_num_, arbitration_member_, degraded_list_);
|
||||
#endif
|
||||
|
||||
LogBatchFetchResp::LogBatchFetchResp()
|
||||
: msg_proposal_id_(INVALID_PROPOSAL_ID),
|
||||
|
@ -446,6 +446,67 @@ public:
|
||||
LSN end_lsn_;
|
||||
};
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
struct LogGetArbMemberInfoReq {
|
||||
OB_UNIS_VERSION(1);
|
||||
public:
|
||||
LogGetArbMemberInfoReq();
|
||||
LogGetArbMemberInfoReq(const int64_t palf_id);
|
||||
~LogGetArbMemberInfoReq();
|
||||
bool is_valid() const;
|
||||
void reset();
|
||||
TO_STRING_KV(K_(palf_id));
|
||||
int64_t palf_id_;
|
||||
};
|
||||
|
||||
struct ArbMemberInfo {
|
||||
OB_UNIS_VERSION(1);
|
||||
public:
|
||||
ArbMemberInfo();
|
||||
~ArbMemberInfo() { reset(); }
|
||||
bool is_valid() const;
|
||||
void reset();
|
||||
ArbMemberInfo &operator=(const ArbMemberInfo &other)
|
||||
{
|
||||
this->palf_id_ = other.palf_id_;
|
||||
this->arb_server_ = other.arb_server_;
|
||||
this->log_proposal_id_ = other.log_proposal_id_;
|
||||
this->config_version_ = other.config_version_;
|
||||
this->mode_version_ = other.mode_version_;
|
||||
this->access_mode_ = other.access_mode_;
|
||||
this->paxos_member_list_ = other.paxos_member_list_;
|
||||
this->paxos_replica_num_ = other.paxos_replica_num_;
|
||||
this->arbitration_member_ = other.arbitration_member_;
|
||||
this->degraded_list_ = other.degraded_list_;
|
||||
return *this;
|
||||
}
|
||||
TO_STRING_KV(K_(palf_id), K_(arb_server), K_(log_proposal_id), K_(config_version), K_(mode_version),
|
||||
K_(access_mode), K_(paxos_member_list), K_(paxos_replica_num), K_(arbitration_member),
|
||||
K_(degraded_list));
|
||||
public:
|
||||
int64_t palf_id_;
|
||||
common::ObAddr arb_server_;
|
||||
int64_t log_proposal_id_;
|
||||
LogConfigVersion config_version_;
|
||||
int64_t mode_version_;
|
||||
AccessMode access_mode_;
|
||||
ObMemberList paxos_member_list_;
|
||||
int64_t paxos_replica_num_;
|
||||
common::ObMember arbitration_member_;
|
||||
common::GlobalLearnerList degraded_list_;
|
||||
};
|
||||
|
||||
struct LogGetArbMemberInfoResp {
|
||||
OB_UNIS_VERSION(1);
|
||||
public:
|
||||
LogGetArbMemberInfoResp();
|
||||
~LogGetArbMemberInfoResp();
|
||||
bool is_valid() const;
|
||||
void reset();
|
||||
TO_STRING_KV(K_(arb_member_info));
|
||||
ArbMemberInfo arb_member_info_;
|
||||
};
|
||||
#endif
|
||||
|
||||
} // end namespace palf
|
||||
} // end namespace oceanbase
|
||||
|
@ -520,6 +520,29 @@ int LogRequestHandler::handle_sync_request<LogGetStatReq, LogGetStatResp>(
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
template <>
|
||||
int LogRequestHandler::handle_sync_request<LogGetArbMemberInfoReq, LogGetArbMemberInfoResp>(
|
||||
const int64_t palf_id,
|
||||
const ObAddr &server,
|
||||
const LogGetArbMemberInfoReq &req,
|
||||
LogGetArbMemberInfoResp &resp)
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
IPalfHandleImplGuard guard;
|
||||
if (false == is_valid_palf_id(palf_id) || false == req.is_valid()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
PALF_LOG(ERROR, "Invalid argument!!!", K(ret), K(palf_id), K(req), KPC(palf_env_impl_));
|
||||
} else if (OB_FAIL(palf_env_impl_->get_palf_handle_impl(palf_id, guard))) {
|
||||
PALF_LOG(WARN, "PalfEnvImpl get_palf_handle_impl failed", K(ret), K(palf_id), K(server));
|
||||
} else if (OB_FAIL(guard.get_palf_handle_impl()->get_arb_member_info(resp.arb_member_info_))) {
|
||||
PALF_LOG(WARN, "get_arb_member_info failed", K(ret), K(palf_id), K(server));
|
||||
} else {
|
||||
PALF_LOG(INFO, "get_arb_member_info succ", K(ret), K(palf_id), K(server), K(req), K(resp));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // end namespace palf
|
||||
} // end namespace oceanbase
|
||||
|
@ -149,6 +149,13 @@ DEFINE_SYNC_RPC_PROCESSOR(LogGetStatP,
|
||||
LogGetStatResp,
|
||||
obrpc::OB_LOG_GET_STAT);
|
||||
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
DEFINE_SYNC_RPC_PROCESSOR(ObRpcGetArbMemberInfoP,
|
||||
obrpc::LogRpcProxyV2,
|
||||
LogGetArbMemberInfoReq,
|
||||
LogGetArbMemberInfoResp,
|
||||
obrpc::OB_LOG_GET_ARB_MEMBER_INFO);
|
||||
#endif
|
||||
} // end namespace palf
|
||||
} // end namespace oceanbase
|
||||
|
||||
|
@ -112,5 +112,10 @@ DEFINE_SYNC_RPC_PROXY_POST_FUNCTION(get_mc_st,
|
||||
DEFINE_SYNC_RPC_PROXY_POST_FUNCTION(get_log_stat,
|
||||
LogGetStatReq,
|
||||
LogGetStatResp);
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
DEFINE_SYNC_RPC_PROXY_POST_FUNCTION(get_remote_arb_member_info,
|
||||
LogGetArbMemberInfoReq,
|
||||
LogGetArbMemberInfoResp);
|
||||
#endif
|
||||
} // end namespace obrpc
|
||||
} // end namespace oceanbase
|
||||
|
@ -105,6 +105,13 @@ public:
|
||||
LogGetStatReq,
|
||||
LogGetStatResp,
|
||||
OB_LOG_GET_STAT);
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
DECLARE_SYNC_RPC_PROXY_POST_FUNCTION(PR5,
|
||||
get_remote_arb_member_info,
|
||||
LogGetArbMemberInfoReq,
|
||||
LogGetArbMemberInfoResp,
|
||||
OB_LOG_GET_ARB_MEMBER_INFO);
|
||||
#endif
|
||||
};
|
||||
} // end namespace obrpc
|
||||
} // end namespace oceanbase
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user