Skip to content

Commit 6e105d7

Browse files
committed
Merge 10.1 into 10.2
2 parents 00ab154 + 9505c96 commit 6e105d7

File tree

10 files changed

+141
-137
lines changed

10 files changed

+141
-137
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ pcre/pcre_chartables.c
9797
pcre/pcregrep
9898
pcre/pcretest
9999
pcre/test*grep
100+
plugin/aws_key_management/aws-sdk-cpp
101+
plugin/aws_key_management/aws_sdk_cpp
102+
plugin/aws_key_management/aws_sdk_cpp-prefix
100103
scripts/comp_sql
101104
scripts/make_binary_distribution
102105
scripts/msql2mysql

plugin/aws_key_management/CMakeLists.txt

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ ENDIF()
5151
FIND_LIBRARY(AWS_CPP_SDK_CORE NAMES aws-cpp-sdk-core PATH_SUFFIXES "${SDK_INSTALL_BINARY_PREFIX}")
5252
FIND_LIBRARY(AWS_CPP_SDK_KMS NAMES aws-cpp-sdk-kms PATH_SUFFIXES "${SDK_INSTALL_BINARY_PREFIX}")
5353
SET(CMAKE_REQUIRED_FLAGS ${CXX11_FLAGS})
54-
CHECK_INCLUDE_FILE_CXX(aws/kms/KMSClient.h HAVE_AWS_HEADERS)
54+
FIND_PATH(AWS_CPP_SDK_INCLUDE_DIR NAMES aws/kms/KMSClient.h)
5555

56-
IF(AWS_CPP_SDK_CORE AND AWS_CPP_SDK_KMS AND HAVE_AWS_HEADERS)
57-
# AWS C++ SDK installed
56+
IF(AWS_CPP_SDK_CORE AND AWS_CPP_SDK_KMS AND AWS_CPP_SDK_INCLUDE_DIR)
57+
# AWS C++ SDK installed
58+
INCLUDE_DIRECTORIES(${AWS_CPP_SDK_INCLUDE_DIR})
5859
SET(AWS_SDK_LIBS ${AWS_CPP_SDK_CORE} ${AWS_CPP_SDK_KMS})
5960
ELSE()
6061
OPTION(AWS_SDK_EXTERNAL_PROJECT "Allow download and build AWS C++ SDK" OFF)
@@ -95,14 +96,26 @@ ELSE()
9596
SET(EXTRA_SDK_CMAKE_FLAGS ${EXTRA_SDK_CMAKE_FLAGS} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
9697
ENDIF()
9798

99+
SET(byproducts )
100+
# We do not need to build the whole SDK , just 2 of its libs
101+
set(AWS_SDK_LIBS aws-cpp-sdk-core aws-cpp-sdk-kms)
102+
FOREACH(lib ${AWS_SDK_LIBS})
103+
ADD_LIBRARY(${lib} STATIC IMPORTED GLOBAL)
104+
ADD_DEPENDENCIES(${lib} aws_sdk_cpp)
105+
SET(loc "${CMAKE_CURRENT_BINARY_DIR}/aws_sdk_cpp/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
106+
SET(byproducts ${byproducts} BUILD_BYPRODUCTS ${loc})
107+
SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LOCATION ${loc})
108+
ENDFOREACH()
109+
98110
SET(AWS_SDK_PATCH_COMMAND )
99111
ExternalProject_Add(
100112
aws_sdk_cpp
101113
GIT_REPOSITORY "https://github.com/awslabs/aws-sdk-cpp.git"
102114
GIT_TAG "1.0.8"
103115
UPDATE_COMMAND ""
104-
SOURCE_DIR "${CMAKE_BINARY_DIR}/aws-sdk-cpp"
105-
CMAKE_ARGS
116+
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/aws-sdk-cpp"
117+
${byproducts}
118+
CMAKE_ARGS
106119
-DBUILD_ONLY=kms
107120
-DBUILD_SHARED_LIBS=OFF
108121
-DFORCE_SHARED_CRT=OFF
@@ -111,34 +124,29 @@ ELSE()
111124
"-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} ${PIC_FLAG}"
112125
"-DCMAKE_CXX_FLAGS_MINSIZEREL=${CMAKE_CXX_FLAGS_MINSIZEREL} ${PIC_FLAG}"
113126
${EXTRA_SDK_CMAKE_FLAGS}
114-
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/aws_sdk_cpp
127+
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/aws_sdk_cpp
115128
TEST_COMMAND ""
116129
)
117130
SET_TARGET_PROPERTIES(aws_sdk_cpp PROPERTIES EXCLUDE_FROM_ALL TRUE)
118-
# We do not need to build the whole SDK , just 2 of its libs
119-
set(AWS_SDK_LIBS aws-cpp-sdk-core aws-cpp-sdk-kms)
120-
FOREACH(lib ${AWS_SDK_LIBS})
121-
ADD_LIBRARY(${lib} STATIC IMPORTED GLOBAL)
122-
ADD_DEPENDENCIES(${lib} aws_sdk_cpp)
123-
SET(loc "${CMAKE_BINARY_DIR}/aws_sdk_cpp/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
124-
SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LOCATION ${loc})
125-
IF(WIN32)
126-
SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "bcrypt;winhttp;wininet;userenv")
127-
ELSE()
128-
SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${SSL_LIBRARIES};${CURL_LIBRARIES};${UUID_LIBRARIES}")
129-
ENDIF()
130-
ENDFOREACH()
131131

