Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PXB-3269 Reduce the time the Server is locked by xtrabackup #1603

Open
wants to merge 59 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
62bb4ce
PXB-3034 - Make --lock-ddl option an ENUM
altmannmarcelo Nov 6, 2023
4abc24c
PXB-3034 - Add DDL tracking to xtrabackup
altmannmarcelo Nov 6, 2023
967c2e5
PXB-3034 - Handle prepare
altmannmarcelo Nov 28, 2023
34d3a0f
PXB-3034 - Second phase copy Multi thread
altmannmarcelo Nov 30, 2023
3b52455
PXB-3034 - Adding test cases
altmannmarcelo Nov 6, 2023
35b4c3e
PXB-3034 - adjust fil_open_for_xtrabackup
altmannmarcelo Dec 20, 2023
582887e
1. Use space_id instead of table name for naming .del .ren files.
aybek Feb 15, 2024
739ed77
PXB-3238 handle rename ddls that happen during scan
aybek Feb 28, 2024
773bff0
We want to note that table will be copied only after it has been open…
aybek Mar 6, 2024
e377e77
PXB-3113 : Improve debug sync framework to allow PXB to pause and res…
satya-bodapati Apr 2, 2024
20a8dd2
PXB-3252 : Xtrabackup failed to read page after 10 retries. File ./my…
satya-bodapati Apr 5, 2024
1bb0dae
PXB-3246 : Assertion failure: log0recv.cc:2141:!page || fil_page_type…
satya-bodapati Apr 5, 2024
e7b4be3
PXB-3253 : [ERROR] [MY-012592] [InnoDB] Operating system error number…
satya-bodapati Apr 18, 2024
0c5f71c
PXB-3223 : PXB must not allow --lock-ddl=REDUCED when pagetracking is…
satya-bodapati Apr 19, 2024
f1e6342
PXB-3120 : Assertion failure: Dir_Walker::is_directory
satya-bodapati Apr 22, 2024
e457504
PXB-3278 : Wrong parsing of MLOG_FILE_ redo log records with lock-ddl…
aybek Aug 6, 2024
181e168
PXB-3281 : With lock-ddl=REDUCED, STL containers used by reduced code…
satya-bodapati Apr 25, 2024
9d94ae7
PXB-3241 : Assertion failure: os0file.cc:3416:!exists while taking ba…
satya-bodapati Apr 26, 2024
d8b1748
PXB-3245 : Assertion failure: fil0fil.cc:2545:err == DB_SUCCESS found…
satya-bodapati Apr 26, 2024
8f57c32
PXB-3280 : undo log truncation causes assertion failure with reduced …
satya-bodapati May 2, 2024
3b4c1ba
PXB-3248 Multiple files found for the same tablespace ID
aybek Aug 6, 2024
96d74f0
PXB-3034: Bring back UNIV_DEBUG on debug-sync-thread.
satya-bodapati Jun 7, 2024
1499019
PXB-3320 : prepare_handle_del_files() fails to delete the .meta and .…
satya-bodapati Jul 5, 2024
ff4ae6a
PXB-3318 : prepare_handle_ren_files(): failed to handle .ren files
satya-bodapati Jul 16, 2024
9d29bf5
PXB-3295 : Undo tablespaces are not tracked properly with lock-ddl=RE…
satya-bodapati Jul 17, 2024
dde5823
PXB-3295: fix testcase
satya-bodapati Jul 18, 2024
7bfb9a6
Follow up fix for PXB-3318: handle rename source and destination as s…
satya-bodapati Jul 18, 2024
d725da5
PXB-3221 : Assertion failure: page0cur.cc:1177:ib::fatal triggered du…
satya-bodapati Jul 18, 2024
1b2e702
PXB-3331 : Assertion failure: fil0fil.cc:6422:success
satya-bodapati Jul 22, 2024
1263d43
PXB-3349 : Fix compilation errors on some platforms
satya-bodapati Aug 15, 2024
dbd4bfc
PXB-3350 : Display verbose DDL states maintained in reduced lock mode
satya-bodapati Aug 15, 2024
74ba585
PXB-3330 : Show the total time that xtrabackup locked the server
satya-bodapati Aug 16, 2024
8a7dadd
Rename testsuite from lockless to reducedlock
satya-bodapati Aug 16, 2024
db75f16
PXB-3351 : Fix undo.sh random failure
satya-bodapati Aug 16, 2024
8c50e7a
Fix memory leak seen on Jenkins.
satya-bodapati Aug 19, 2024
a8244e4
PXB-3352 : Fix jenkins test failures
satya-bodapati Aug 20, 2024
db6168e
PXB-3352 : Fix jenkins test failures
satya-bodapati Aug 22, 2024
171ab41
PXB-3334 Code cleanups in reduced lock feature
Aug 23, 2024
9426040
PXB-3334 Code cleanups in reduced lock feature
Aug 27, 2024
47adf50
Refactor code. Move it reduced lock code to ddl_tracker files
satya-bodapati Aug 27, 2024
65300ae
PXB-3334 Code cleanups in reduced lock feature
Aug 28, 2024
2a98596
Addressing the PR review comments
Aug 30, 2024
5032b11
Address review comments
satya-bodapati Sep 2, 2024
0a1015e
PXB-3269
satya-bodapati Sep 4, 2024
1d7620e
PXB-3269 : Address review comments
satya-bodapati Sep 4, 2024
7c77361
PXB-3269 : Address review comments
satya-bodapati Sep 10, 2024
6c9aa00
PXB-3269: Address self review comments
satya-bodapati Sep 12, 2024
041a65a
PXB-3269 : Add version number to .ren files
satya-bodapati Sep 12, 2024
cb27cb4
PXB-3368 Fix jenkins test failures
Sep 17, 2024
284e035
Add missing function comment
satya-bodapati Sep 13, 2024
7d82843
PXB-3269 : Fix debug assertion failure on prepare_handle_ren() files.
satya-bodapati Sep 18, 2024
e525a8f
PXB-3368 Fix jenkins test failures
Sep 19, 2024
ecf20bb
PXB-3370 : Full Backup fails while open file limit is reduced to 1024…
satya-bodapati Sep 24, 2024
335c7d5
PXB-3374 : Space ID is missing encryption information
satya-bodapati Oct 4, 2024
bb3e06a
PXB-3381 : Implement check to fail early if number of open file hand…
satya-bodapati Oct 4, 2024
f5ae4e8
PXB-3380 Backup fails when using external tablespaces and external un…
Oct 8, 2024
cb498b0
PXB-3380 Extending the tests for external tablespaces
Oct 9, 2024
022a5be
PXB-3380 Addressing review comments
Oct 11, 2024
e048e90
PXB-3380 Addressing review comments
Oct 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions storage/innobase/xtrabackup/src/ddl_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,16 @@ static void copy_for_reduced(copy_thread_ctxt_t *ctxt) {
if (ctxt->new_tables->find(node->space->id) == ctxt->new_tables->end()) {
continue;
}
std::string dest_name = node->name;
dest_name.append(EXT_NEW);
if (xtrabackup_copy_datafile_func(node, num, dest_name.c_str())) {
char dest_name[FN_REFLEN];
if (fsp_is_file_per_table(node->space->id, node->space->flags)) {
snprintf(dest_name, sizeof(dest_name), "%s%s%s",
fil_path_to_space_name(node->name), EXT_IBD.c_str(),
aybek marked this conversation as resolved.
Show resolved Hide resolved
EXT_NEW.c_str());
} else {
snprintf(dest_name, sizeof(dest_name), "%s%s",
Fil_path::get_basename(node->name).c_str(), EXT_NEW.c_str());
}
if (xtrabackup_copy_datafile_func(node, num, dest_name)) {
xb::error() << "failed to copy datafile " << node->name;
*(ctxt->error) = true;
}
Expand All @@ -331,8 +338,9 @@ format by replacing the `filename` to `spaceid` and appending the extension
@returns .del or .ren file name starting with space_id e.g schema/spaceid.del
*/
static std::string convert_file_name(const space_id_t space_id,
const std::string &file_name,
const std::string &file_path,
const std::string &ext) {
std::string file_name = fil_path_to_space_name(file_path.c_str());
auto sep_pos = file_name.find_last_of(Fil_path::SEPARATOR);
return file_name.substr(0, sep_pos + 1) + std::to_string(space_id) + ext;
}
Expand Down
10 changes: 2 additions & 8 deletions storage/innobase/xtrabackup/src/xtrabackup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3632,14 +3632,8 @@ static dberr_t xb_load_tablespaces()
for (auto tablespace : Tablespace_map::instance().external_files()) {
if (tablespace.type != Tablespace_map::TABLESPACE) continue;
/* when LOCK_DDL_REDUCED while processing ddl files on prepare phase
we should load data files without first page validation */
if (xtrabackup_prepare && opt_lock_ddl == LOCK_DDL_REDUCED &&
!xtrabackup_incremental) {
dberr_t err = fil_open_for_reduced(tablespace.file_name);
if (err != DB_SUCCESS) {
return (err);
}
} else {
we should not load external files */
if (!xtrabackup_prepare) {
fil_open_for_xtrabackup(tablespace.file_name, tablespace.name);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
########################################################################
# Test support for external tablespaces
########################################################################

. inc/common.sh

require_debug_pxb_version
vlog "case #1: ensure external undo tablespaces are copied"

undo_directory_ext=$TEST_VAR_ROOT/var1/undo_dir_ext
mkdir -p $undo_directory_ext

MYSQLD_EXTRA_MY_CNF_OPTS="
innodb_undo_directory=$undo_directory_ext
"

start_server
$MYSQL $MYSQL_ARGS -e "CREATE TABLE t1 (a INT) ENGINE=InnoDB" test
$MYSQL $MYSQL_ARGS -e "INSERT INTO t1 VALUES (1)" test
mysql -e "CREATE UNDO TABLESPACE UNDO_1 ADD DATAFILE 'undo_1.ibu'"
mysql -e "CREATE UNDO TABLESPACE UNDO_2 ADD DATAFILE 'undo_2.ibu'"

xtrabackup --backup --lock-ddl=REDUCED --target-dir=$topdir/backup \
--debug-sync="ddl_tracker_before_lock_ddl" 2> >( tee $topdir/backup.log)&
job_pid=$!

pid_file=$topdir/backup/xtrabackup_debug_sync
wait_for_xb_to_suspend $pid_file
xb_pid=`cat $pid_file`
echo "backup pid is $job_pid"

mysql -e "ALTER UNDO TABLESPACE UNDO_1 SET INACTIVE"
mysql -e "SET GLOBAL innodb_purge_rseg_truncate_frequency=1"
sleep 3s

# Resume the xtrabackup process
vlog "Resuming xtrabackup"
kill -SIGCONT $xb_pid
run_cmd wait $job_pid

if ! egrep -q "Deleted undo file: $undo_directory_ext/undo_1.ibu : [0-9]*" $topdir/backup.log ; then
die "xtrabackup did not handle delete table DDL"
fi

if ! egrep -q "Done: Writing file $topdir/backup/[0-9]*.del" $topdir/backup.log ; then
die "xtrabackup did not create .del file"
fi

if ! egrep -q "New undo file: $undo_directory_ext/undo_1.ibu : [0-9]*" $topdir/backup.log ; then
die "xtrabackup did not handle new table DDL"
fi

if ! egrep -q "Done: Copying $undo_directory_ext/undo_1.ibu to $topdir/backup/undo_1.ibu.new" $topdir/backup.log ; then
die "xtrabackup did not create undo_1.ibu.new file"
fi


mysql -e "SET GLOBAL innodb_purge_rseg_truncate_frequency=default"
xtrabackup --prepare --target-dir=$topdir/backup
stop_server
rm -rf $MYSQLD_DATADIR/*
rm -rf $undo_directory_ext/*
xtrabackup --copy-back --target-dir=$topdir/backup --innodb_undo_directory=$undo_directory_ext
start_server

stop_server
rm -rf $MYSQLD_DATADIR
rm -rf $undo_directory_ext



vlog "case #2: ensure regular external tablespaces are handled"

data_directory_ext=$TEST_VAR_ROOT/var1/data_dir_ext
mkdir -p $data_directory_ext

MYSQLD_EXTRA_MY_CNF_OPTS="
innodb_directories=$data_directory_ext
"
start_server

$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.DELETE_TABLE (id INT PRIMARY KEY AUTO_INCREMENT) DATA DIRECTORY = '$data_directory_ext';" test
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.ORIGINAL_TABLE (id INT PRIMARY KEY AUTO_INCREMENT) DATA DIRECTORY = '$data_directory_ext'; INSERT INTO test.ORIGINAL_TABLE VALUES(1)" test
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.OP_DDL_TABLE (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50)) DATA DIRECTORY = '$data_directory_ext'; INSERT INTO test.OP_DDL_TABLE VALUES(1, 'test')" test

innodb_wait_for_flush_all

xtrabackup --backup --target-dir=$topdir/backup_new_table \
--debug-sync="xtrabackup_load_tablespaces_pause" --lock-ddl=REDUCED \
2> >( tee $topdir/backup_with_new_table.log)&

job_pid=$!
pid_file=$topdir/backup_new_table/xtrabackup_debug_sync
wait_for_xb_to_suspend $pid_file
xb_pid=`cat $pid_file`
echo "backup pid is $job_pid"

# Generate redo on table than delete it
$MYSQL $MYSQL_ARGS -Ns -e "INSERT INTO test.DELETE_TABLE VALUES (1); DROP TABLE test.DELETE_TABLE;" test

# Create table and generate redo
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.NEW_TABLE (id INT PRIMARY KEY AUTO_INCREMENT) DATA DIRECTORY = '$data_directory_ext'; INSERT INTO test.NEW_TABLE VALUES (), ();" test

# Bulk Index Load and generate redo
$MYSQL $MYSQL_ARGS -Ns -e "ALTER TABLE test.OP_DDL_TABLE ADD INDEX(name); INSERT INTO test.OP_DDL_TABLE VALUES (2, 'test2');" test

# Resume the xtrabackup process
vlog "Resuming xtrabackup"
kill -SIGCONT $xb_pid
run_cmd wait $job_pid

if ! egrep -q "DDL tracking : LSN: [0-9]* delete space ID: [0-9]* Name: $data_directory_ext/test/DELETE_TABLE.ibd" $topdir/backup_with_new_table.log ; then
die "xtrabackup did not handle delete table DDL"
fi

if ! egrep -q "Done: Writing file $topdir/backup_new_table/test/[0-9]*.del" $topdir/backup_with_new_table.log ; then
die "xtrabackup did not create .del file"
fi

if ! egrep -q "DDL tracking : LSN: [0-9]* create space ID: [0-9]* Name: $data_directory_ext/test/NEW_TABLE.ibd" $topdir/backup_with_new_table.log ; then
die "xtrabackup did not handle new table DDL"
fi

if ! egrep -q "Done: Copying $data_directory_ext/test/OP_DDL_TABLE.ibd to $topdir/backup_new_table/test/OP_DDL_TABLE.ibd.new" $topdir/backup_with_new_table.log ; then
die "xtrabackup did not create OP_DDL_TABLE.ibd.new file"
fi

if ! egrep -q "DDL tracking : LSN: [0-9]* add index on space ID: [0-9]*" $topdir/backup_with_new_table.log ; then
die "xtrabackup did not handle Bulk Index Load DDL"
fi

xtrabackup --prepare --target-dir=$topdir/backup_new_table
record_db_state test
stop_server
rm -rf $mysql_datadir/*
rm -rf $data_directory_ext/*
xtrabackup --copy-back --target-dir=$topdir/backup_new_table
start_server
verify_db_state test
stop_server
rm -rf $mysql_datadir $topdir/backup_new_table $data_directory_ext

Loading