Skip to content

Commit a8de8f2

Browse files
committed
Merge 10.2 into 10.3
2 parents e183aec + 42e1815 commit a8de8f2

File tree

122 files changed

+19102
-2557
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+19102
-2557
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pcre/pcre_chartables.c
100100
pcre/pcregrep
101101
pcre/pcretest
102102
pcre/test*grep
103+
plugin/auth_pam/config_auth_pam.h
103104
plugin/aws_key_management/aws-sdk-cpp
104105
plugin/aws_key_management/aws_sdk_cpp
105106
plugin/aws_key_management/aws_sdk_cpp-prefix

extra/mariabackup/xtrabackup.cc

Lines changed: 102 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,17 +2530,24 @@ xb_get_copy_action(const char *dflt)
25302530
return(action);
25312531
}
25322532

2533-
/* TODO: We may tune the behavior (e.g. by fil_aio)*/
25342533

2535-
static
2536-
my_bool
2537-
xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, const char *dest_name=0, ulonglong max_size=ULLONG_MAX)
2534+
/** Copy innodb data file to the specified destination.
2535+
2536+
@param[in] node file node of a tablespace
2537+
@param[in] thread_n thread id, used in the text of diagnostic messages
2538+
@param[in] dest_name destination file name
2539+
@param[in] write_filter write filter to copy data, can be pass-through filter
2540+
for full backup, pages filter for incremental backup, etc.
2541+
2542+
@return FALSE on success and TRUE on error */
2543+
static my_bool xtrabackup_copy_datafile(fil_node_t *node, uint thread_n,
2544+
const char *dest_name,
2545+
const xb_write_filt_t &write_filter)
25382546
{
25392547
char dst_name[FN_REFLEN];
25402548
ds_file_t *dstfile = NULL;
25412549
xb_fil_cur_t cursor;
25422550
xb_fil_cur_result_t res;
2543-
xb_write_filt_t *write_filter = NULL;
25442551
xb_write_filt_ctxt_t write_filt_ctxt;
25452552
const char *action;
25462553
xb_read_filt_t *read_filter;
@@ -2584,7 +2591,7 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, const char *dest_name=
25842591
read_filter = &rf_bitmap;
25852592
}
25862593

2587-
res = xb_fil_cur_open(&cursor, read_filter, node, thread_n,max_size);
2594+
res = xb_fil_cur_open(&cursor, read_filter, node, thread_n, ULLONG_MAX);
25882595
if (res == XB_FIL_CUR_SKIP) {
25892596
goto skip;
25902597
} else if (res == XB_FIL_CUR_ERROR) {
@@ -2595,18 +2602,11 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, const char *dest_name=
25952602
sizeof dst_name - 1);
25962603
dst_name[sizeof dst_name - 1] = '\0';
25972604

2598-
/* Setup the page write filter */
2599-
if (xtrabackup_incremental) {
2600-
write_filter = &wf_incremental;
2601-
} else {
2602-
write_filter = &wf_write_through;
2603-
}
2604-
26052605
memset(&write_filt_ctxt, 0, sizeof(xb_write_filt_ctxt_t));
2606-
ut_a(write_filter->process != NULL);
2606+
ut_a(write_filter.process != NULL);
26072607

2608-
if (write_filter->init != NULL &&
2609-
!write_filter->init(&write_filt_ctxt, dst_name, &cursor)) {
2608+
if (write_filter.init != NULL &&
2609+
!write_filter.init(&write_filt_ctxt, dst_name, &cursor)) {
26102610
msg (thread_n, "mariabackup: error: failed to initialize page write filter.");
26112611
goto error;
26122612
}
@@ -2627,7 +2627,7 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, const char *dest_name=
26272627

26282628
/* The main copy loop */
26292629
while ((res = xb_fil_cur_read(&cursor)) == XB_FIL_CUR_SUCCESS) {
2630-
if (!write_filter->process(&write_filt_ctxt, dstfile)) {
2630+
if (!write_filter.process(&write_filt_ctxt, dstfile)) {
26312631
goto error;
26322632
}
26332633
}
@@ -2636,8 +2636,8 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, const char *dest_name=
26362636
goto error;
26372637
}
26382638

2639-
if (write_filter->finalize
2640-
&& !write_filter->finalize(&write_filt_ctxt, dstfile)) {
2639+
if (write_filter.finalize
2640+
&& !write_filter.finalize(&write_filt_ctxt, dstfile)) {
26412641
goto error;
26422642
}
26432643

@@ -2651,8 +2651,8 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, const char *dest_name=
26512651
if (ds_close(dstfile)) {
26522652
rc = TRUE;
26532653
}
2654-
if (write_filter && write_filter->deinit) {
2655-
write_filter->deinit(&write_filt_ctxt);
2654+
if (write_filter.deinit) {
2655+
write_filter.deinit(&write_filt_ctxt);
26562656
}
26572657
return(rc);
26582658

@@ -2661,8 +2661,8 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, const char *dest_name=
26612661
if (dstfile != NULL) {
26622662
ds_close(dstfile);
26632663
}
2664-
if (write_filter && write_filter->deinit) {
2665-
write_filter->deinit(&write_filt_ctxt);;
2664+
if (write_filter.deinit) {
2665+
write_filter.deinit(&write_filt_ctxt);;
26662666
}
26672667
msg(thread_n, "mariabackup: xtrabackup_copy_datafile() failed.");
26682668
return(TRUE); /*ERROR*/
@@ -2672,8 +2672,8 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, const char *dest_name=
26722672
if (dstfile != NULL) {
26732673
ds_close(dstfile);
26742674
}
2675-
if (write_filter && write_filter->deinit) {
2676-
write_filter->deinit(&write_filt_ctxt);
2675+
if (write_filter.deinit) {
2676+
write_filter.deinit(&write_filt_ctxt);
26772677
}
26782678
msg(thread_n,"Warning: We assume the table was dropped during xtrabackup execution and ignore the tablespace %s", node_name);
26792679
return(FALSE);
@@ -2970,9 +2970,9 @@ DECLARE_THREAD(data_copy_thread_func)(
29702970
while ((node = datafiles_iter_next(ctxt->it)) != NULL) {
29712971
DBUG_MARIABACKUP_EVENT("before_copy", node->space->name);
29722972
/* copy the datafile */
2973-
if(xtrabackup_copy_datafile(node, num)) {
2973+
if (xtrabackup_copy_datafile(node, num, NULL,
2974+
xtrabackup_incremental ? wf_incremental : wf_write_through))
29742975
die("failed to copy datafile.");
2975-
}
29762976

29772977
DBUG_MARIABACKUP_EVENT("after_copy", node->space->name);
29782978

@@ -4570,7 +4570,7 @@ void backup_fix_ddl(void)
45704570
continue;
45714571
std::string dest_name(node->space->name);
45724572
dest_name.append(".new");
4573-
xtrabackup_copy_datafile(node, 0, dest_name.c_str()/*, do_full_copy ? ULONGLONG_MAX:UNIV_PAGE_SIZE */);
4573+
xtrabackup_copy_datafile(node, 0, dest_name.c_str(), wf_write_through);
45744574
}
45754575

45764576
datafiles_iter_free(it);
@@ -5130,22 +5130,66 @@ static void rename_force(const char *from, const char *to) {
51305130
rename_file(from,to);
51315131
}
51325132

5133-
/* During prepare phase, rename ".new" files , that were created in backup_fix_ddl(),
5134-
to ".ibd".*/
5135-
static ibool prepare_handle_new_files(
5136-
const char* data_home_dir, /*!<in: path to datadir */
5137-
const char* db_name, /*!<in: database name */
5138-
const char* file_name, /*!<in: file name with suffix */
5139-
void *)
5140-
{
51415133

5134+
/** During prepare phase, rename ".new" files, that were created in
5135+
backup_fix_ddl() and backup_optimized_ddl_op(), to ".ibd". In the case of
5136+
incremental backup, i.e. of arg argument is set, move ".new" files to
5137+
destination directory and rename them to ".ibd", remove existing ".ibd.delta"
5138+
and ".idb.meta" files in incremental directory to avoid applying delta to
5139+
".ibd" file.
5140+
5141+
@param[in] data_home_dir path to datadir
5142+
@param[in] db_name database name
5143+
@param[in] file_name file name with suffix
5144+
@param[in] arg destination path, used in incremental backup to notify, that
5145+
*.new file must be moved to destibation directory
5146+
5147+
@return true */
5148+
static ibool prepare_handle_new_files(const char *data_home_dir,
5149+
const char *db_name,
5150+
const char *file_name, void *arg)
5151+
{
5152+
const char *dest_dir = static_cast<const char *>(arg);
51425153
std::string src_path = std::string(data_home_dir) + '/' + std::string(db_name) + '/' + file_name;
5143-
std::string dest_path = src_path;
5154+
/* Copy "*.new" files from incremental to base dir for incremental backup */
5155+
std::string dest_path=
5156+
dest_dir ? std::string(dest_dir) + '/' + std::string(db_name) +
5157+
'/' + file_name : src_path;
51445158

51455159
size_t index = dest_path.find(".new");
51465160
DBUG_ASSERT(index != std::string::npos);
5147-
dest_path.replace(index, 4, ".ibd");
5161+
dest_path.replace(index, strlen(".ibd"), ".ibd");
51485162
rename_force(src_path.c_str(),dest_path.c_str());
5163+
5164+
if (dest_dir) {
5165+
/* remove delta and meta files to avoid delta applying for new file */
5166+
index = src_path.find(".new");
5167+
DBUG_ASSERT(index != std::string::npos);
5168+
src_path.replace(index, std::string::npos, ".ibd.delta");
5169+
if (access(src_path.c_str(), R_OK) == 0) {
5170+
msg("Removing %s", src_path.c_str());
5171+
if (my_delete(src_path.c_str(), MYF(MY_WME)))
5172+
die("Can't remove %s, errno %d", src_path.c_str(), errno);
5173+
}
5174+
src_path.replace(index, std::string::npos, ".ibd.meta");
5175+
if (access(src_path.c_str(), R_OK) == 0) {
5176+
msg("Removing %s", src_path.c_str());
5177+
if (my_delete(src_path.c_str(), MYF(MY_WME)))
5178+
die("Can't remove %s, errno %d", src_path.c_str(), errno);
5179+
}
5180+
5181+
/* add table name to the container to avoid it's deletion at the end of
5182+
prepare */
5183+
std::string table_name = std::string(db_name) + '/'
5184+
+ std::string(file_name, file_name + strlen(file_name) - strlen(".new"));
5185+
xb_filter_entry_t *table = static_cast<xb_filter_entry_t *>
5186+
(malloc(sizeof(xb_filter_entry_t) + table_name.size() + 1));
5187+
table->name = ((char*)table) + sizeof(xb_filter_entry_t);
5188+
strcpy(table->name, table_name.c_str());
5189+
HASH_INSERT(xb_filter_entry_t, name_hash, inc_dir_tables_hash,
5190+
ut_fold_string(table->name), table);
5191+
}
5192+
51495193
return TRUE;
51505194
}
51515195

@@ -5182,17 +5226,18 @@ rm_if_not_found(
51825226
return(TRUE);
51835227
}
51845228

5185-
/************************************************************************
5186-
Function enumerates files in datadir (provided by path) which are matched
5229+
/** Function enumerates files in datadir (provided by path) which are matched
51875230
by provided suffix. For each entry callback is called.
5231+
5232+
@param[in] path datadir path
5233+
@param[in] suffix suffix to match against
5234+
@param[in] func callback
5235+
@param[in] func_arg arguments for the above callback
5236+
51885237
@return FALSE if callback for some entry returned FALSE */
5189-
static
5190-
ibool
5191-
xb_process_datadir(
5192-
const char* path, /*!<in: datadir path */
5193-
const char* suffix, /*!<in: suffix to match
5194-
against */
5195-
handle_datadir_entry_func_t func) /*!<in: callback */
5238+
static ibool xb_process_datadir(const char *path, const char *suffix,
5239+
handle_datadir_entry_func_t func,
5240+
void *func_arg = NULL)
51965241
{
51975242
ulint ret;
51985243
char dbpath[OS_FILE_MAX_PATH+1];
@@ -5227,7 +5272,7 @@ xb_process_datadir(
52275272
suffix)) {
52285273
if (!func(
52295274
path, NULL,
5230-
fileinfo.name, NULL))
5275+
fileinfo.name, func_arg))
52315276
{
52325277
os_file_closedir(dbdir);
52335278
return(FALSE);
@@ -5291,7 +5336,7 @@ xb_process_datadir(
52915336
if (!func(
52925337
path,
52935338
dbinfo.name,
5294-
fileinfo.name, NULL))
5339+
fileinfo.name, func_arg))
52955340
{
52965341
os_file_closedir(dbdir);
52975342
os_file_closedir(dir);
@@ -5451,6 +5496,12 @@ static bool xtrabackup_prepare_func(char** argv)
54515496

54525497
fil_path_to_mysql_datadir = ".";
54535498

5499+
ut_ad(xtrabackup_incremental == xtrabackup_incremental_dir);
5500+
if (xtrabackup_incremental) {
5501+
inc_dir_tables_hash = hash_create(1000);
5502+
ut_ad(inc_dir_tables_hash);
5503+
}
5504+
54545505
/* Fix DDL for prepare. Process .del,.ren, and .new files.
54555506
The order in which files are processed, is important
54565507
(see MDEV-18185, MDEV-18201)
@@ -5462,6 +5513,8 @@ static bool xtrabackup_prepare_func(char** argv)
54625513
if (xtrabackup_incremental_dir) {
54635514
xb_process_datadir(xtrabackup_incremental_dir, ".new.meta", prepare_handle_new_files);
54645515
xb_process_datadir(xtrabackup_incremental_dir, ".new.delta", prepare_handle_new_files);
5516+
xb_process_datadir(xtrabackup_incremental_dir, ".new",
5517+
prepare_handle_new_files, (void *)".");
54655518
}
54665519
else {
54675520
xb_process_datadir(".", ".new", prepare_handle_new_files);
@@ -5545,8 +5598,6 @@ static bool xtrabackup_prepare_func(char** argv)
55455598
goto error_cleanup;
55465599
}
55475600

5548-
inc_dir_tables_hash = hash_create(1000);
5549-
55505601
ok = xtrabackup_apply_deltas();
55515602

55525603
xb_data_files_close();

include/my_sys.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,18 +480,19 @@ typedef struct st_io_cache /* Used when caching files */
480480
partial.
481481
*/
482482
int seek_not_done,error;
483-
/* buffer_length is memory size allocated for buffer or write_buffer */
483+
/* length of the buffer used for storing un-encrypted data */
484484
size_t buffer_length;
485485
/* read_length is the same as buffer_length except when we use async io */
486486
size_t read_length;
487487
myf myflags; /* Flags used to my_read/my_write */
488488
/*
489-
alloced_buffer is 1 if the buffer was allocated by init_io_cache() and
490-
0 if it was supplied by the user.
489+
alloced_buffer is set to the size of the buffer allocated for the IO_CACHE.
490+
Includes the overhead(storing key to ecnrypt and decrypt) for encryption.
491+
Set to 0 if nothing is allocated.
491492
Currently READ_NET is the only one that will use a buffer allocated
492493
somewhere else
493494
*/
494-
my_bool alloced_buffer;
495+
size_t alloced_buffer;
495496
#ifdef HAVE_AIOWAIT
496497
/*
497498
As inidicated by ifdef, this is for async I/O, which is not currently

include/mysql_version.h.in

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717
#define MYSQL_SERVER_SUFFIX_DEF "@MYSQL_SERVER_SUFFIX@"
1818
#define FRM_VER @DOT_FRM_VERSION@
1919
#define MYSQL_VERSION_ID @MYSQL_VERSION_ID@
20-
#define MYSQL_PORT @MYSQL_TCP_PORT@
20+
#define MARIADB_PORT @MYSQL_TCP_PORT@
2121
#define MYSQL_PORT_DEFAULT @MYSQL_TCP_PORT_DEFAULT@
22-
#define MYSQL_UNIX_ADDR "@MYSQL_UNIX_ADDR@"
22+
#define MARIADB_UNIX_ADDR "@MYSQL_UNIX_ADDR@"
2323
#define MYSQL_CONFIG_NAME "my"
2424
#define MYSQL_COMPILATION_COMMENT "@COMPILATION_COMMENT@"
2525
#define SERVER_MATURITY_LEVEL @SERVER_MATURITY_LEVEL@
2626

27+
#define MYSQL_PORT MARIADB_PORT
28+
#define MYSQL_UNIX_ADDR MARIADB_UNIX_ADDR
29+
2730
#ifdef WITH_WSREP
2831
#define WSREP_PATCH_VERSION "@WSREP_PATCH_VERSION@"
2932
#endif

libmariadb

mysql-test/main/case.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,12 +517,12 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='a' AND CASE 'a' WHEN 'a' THEN a ELSE
517517
id select_type table type possible_keys key key_len ref rows filtered Extra
518518
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
519519
Warnings:
520-
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 'a' and (case 'a' when 'a' then `test`.`t1`.`a` else 'a' end) = 'a'
520+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 'a' and case 'a' when 'a' then `test`.`t1`.`a` else 'a' end = 'a'
521521
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='a' AND CASE 'a' WHEN 'a' THEN 'a' ELSE a END='a';
522522
id select_type table type possible_keys key key_len ref rows filtered Extra
523523
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
524524
Warnings:
525-
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 'a' and (case 'a' when 'a' then 'a' else `test`.`t1`.`a` end) = 'a'
525+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 'a' and case 'a' when 'a' then 'a' else `test`.`t1`.`a` end = 'a'
526526
ALTER TABLE t1 MODIFY a VARBINARY(10);
527527
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='a' AND CASE a WHEN 'a' THEN 'a' ELSE 'a' END='a';
528528
id select_type table type possible_keys key key_len ref rows filtered Extra
@@ -570,7 +570,7 @@ CASE WHEN a THEN b ELSE 1 END=3;
570570
id select_type table type possible_keys key key_len ref rows filtered Extra
571571
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
572572
Warnings:
573-
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (case `test`.`t1`.`a` when `test`.`t1`.`b` then 1 end) = 1 and (case when `test`.`t1`.`a` then `test`.`t1`.`b` else 1 end) = 3
573+
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where case `test`.`t1`.`a` when `test`.`t1`.`b` then 1 end = 1 and case when `test`.`t1`.`a` then `test`.`t1`.`b` else 1 end = 3
574574
DROP TABLE t1;
575575
#
576576
# End of 10.3 test

0 commit comments

Comments
 (0)