132132
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
133133
# Need whole-archive , otherwise static libraries are not linked
134134
SET(AWS_SDK_LIBS -Wl,--whole-archive ${AWS_SDK_LIBS} -Wl,--no-whole-archive)
135135
ENDIF()
136136
SET_TARGET_PROPERTIES(aws_sdk_cpp PROPERTIES EXCLUDE_FROM_ALL TRUE)
137-
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/aws_sdk_cpp/include)
137+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/aws_sdk_cpp/include)
138138
ENDIF()
139139

140140
ADD_DEFINITIONS(${SSL_DEFINES}) # Need to know whether openssl should be initialized
141141
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_FLAGS}")
142142
MYSQL_ADD_PLUGIN(aws_key_management aws_key_management_plugin.cc
143143
LINK_LIBRARIES ${AWS_SDK_LIBS}
144144
COMPONENT aws-key-management)
145+
146+
IF(WIN32)
147+
SET(AWS_CPP_SDK_DEPENDENCIES bcrypt winhttp wininet userenv version)
148+
ELSE()
149+
SET(AWS_CPP_SDK_DEPENDENCIES ${SSL_LIBRARIES} ${CURL_LIBRARIES} ${UUID_LIBRARIES})
150+
ENDIF()
151+
152+
TARGET_LINK_LIBRARIES(aws_key_management ${AWS_SDK_LIBS} ${AWS_CPP_SDK_DEPENDENCIES})

