Commit 6e105d75 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.1 into 10.2

parents 00ab154d 9505c968
......@@ -97,6 +97,9 @@ pcre/pcre_chartables.c
pcre/pcregrep
pcre/pcretest
pcre/test*grep
plugin/aws_key_management/aws-sdk-cpp
plugin/aws_key_management/aws_sdk_cpp
plugin/aws_key_management/aws_sdk_cpp-prefix
scripts/comp_sql
scripts/make_binary_distribution
scripts/msql2mysql
......
......@@ -51,10 +51,11 @@ ENDIF()
FIND_LIBRARY(AWS_CPP_SDK_CORE NAMES aws-cpp-sdk-core PATH_SUFFIXES "${SDK_INSTALL_BINARY_PREFIX}")
FIND_LIBRARY(AWS_CPP_SDK_KMS NAMES aws-cpp-sdk-kms PATH_SUFFIXES "${SDK_INSTALL_BINARY_PREFIX}")
SET(CMAKE_REQUIRED_FLAGS ${CXX11_FLAGS})
CHECK_INCLUDE_FILE_CXX(aws/kms/KMSClient.h HAVE_AWS_HEADERS)
FIND_PATH(AWS_CPP_SDK_INCLUDE_DIR NAMES aws/kms/KMSClient.h)
IF(AWS_CPP_SDK_CORE AND AWS_CPP_SDK_KMS AND HAVE_AWS_HEADERS)
# AWS C++ SDK installed
IF(AWS_CPP_SDK_CORE AND AWS_CPP_SDK_KMS AND AWS_CPP_SDK_INCLUDE_DIR)
# AWS C++ SDK installed
INCLUDE_DIRECTORIES(${AWS_CPP_SDK_INCLUDE_DIR})
SET(AWS_SDK_LIBS ${AWS_CPP_SDK_CORE} ${AWS_CPP_SDK_KMS})
ELSE()
OPTION(AWS_SDK_EXTERNAL_PROJECT "Allow download and build AWS C++ SDK" OFF)
......@@ -95,14 +96,26 @@ ELSE()
SET(EXTRA_SDK_CMAKE_FLAGS ${EXTRA_SDK_CMAKE_FLAGS} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
ENDIF()
SET(byproducts )
# We do not need to build the whole SDK , just 2 of its libs
set(AWS_SDK_LIBS aws-cpp-sdk-core aws-cpp-sdk-kms)
FOREACH(lib ${AWS_SDK_LIBS})
ADD_LIBRARY(${lib} STATIC IMPORTED GLOBAL)
ADD_DEPENDENCIES(${lib} aws_sdk_cpp)
SET(loc "${CMAKE_CURRENT_BINARY_DIR}/aws_sdk_cpp/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
SET(byproducts ${byproducts} BUILD_BYPRODUCTS ${loc})
SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LOCATION ${loc})
ENDFOREACH()
SET(AWS_SDK_PATCH_COMMAND )
ExternalProject_Add(
aws_sdk_cpp
GIT_REPOSITORY "https://github.com/awslabs/aws-sdk-cpp.git"
GIT_TAG "1.0.8"
UPDATE_COMMAND ""
SOURCE_DIR "${CMAKE_BINARY_DIR}/aws-sdk-cpp"
CMAKE_ARGS
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/aws-sdk-cpp"
${byproducts}
CMAKE_ARGS
-DBUILD_ONLY=kms
-DBUILD_SHARED_LIBS=OFF
-DFORCE_SHARED_CRT=OFF
......@@ -111,30 +124,17 @@ ELSE()
"-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} ${PIC_FLAG}"
"-DCMAKE_CXX_FLAGS_MINSIZEREL=${CMAKE_CXX_FLAGS_MINSIZEREL} ${PIC_FLAG}"
${EXTRA_SDK_CMAKE_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/aws_sdk_cpp
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/aws_sdk_cpp
TEST_COMMAND ""
)
SET_TARGET_PROPERTIES(aws_sdk_cpp PROPERTIES EXCLUDE_FROM_ALL TRUE)
# We do not need to build the whole SDK , just 2 of its libs
set(AWS_SDK_LIBS aws-cpp-sdk-core aws-cpp-sdk-kms)
FOREACH(lib ${AWS_SDK_LIBS})
ADD_LIBRARY(${lib} STATIC IMPORTED GLOBAL)
ADD_DEPENDENCIES(${lib} aws_sdk_cpp)
SET(loc "${CMAKE_BINARY_DIR}/aws_sdk_cpp/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LOCATION ${loc})
IF(WIN32)
SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "bcrypt;winhttp;wininet;userenv")
ELSE()
SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${SSL_LIBRARIES};${CURL_LIBRARIES};${UUID_LIBRARIES}")
ENDIF()
ENDFOREACH()
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
# Need whole-archive , otherwise static libraries are not linked
SET(AWS_SDK_LIBS -Wl,--whole-archive ${AWS_SDK_LIBS} -Wl,--no-whole-archive)
ENDIF()
SET_TARGET_PROPERTIES(aws_sdk_cpp PROPERTIES EXCLUDE_FROM_ALL TRUE)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/aws_sdk_cpp/include)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/aws_sdk_cpp/include)
ENDIF()
ADD_DEFINITIONS(${SSL_DEFINES}) # Need to know whether openssl should be initialized
......@@ -142,3 +142,11 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_FLAGS}")
MYSQL_ADD_PLUGIN(aws_key_management aws_key_management_plugin.cc
LINK_LIBRARIES ${AWS_SDK_LIBS}
COMPONENT aws-key-management)
IF(WIN32)
SET(AWS_CPP_SDK_DEPENDENCIES bcrypt winhttp wininet userenv version)
ELSE()
SET(AWS_CPP_SDK_DEPENDENCIES ${SSL_LIBRARIES} ${CURL_LIBRARIES} ${UUID_LIBRARIES})
ENDIF()
TARGET_LINK_LIBRARIES(aws_key_management ${AWS_SDK_LIBS} ${AWS_CPP_SDK_DEPENDENCIES})
......@@ -136,15 +136,15 @@ btr_scrub_lock_dict_func(ulint space_id, bool lock_to_close_table,
* if we don't lock to close a table, we check if space
* is closing, and then instead give up
*/
if (lock_to_close_table == false) {
fil_space_t* space = fil_space_acquire(space_id);
if (!space || space->stop_new_ops) {
if (space) {
fil_space_release(space);
}
if (lock_to_close_table) {
} else if (fil_space_t* space = fil_space_acquire(space_id)) {
bool stopping = space->is_stopping();
fil_space_release(space);
if (stopping) {
return false;
}
fil_space_release(space);
} else {
return false;
}
os_thread_sleep(250000);
......@@ -206,18 +206,15 @@ btr_scrub_table_close_for_thread(
return;
}
fil_space_t* space = fil_space_acquire(scrub_data->space);
/* If tablespace is not marked as stopping perform
the actual close. */
if (space && !space->is_stopping()) {
mutex_enter(&dict_sys->mutex);
/* perform the actual closing */
btr_scrub_table_close(scrub_data->current_table);
mutex_exit(&dict_sys->mutex);
}
if (space) {
if (fil_space_t* space = fil_space_acquire(scrub_data->space)) {
/* If tablespace is not marked as stopping perform
the actual close. */
if (!space->is_stopping()) {
mutex_enter(&dict_sys->mutex);
/* perform the actual closing */
btr_scrub_table_close(scrub_data->current_table);
mutex_exit(&dict_sys->mutex);
}
fil_space_release(space);
}
......
......@@ -7535,12 +7535,12 @@ buf_page_decrypt_after_read(buf_page_t* bpage)
return (true);
}
FilSpace space(bpage->id.space());
FilSpace space(bpage->id.space(), true);
/* Page is encrypted if encryption information is found from
tablespace and page contains used key_version. This is true
also for pages first compressed and then encrypted. */
if (!space()->crypt_data) {
if (!space() || !space()->crypt_data) {
key_version = 0;
}
......
......@@ -2268,12 +2268,13 @@ Used by background threads that do not necessarily hold proper locks
for concurrency control.
@param[in] id tablespace ID
@param[in] silent whether to silently ignore missing tablespaces
@return the tablespace, or NULL if missing or being deleted */
@param[in] for_io whether to look up the tablespace while performing I/O
(possibly executing TRUNCATE)
@return the tablespace
@retval NULL if missing or being deleted or truncated */
inline
fil_space_t*
fil_space_acquire_low(
ulint id,
bool silent)
fil_space_acquire_low(ulint id, bool silent, bool for_io = false)
{
fil_space_t* space;
......@@ -2286,7 +2287,7 @@ fil_space_acquire_low(
ib::warn() << "Trying to access missing"
" tablespace " << id;
}
} else if (space->stop_new_ops || space->is_being_truncated) {
} else if (!for_io && space->is_stopping()) {
space = NULL;
} else {
space->n_pending_ops++;
......@@ -2301,22 +2302,24 @@ fil_space_acquire_low(
Used by background threads that do not necessarily hold proper locks
for concurrency control.
@param[in] id tablespace ID
@return the tablespace, or NULL if missing or being deleted */
@param[in] for_io whether to look up the tablespace while performing I/O
(possibly executing TRUNCATE)
@return the tablespace
@retval NULL if missing or being deleted or truncated */
fil_space_t*
fil_space_acquire(
ulint id)
fil_space_acquire(ulint id, bool for_io)
{
return(fil_space_acquire_low(id, false));
return(fil_space_acquire_low(id, false, for_io));
}
/** Acquire a tablespace that may not exist.
Used by background threads that do not necessarily hold proper locks
for concurrency control.
@param[in] id tablespace ID
@return the tablespace, or NULL if missing or being deleted */
@return the tablespace
@retval NULL if missing or being deleted */
fil_space_t*
fil_space_acquire_silent(
ulint id)
fil_space_acquire_silent(ulint id)
{
return(fil_space_acquire_low(id, true));
}
......@@ -2324,8 +2327,7 @@ fil_space_acquire_silent(
/** Release a tablespace acquired with fil_space_acquire().
@param[in,out] space tablespace to release */
void
fil_space_release(
fil_space_t* space)
fil_space_release(fil_space_t* space)
{
mutex_enter(&fil_system->mutex);
ut_ad(space->magic_n == FIL_SPACE_MAGIC_N);
......@@ -5479,8 +5481,7 @@ fil_flush(
if (fil_space_t* space = fil_space_get_by_id(space_id)) {
if (space->purpose != FIL_TYPE_TEMPORARY
&& !space->stop_new_ops
&& !space->is_being_truncated) {
&& !space->is_stopping()) {
fil_flush_low(space);
}
}
......@@ -5524,8 +5525,7 @@ fil_flush_file_spaces(
space = UT_LIST_GET_NEXT(unflushed_spaces, space)) {
if (space->purpose == purpose
&& !space->stop_new_ops
&& !space->is_being_truncated) {
&& !space->is_stopping()) {
space_ids[n_space_ids++] = space->id;
}
......@@ -6701,8 +6701,7 @@ If NULL, use the first fil_space_t on fil_system->space_list.
@return pointer to the next fil_space_t.
@retval NULL if this was the last*/
fil_space_t*
fil_space_next(
fil_space_t* prev_space)
fil_space_next(fil_space_t* prev_space)
{
fil_space_t* space=prev_space;
......@@ -6725,8 +6724,8 @@ fil_space_next(
fil_ibd_create(), or dropped, or !tablespace. */
while (space != NULL
&& (UT_LIST_GET_LEN(space->chain) == 0
|| space->stop_new_ops
|| space->purpose != FIL_TYPE_TABLESPACE)) {
|| space->is_stopping()
|| space->purpose != FIL_TYPE_TABLESPACE)) {
space = UT_LIST_GET_NEXT(space_list, space);
}
......
......@@ -735,27 +735,28 @@ MY_ATTRIBUTE((warn_unused_result));
Used by background threads that do not necessarily hold proper locks
for concurrency control.
@param[in] id tablespace ID
@return the tablespace, or NULL if missing or being deleted */
@param[in] for_io whether to look up the tablespace while performing I/O
(possibly executing TRUNCATE)
@return the tablespace
@retval NULL if missing or being deleted or truncated */
fil_space_t*
fil_space_acquire(
ulint id)
fil_space_acquire(ulint id, bool for_io = false)
MY_ATTRIBUTE((warn_unused_result));
/** Acquire a tablespace that may not exist.
Used by background threads that do not necessarily hold proper locks
for concurrency control.
@param[in] id tablespace ID
@return the tablespace, or NULL if missing or being deleted */
@return the tablespace
@retval NULL if missing or being deleted */
fil_space_t*
fil_space_acquire_silent(
ulint id)
fil_space_acquire_silent(ulint id)
MY_ATTRIBUTE((warn_unused_result));
/** Release a tablespace acquired with fil_space_acquire().
@param[in,out] space tablespace to release */
void
fil_space_release(
fil_space_t* space);
fil_space_release(fil_space_t* space);
/** Return the next fil_space_t.
Once started, the caller must keep calling this until it returns NULL.
......@@ -792,17 +793,19 @@ class FilSpace
FilSpace() : m_space(NULL) {}
/** Constructor: Look up the tablespace and increment the
referece count if found.
@param[in] space_id tablespace ID */
explicit FilSpace(ulint space_id)
: m_space(fil_space_acquire(space_id)) {}
reference count if found.
@param[in] space_id tablespace ID
@param[in] for_io whether to look up the tablespace
while performing I/O
(possibly executing TRUNCATE) */
explicit FilSpace(ulint space_id, bool for_io = false)
: m_space(fil_space_acquire(space_id, for_io)) {}
/** Assignment operator: This assumes that fil_space_acquire()
has already been done for the fil_space_t. The caller must
assign NULL if it calls fil_space_release().
@param[in] space tablespace to assign */
class FilSpace& operator=(
fil_space_t* space)
class FilSpace& operator=(fil_space_t* space)
{
/* fil_space_acquire() must have been invoked. */
ut_ad(space == NULL || space->n_pending_ops > 0);
......
......@@ -129,15 +129,15 @@ btr_scrub_lock_dict_func(ulint space_id, bool lock_to_close_table,
* if we don't lock to close a table, we check if space
* is closing, and then instead give up
*/
if (lock_to_close_table == false) {
fil_space_t* space = fil_space_acquire(space_id);
if (!space || space->stop_new_ops) {
if (space) {
fil_space_release(space);
}
if (lock_to_close_table) {
} else if (fil_space_t* space = fil_space_acquire(space_id)) {
bool stopping = space->is_stopping();
fil_space_release(space);
if (stopping) {
return false;
}
fil_space_release(space);
} else {
return false;
}
os_thread_sleep(250000);
......@@ -197,18 +197,15 @@ btr_scrub_table_close_for_thread(
return;
}
fil_space_t* space = fil_space_acquire(scrub_data->space);
/* If tablespace is not marked as stopping perform
the actual close. */
if (space && !space->is_stopping()) {
mutex_enter(&dict_sys->mutex);
/* perform the actual closing */
btr_scrub_table_close(scrub_data->current_table);
mutex_exit(&dict_sys->mutex);
}
if (space) {
if (fil_space_t* space = fil_space_acquire(scrub_data->space)) {
/* If tablespace is not marked as stopping perform
the actual close. */
if (!space->is_stopping()) {
mutex_enter(&dict_sys->mutex);
/* perform the actual closing */
btr_scrub_table_close(scrub_data->current_table);
mutex_exit(&dict_sys->mutex);
}
fil_space_release(space);
}
......
......@@ -6413,14 +6413,12 @@ buf_page_decrypt_after_read(
return (true);
}
fil_space_t* space = fil_space_acquire(bpage->space);
fil_space_crypt_t* crypt_data = space->crypt_data;
fil_space_t* space = fil_space_acquire(bpage->space, true);
/* Page is encrypted if encryption information is found from
tablespace and page contains used key_version. This is true
also for pages first compressed and then encrypted. */
if (!crypt_data) {
if (!space || !space->crypt_data) {
key_version = 0;
}
......@@ -6504,6 +6502,8 @@ buf_page_decrypt_after_read(
}
}
fil_space_release(space);
if (space != NULL) {
fil_space_release(space);
}
return (success);
}
......@@ -6389,16 +6389,12 @@ fil_flush(
{
mutex_enter(&fil_system->mutex);
fil_space_t* space = fil_space_get_by_id(space_id);
if (!space || space->stop_new_ops) {
mutex_exit(&fil_system->mutex);
return;
if (fil_space_t* space = fil_space_get_by_id(space_id)) {
if (!space->is_stopping()) {
fil_flush_low(space);
}
}
fil_flush_low(space);
mutex_exit(&fil_system->mutex);
}
......@@ -6438,8 +6434,7 @@ fil_flush_file_spaces(
space;
space = UT_LIST_GET_NEXT(unflushed_spaces, space)) {
if (space->purpose == purpose && !space->stop_new_ops) {
if (space->purpose == purpose && !space->is_stopping()) {
space_ids[n_space_ids++] = space->id;
}
}
......@@ -7388,12 +7383,13 @@ Used by background threads that do not necessarily hold proper locks
for concurrency control.
@param[in] id tablespace ID
@param[in] silent whether to silently ignore missing tablespaces
@return the tablespace, or NULL if missing or being deleted */
@param[in] for_io whether to look up the tablespace while performing I/O
(possibly executing TRUNCATE)
@return the tablespace
@retval NULL if missing or being deleted or truncated */
inline
fil_space_t*
fil_space_acquire_low(
ulint id,
bool silent)
fil_space_acquire_low(ulint id, bool silent, bool for_io = false)
{
fil_space_t* space;
......@@ -7407,7 +7403,7 @@ fil_space_acquire_low(
" tablespace " ULINTPF ".", id);
ut_error;
}
} else if (space->stop_new_ops) {
} else if (!for_io && space->is_stopping()) {
space = NULL;
} else {
space->n_pending_ops++;
......@@ -7422,22 +7418,24 @@ fil_space_acquire_low(
Used by background threads that do not necessarily hold proper locks
for concurrency control.
@param[in] id tablespace ID
@return the tablespace, or NULL if missing or being deleted */
@param[in] for_io whether to look up the tablespace while performing I/O
(possibly executing TRUNCATE)
@return the tablespace
@retval NULL if missing or being deleted or truncated */
fil_space_t*
fil_space_acquire(
ulint id)
fil_space_acquire(ulint id, bool for_io)
{
return(fil_space_acquire_low(id, false));
return(fil_space_acquire_low(id, false, for_io));
}
/** Acquire a tablespace that may not exist.
Used by background threads that do not necessarily hold proper locks
for concurrency control.
@param[in] id tablespace ID
@return the tablespace, or NULL if missing or being deleted */
@return the tablespace
@retval NULL if missing or being deleted */
fil_space_t*
fil_space_acquire_silent(
ulint id)
fil_space_acquire_silent(ulint id)
{
return(fil_space_acquire_low(id, true));
}
......@@ -7445,8 +7443,7 @@ fil_space_acquire_silent(
/** Release a tablespace acquired with fil_space_acquire().
@param[in,out] space tablespace to release */
void
fil_space_release(
fil_space_t* space)
fil_space_release(fil_space_t* space)
{
mutex_enter(&fil_system->mutex);
ut_ad(space->magic_n == FIL_SPACE_MAGIC_N);
......@@ -7464,8 +7461,7 @@ If NULL, use the first fil_space_t on fil_system->space_list.
@return pointer to the next fil_space_t.
@retval NULL if this was the last*/
fil_space_t*
fil_space_next(
fil_space_t* prev_space)
fil_space_next(fil_space_t* prev_space)
{
fil_space_t* space=prev_space;
......@@ -7488,8 +7484,8 @@ fil_space_next(
fil_ibd_create(), or dropped, or !tablespace. */
while (space != NULL
&& (UT_LIST_GET_LEN(space->chain) == 0
|| space->stop_new_ops
|| space->purpose != FIL_TABLESPACE)) {
|| space->is_stopping()
|| space->purpose != FIL_TABLESPACE)) {
space = UT_LIST_GET_NEXT(space_list, space);
}
......
......@@ -650,27 +650,28 @@ fil_write_flushed_lsn_to_data_files(
Used by background threads that do not necessarily hold proper locks
for concurrency control.
@param[in] id tablespace ID
@return the tablespace, or NULL if missing or being deleted */
@param[in] for_io whether to look up the tablespace while performing I/O
(possibly executing TRUNCATE)
@return the tablespace
@retval NULL if missing or being deleted or truncated */
fil_space_t*
fil_space_acquire(
ulint id)
fil_space_acquire(ulint id, bool for_io = false)
MY_ATTRIBUTE((warn_unused_result));
/** Acquire a tablespace that may not exist.
Used by background threads that do not necessarily hold proper locks
for concurrency control.
@param[in] id tablespace ID
@return the tablespace, or NULL if missing or being deleted */
@return the tablespace
@retval NULL if missing or being deleted */
fil_space_t*
fil_space_acquire_silent(
ulint id)
fil_space_acquire_silent(ulint id)
MY_ATTRIBUTE((warn_unused_result));
/** Release a tablespace acquired with fil_space_acquire().
@param[in,out] space tablespace to release */
void
fil_space_release(
fil_space_t* space);
fil_space_release(fil_space_t* space);
/** Return the next fil_space_t.
Once started, the caller must keep calling this until it returns NULL.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment