-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://jira.percona.com/browse/PXB-3034 Added test cases under suite/lockless Fixed test cases using --lock-ddl=false/true
- Loading branch information
1 parent
38d7216
commit 3c89fe3
Showing
43 changed files
with
1,340 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
storage/innobase/xtrabackup/test/suites/lockless/alter_table_add_column.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
|
||
. inc/common.sh | ||
|
||
require_debug_pxb_version | ||
require_debug_server | ||
|
||
function run_test() { | ||
ALL_TABLES_IN_BACKUP=$1 | ||
INSTANT=$2 | ||
|
||
vlog "Running test with ALL_TABLES_IN_BACKUP=$ALL_TABLES_IN_BACKUP and INSTANT=$INSTANT" | ||
|
||
start_server | ||
if [ "$ALL_TABLES_IN_BACKUP" = "false" ]; then | ||
$MYSQL $MYSQL_ARGS -Ns -e "SET GLOBAL innodb_checkpoint_disabled=true;" | ||
fi | ||
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.keep (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50)); INSERT INTO test.keep VALUES(1, 'a'), (2, 'b');" test | ||
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.rename (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50)); INSERT INTO test.rename VALUES(1, 'a'), (2, 'b');" test | ||
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.drop (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50)); INSERT INTO test.drop VALUES(1, 'a'), (2, 'b');" test | ||
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.default_val (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50)); INSERT INTO test.default_val VALUES(1, 'a'), (2, 'b');" test | ||
|
||
|
||
if [ "$ALL_TABLES_IN_BACKUP" = "true" ]; then | ||
innodb_wait_for_flush_all | ||
fi | ||
|
||
|
||
xtrabackup --backup --target-dir=$topdir/backup_add_column \ | ||
--debug-sync="ddl_tracker_before_lock_ddl" --lock-ddl=REDUCED \ | ||
2> >( tee $topdir/backup_with_add_column.log)& | ||
|
||
job_pid=$! | ||
pid_file=$topdir/backup_add_column/xtrabackup_debug_sync | ||
wait_for_xb_to_suspend $pid_file | ||
xb_pid=`cat $pid_file` | ||
echo "backup pid is $job_pid" | ||
|
||
# change default value and generate redo | ||
QUERY="ALTER TABLE test.default_val ALTER COLUMN name SET DEFAULT 'no-name', ALGORITHM=" | ||
if [ "$INSTANT" = "true" ]; then | ||
QUERY+="INSTANT" | ||
else | ||
QUERY+="INPLACE" | ||
fi | ||
|
||
$MYSQL $MYSQL_ARGS -Ns -e "${QUERY} ; INSERT INTO test.default_val VALUES (3, 'c'), (4, 'd');" test | ||
|
||
# Add new column to table and generate redo | ||
QUERY="ALTER TABLE test.keep ADD COLUMN new_col VARCHAR(50) AFTER id, ALGORITHM=" | ||
if [ "$INSTANT" = "true" ]; then | ||
QUERY+="INSTANT" | ||
else | ||
QUERY+="INPLACE" | ||
fi | ||
|
||
$MYSQL $MYSQL_ARGS -Ns -e "${QUERY} ; INSERT INTO test.keep VALUES (3, 'col', 'c'), (4, 'col', 'd');" test | ||
|
||
# Add new column to table, generate redo, rename the table and generate redo | ||
QUERY="ALTER TABLE test.rename ADD COLUMN new_col VARCHAR(50) AFTER id, ALGORITHM=" | ||
if [ "$INSTANT" = "true" ]; then | ||
QUERY+="INSTANT" | ||
else | ||
QUERY+="INPLACE" | ||
fi | ||
|
||
$MYSQL $MYSQL_ARGS -Ns -e "${QUERY} ; INSERT INTO test.rename VALUES (3, 'col', 'c'), (4, 'col', 'd');" test | ||
$MYSQL $MYSQL_ARGS -Ns -e "RENAME TABLE test.rename TO test.after_rename; INSERT INTO test.after_rename VALUES (5, 'col', 'e'), (6, 'col', 'f');" test | ||
|
||
# Add new column to table, generate redo, drop the table | ||
QUERY="ALTER TABLE test.drop ADD COLUMN new_col VARCHAR(50) AFTER id, ALGORITHM=" | ||
if [ "$INSTANT" = "true" ]; then | ||
QUERY+="INSTANT" | ||
else | ||
QUERY+="INPLACE" | ||
fi | ||
$MYSQL $MYSQL_ARGS -Ns -e "${QUERY} ; INSERT INTO test.drop VALUES (3, 'col', 'c'), (4, 'col', 'd'); DROP TABLE test.drop;" test | ||
|
||
# Create table, generate redo and add column | ||
QUERY="CREATE TABLE test.new (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50)); INSERT INTO test.new VALUES(1, 'a'), (2, 'b'); ALTER TABLE test.new ADD COLUMN new_col VARCHAR(50) AFTER id, ALGORITHM=" | ||
if [ "$INSTANT" = "true" ]; then | ||
QUERY+="INSTANT" | ||
else | ||
QUERY+="INPLACE" | ||
fi | ||
$MYSQL $MYSQL_ARGS -Ns -e "${QUERY} ; INSERT INTO test.new VALUES (3, 'col', 'c'), (4, 'col', 'd');" test | ||
|
||
# Resume the xtrabackup process | ||
vlog "Resuming xtrabackup" | ||
kill -SIGCONT $xb_pid | ||
run_cmd wait $job_pid | ||
|
||
xtrabackup --prepare --target-dir=$topdir/backup_add_column | ||
record_db_state test | ||
stop_server | ||
rm -rf $mysql_datadir/* | ||
xtrabackup --copy-back --target-dir=$topdir/backup_add_column | ||
start_server | ||
verify_db_state test | ||
|
||
stop_server | ||
rm -rf $mysql_datadir $topdir/backup_with_add_column.log $topdir/backup_add_column | ||
} | ||
|
||
|
||
# Run test with all tables in backup and algortihm inplace | ||
run_test true false | ||
|
||
# Run test with all tables in backup and algortihm instant | ||
run_test true true | ||
|
||
# Run test with all tables in redo and algortihm inplace | ||
run_test false false | ||
|
||
# Run test with all tables in redo and algortihm instant | ||
run_test false true | ||
|
79 changes: 79 additions & 0 deletions
79
storage/innobase/xtrabackup/test/suites/lockless/alter_table_add_index.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
|
||
. inc/common.sh | ||
|
||
require_debug_pxb_version | ||
require_debug_server | ||
|
||
function run_test() { | ||
ALL_TABLES_IN_BACKUP=$1 | ||
vlog "Running test with ALL_TABLES_IN_BACKUP=$ALL_TABLES_IN_BACKUP" | ||
|
||
start_server | ||
if [ "$ALL_TABLES_IN_BACKUP" = "false" ]; then | ||
$MYSQL $MYSQL_ARGS -Ns -e "SET GLOBAL innodb_checkpoint_disabled=true;" | ||
fi | ||
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.secondary_idx_keep (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50)); INSERT INTO test.secondary_idx_keep VALUES(1, 'a'), (2, 'b');" test | ||
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.secondary_idx_rename (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50)); INSERT INTO test.secondary_idx_rename VALUES(1, 'a'), (2, 'b');" test | ||
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.secondary_idx_drop (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50)); INSERT INTO test.secondary_idx_drop VALUES(1, 'a'), (2, 'b');" test | ||
|
||
if [ "$ALL_TABLES_IN_BACKUP" = "true" ]; then | ||
innodb_wait_for_flush_all | ||
fi | ||
|
||
|
||
xtrabackup --backup --target-dir=$topdir/backup_optimized_ddl \ | ||
--debug-sync="ddl_tracker_before_lock_ddl" --lock-ddl=REDUCED \ | ||
2> >( tee $topdir/backup_with_optimized_ddl.log)& | ||
|
||
job_pid=$! | ||
pid_file=$topdir/backup_optimized_ddl/xtrabackup_debug_sync | ||
wait_for_xb_to_suspend $pid_file | ||
xb_pid=`cat $pid_file` | ||
echo "backup pid is $job_pid" | ||
|
||
# Add secondary index | ||
$MYSQL $MYSQL_ARGS -Ns -e "ALTER TABLE test.secondary_idx_keep ADD INDEX(name);" test | ||
|
||
# Add secondary index and rename table | ||
$MYSQL $MYSQL_ARGS -Ns -e "ALTER TABLE test.secondary_idx_rename ADD INDEX(name); RENAME TABLE test.secondary_idx_rename TO test.secondary_idx_after_rename" test | ||
|
||
# Add secondary index and drop table | ||
$MYSQL $MYSQL_ARGS -Ns -e "ALTER TABLE test.secondary_idx_drop ADD INDEX(name); DROP TABLE test.secondary_idx_drop;" test | ||
|
||
# Create table and generate redo | ||
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.secondary_idx_new (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50)); INSERT INTO test.secondary_idx_new VALUES(1, 'a'), (2, 'b'); ALTER TABLE test.secondary_idx_new ADD INDEX(name);" test | ||
|
||
# Resume the xtrabackup process | ||
vlog "Resuming xtrabackup" | ||
kill -SIGCONT $xb_pid | ||
run_cmd wait $job_pid | ||
|
||
original_keep_table_row_count=`$MYSQL $MYSQL_ARGS -Ns -e "SELECT COUNT(*) FROM test.secondary_idx_keep FORCE INDEX(name);" | awk {'print $1'}` | ||
original_rename_table_row_count=`$MYSQL $MYSQL_ARGS -Ns -e "SELECT COUNT(*) FROM test.secondary_idx_after_rename FORCE INDEX(name);" | awk {'print $1'}` | ||
xtrabackup --prepare --target-dir=$topdir/backup_optimized_ddl | ||
record_db_state test | ||
stop_server | ||
rm -rf $mysql_datadir/* | ||
xtrabackup --copy-back --target-dir=$topdir/backup_optimized_ddl | ||
start_server | ||
verify_db_state test | ||
restored_keep_table_row_count=`$MYSQL $MYSQL_ARGS -Ns -e "SELECT COUNT(*) FROM test.secondary_idx_keep FORCE INDEX(name);" | awk {'print $1'}` | ||
restored_rename_table_row_count=`$MYSQL $MYSQL_ARGS -Ns -e "SELECT COUNT(*) FROM test.secondary_idx_after_rename FORCE INDEX(name);" | awk {'print $1'}` | ||
|
||
if [ "$original_keep_table_row_count" != "$restored_keep_table_row_count" ]; then | ||
die "rows in table secondary_idx_keep is $restored_keep_table_row_count when it should be $original_keep_table_row_count" | ||
fi | ||
|
||
if [ "$original_rename_table_row_count" != "$restored_rename_table_row_count" ]; then | ||
die "rows in table secondary_idx_after_rename is $restored_rename_table_row_count when it should be $original_rename_table_row_count" | ||
fi | ||
stop_server | ||
rm -rf $mysql_datadir $topdir/backup_with_optimized_ddl.log $topdir/backup_optimized_ddl | ||
} | ||
|
||
|
||
# Run test with all tables in backup | ||
run_test true | ||
|
||
# Run test ensure DDL for create tables are part of redo log entries | ||
run_test false |
Oops, something went wrong.