storage/innobase/btr/btr0scrub.cc

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ btr_scrub_lock_dict_func(ulint space_id, bool lock_to_close_table,
136136
* if we don't lock to close a table, we check if space
137137
* is closing, and then instead give up
138138
*/
139-
if (lock_to_close_table == false) {
140-
fil_space_t* space = fil_space_acquire(space_id);
141-
if (!space || space->stop_new_ops) {
142-
if (space) {
143-
fil_space_release(space);
144-
}
139+
if (lock_to_close_table) {
140+
} else if (fil_space_t* space = fil_space_acquire(space_id)) {
141+
bool stopping = space->is_stopping();
142+
fil_space_release(space);
143+
if (stopping) {
145144
return false;
146145
}
147-
fil_space_release(space);
146+
} else {
147+
return false;
148148
}
149149
os_thread_sleep(250000);
150150

@@ -206,18 +206,15 @@ btr_scrub_table_close_for_thread(
206206
return;
207207
}
208208

209-
fil_space_t* space = fil_space_acquire(scrub_data->space);
210-
211-
/* If tablespace is not marked as stopping perform
212-
the actual close. */
213-
if (space && !space->is_stopping()) {
214-
mutex_enter(&dict_sys->mutex);
215-
/* perform the actual closing */
216-
btr_scrub_table_close(scrub_data->current_table);
217-
mutex_exit(&dict_sys->mutex);
218-
}
219-
220-
if (space) {
209+
if (fil_space_t* space = fil_space_acquire(scrub_data->space)) {
210+
/* If tablespace is not marked as stopping perform
211+
the actual close. */
212+
if (!space->is_stopping()) {
213+
mutex_enter(&dict_sys->mutex);
214+
/* perform the actual closing */
215+
btr_scrub_table_close(scrub_data->current_table);
216+
mutex_exit(&dict_sys->mutex);
217+
}
221218
fil_space_release(space);
222219
}
223220

storage/innobase/buf/buf0buf.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7535,12 +7535,12 @@ buf_page_decrypt_after_read(buf_page_t* bpage)
75357535
return (true);
75367536
}
75377537

7538-
FilSpace space(bpage->id.space());
7538+
FilSpace space(bpage->id.space(), true);
75397539

75407540
/* Page is encrypted if encryption information is found from
75417541
tablespace and page contains used key_version. This is true
75427542
also for pages first compressed and then encrypted. */
7543-
if (!space()->crypt_data) {
7543+
if (!space() || !space()->crypt_data) {
75447544
key_version = 0;
75457545
}
75467546

storage/innobase/fil/fil0fil.cc

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,12 +2268,13 @@ Used by background threads that do not necessarily hold proper locks
22682268
for concurrency control.
22692269
@param[in] id tablespace ID
22702270
@param[in] silent whether to silently ignore missing tablespaces
2271-
@return the tablespace, or NULL if missing or being deleted */
2271+
@param[in] for_io whether to look up the tablespace while performing I/O
2272+
(possibly executing TRUNCATE)
2273+
@return the tablespace
2274+
@retval NULL if missing or being deleted or truncated */
22722275
inline
22732276
fil_space_t*
2274-
fil_space_acquire_low(
2275-
ulint id,
2276-
bool silent)
2277+
fil_space_acquire_low(ulint id, bool silent, bool for_io = false)
22772278
{
22782279
fil_space_t* space;
22792280

@@ -2286,7 +2287,7 @@ fil_space_acquire_low(
22862287
ib::warn() << "Trying to access missing"
22872288
" tablespace " << id;
22882289
}
2289-
} else if (space->stop_new_ops || space->is_being_truncated) {
2290+
} else if (!for_io && space->is_stopping()) {
22902291
space = NULL;
22912292
} else {
22922293
space->n_pending_ops++;
@@ -2301,31 +2302,32 @@ fil_space_acquire_low(
23012302
Used by background threads that do not necessarily hold proper locks
23022303
for concurrency control.
23032304
@param[in] id tablespace ID
2304-
@return the tablespace, or NULL if missing or being deleted */
2305+
@param[in] for_io whether to look up the tablespace while performing I/O
2306+
(possibly executing TRUNCATE)
2307+
@return the tablespace
2308+
@retval NULL if missing or being deleted or truncated */
23052309
fil_space_t*
2306-
fil_space_acquire(
2307-
ulint id)
2310+
fil_space_acquire(ulint id, bool for_io)
23082311
{
2309-
return(fil_space_acquire_low(id, false));
2312+
return(fil_space_acquire_low(id, false, for_io));
23102313
}
23112314

23122315
/** Acquire a tablespace that may not exist.
23132316
Used by background threads that do not necessarily hold proper locks
23142317
for concurrency control.
23152318
@param[in] id tablespace ID
2316-
@return the tablespace, or NULL if missing or being deleted */
2319+
@return the tablespace
2320+
@retval NULL if missing or being deleted */
23172321
fil_space_t*
2318-
fil_space_acquire_silent(
2319-
ulint id)
2322+
fil_space_acquire_silent(ulint id)
23202323
{
23212324
return(fil_space_acquire_low(id, true));
23222325
}
23232326

23242327
/** Release a tablespace acquired with fil_space_acquire().
23252328
@param[in,out] space tablespace to release */
23262329
void
2327-
fil_space_release(
2328-
fil_space_t* space)
2330+
fil_space_release(fil_space_t* space)
23292331
{
23302332
mutex_enter(&fil_system->mutex);
23312333
ut_ad(space->magic_n == FIL_SPACE_MAGIC_N);
@@ -5479,8 +5481,7 @@ fil_flush(
54795481

54805482
if (fil_space_t* space = fil_space_get_by_id(space_id)) {
54815483
if (space->purpose != FIL_TYPE_TEMPORARY
5482-
&& !space->stop_new_ops
5483-
&& !space->is_being_truncated) {
5484+
&& !space->is_stopping()) {
54845485
fil_flush_low(space);
54855486
}
54865487
}
@@ -5524,8 +5525,7 @@ fil_flush_file_spaces(
55245525
space = UT_LIST_GET_NEXT(unflushed_spaces, space)) {
55255526

55265527
if (space->purpose == purpose
5527-
&& !space->stop_new_ops
5528-
&& !space->is_being_truncated) {
5528+
&& !space->is_stopping()) {
55295529

55305530
space_ids[n_space_ids++] = space->id;
55315531
}
@@ -6701,8 +6701,7 @@ If NULL, use the first fil_space_t on fil_system->space_list.
67016701
@return pointer to the next fil_space_t.
67026702
@retval NULL if this was the last*/
67036703
fil_space_t*
6704-
fil_space_next(
6705-
fil_space_t* prev_space)
6704+
fil_space_next(fil_space_t* prev_space)
67066705
{
67076706
fil_space_t* space=prev_space;
67086707

@@ -6725,8 +6724,8 @@ fil_space_next(
67256724
fil_ibd_create(), or dropped, or !tablespace. */
67266725
while (space != NULL
67276726
&& (UT_LIST_GET_LEN(space->chain) == 0
6728-
|| space->stop_new_ops
6729-
|| space->purpose != FIL_TYPE_TABLESPACE)) {
6727+
|| space->is_stopping()
6728+
|| space->purpose != FIL_TYPE_TABLESPACE)) {
67306729
space = UT_LIST_GET_NEXT(space_list, space);
67316730
}
67326731

storage/innobase/include/fil0fil.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -735,27 +735,28 @@ MY_ATTRIBUTE((warn_unused_result));
735735
Used by background threads that do not necessarily hold proper locks
736736
for concurrency control.
737737
@param[in] id tablespace ID
738-
@return the tablespace, or NULL if missing or being deleted */
738+
@param[in] for_io whether to look up the tablespace while performing I/O
739+
(possibly executing TRUNCATE)
740+
@return the tablespace
741+
@retval NULL if missing or being deleted or truncated */
739742
fil_space_t*
740-
fil_space_acquire(
741-
ulint id)
743+
fil_space_acquire(ulint id, bool for_io = false)
742744
MY_ATTRIBUTE((warn_unused_result));
743745

744746
/** Acquire a tablespace that may not exist.
745747
Used by background threads that do not necessarily hold proper locks
746748
for concurrency control.
747749
@param[in] id tablespace ID
748-
@return the tablespace, or NULL if missing or being deleted */
750+
@return the tablespace
751+
@retval NULL if missing or being deleted */
749752
fil_space_t*
750-
fil_space_acquire_silent(
751-
ulint id)
753+
fil_space_acquire_silent(ulint id)
752754
MY_ATTRIBUTE((warn_unused_result));
753755

754756
/** Release a tablespace acquired with fil_space_acquire().
755757
@param[in,out] space tablespace to release */
756758
void
757-
fil_space_release(
758-
fil_space_t* space);
759+
fil_space_release(fil_space_t* space);
759760

760761
/** Return the next fil_space_t.
761762
Once started, the caller must keep calling this until it returns NULL.
@@ -792,17 +793,19 @@ class FilSpace
792793
FilSpace() : m_space(NULL) {}
793794

794795
/** Constructor: Look up the tablespace and increment the
795-
referece count if found.
796-
@param[in] space_id tablespace ID */
797-
explicit FilSpace(ulint space_id)
798-
: m_space(fil_space_acquire(space_id)) {}
796+
reference count if found.
797+
@param[in] space_id tablespace ID
798+
@param[in] for_io whether to look up the tablespace
799+
while performing I/O
800+
(possibly executing TRUNCATE) */
801+
explicit FilSpace(ulint space_id, bool for_io = false)
802+
: m_space(fil_space_acquire(space_id, for_io)) {}
799803

800804
/** Assignment operator: This assumes that fil_space_acquire()
801805
has already been done for the fil_space_t. The caller must
802806
assign NULL if it calls fil_space_release().
803807
@param[in] space tablespace to assign */
804-
class FilSpace& operator=(
805-
fil_space_t* space)
808+
class FilSpace& operator=(fil_space_t* space)
806809
{
807810
/* fil_space_acquire() must have been invoked. */
808811
ut_ad(space == NULL || space->n_pending_ops > 0);

storage/xtradb/btr/btr0scrub.cc

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ btr_scrub_lock_dict_func(ulint space_id, bool lock_to_close_table,
129129
* if we don't lock to close a table, we check if space
130130
* is closing, and then instead give up
131131
*/
132-
if (lock_to_close_table == false) {
133-
fil_space_t* space = fil_space_acquire(space_id);
134-
if (!space || space->stop_new_ops) {
135-
if (space) {
136-
fil_space_release(space);
137-
}
132+
if (lock_to_close_table) {
133+
} else if (fil_space_t* space = fil_space_acquire(space_id)) {
134+
bool stopping = space->is_stopping();
135+
fil_space_release(space);
136+
if (stopping) {
138137
return false;
139138
}
140-
fil_space_release(space);
139+
} else {
140+
return false;
141141
}
142142
os_thread_sleep(250000);
143143

@@ -197,18 +197,15 @@ btr_scrub_table_close_for_thread(
197197
return;
198198
}
199199

200-
fil_space_t* space = fil_space_acquire(scrub_data->space);
201-
202-
/* If tablespace is not marked as stopping perform
203-
the actual close. */
204-
if (space && !space->is_stopping()) {
205-
mutex_enter(&dict_sys->mutex);
206-
/* perform the actual closing */
207-
btr_scrub_table_close(scrub_data->current_table);
208-
mutex_exit(&dict_sys->mutex);
209-
}
210-
211-
if (space) {
200+
if (fil_space_t* space = fil_space_acquire(scrub_data->space)) {
201+
/* If tablespace is not marked as stopping perform
202+
the actual close. */
203+
if (!space->is_stopping()) {
204+
mutex_enter(&dict_sys->mutex);
205+
/* perform the actual closing */
206+
btr_scrub_table_close(scrub_data->current_table);
207+
mutex_exit(&dict_sys->mutex);
208+
}
212209
fil_space_release(space);
213210
}
214211

0 commit comments

Comments
 (0)