Skip to content

Commit

Permalink
MDEV-32216 add tests for mariadb-dump --parallel
Browse files Browse the repository at this point in the history
-  --parallel=N with or without --single-transaction
-  Error cases (too many connections, emulate error on one connection)
-  Windows specific test for named pipe connections
  • Loading branch information
vaintroub committed Jan 29, 2024
1 parent 4532dae commit a5802ed
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 1 deletion.
4 changes: 4 additions & 0 deletions mysql-test/main/mariadb-dump-debug.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set @save_debug_dbug=@@global.debug_dbug;
set global debug_dbug='+d,select_export_kill';
mariadb-dump: Couldn't execute async query 'SELECT /*!40001 SQL_NO_CACHE */ `Host`, `User`, `Priv` INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/global_priv.txt' /*!50138 CHARACTER SET binary */ FROM `mysql`.`global_priv`' (Query execution was interrupted)
set global debug_dbug=@save_debug_dbug;
15 changes: 15 additions & 0 deletions mysql-test/main/mariadb-dump-debug.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--source include/have_debug.inc
--source include/not_embedded.inc
# need to dump "mysql" schema
--source include/have_innodb.inc

# inject error on SELECT INTO OUTFILE
set @save_debug_dbug=@@global.debug_dbug;
set global debug_dbug='+d,select_export_kill';
# This one succeeds
--replace_result .\exe '' $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 2
--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --parallel=2 mysql global_priv 2>&1

set global debug_dbug=@save_debug_dbug;

1 change: 1 addition & 0 deletions mysql-test/main/mysqldump-win.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--loose-enable-named-pipe
9 changes: 9 additions & 0 deletions mysql-test/main/mysqldump-win.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Test mysqldump specific features (pipe connection, with parallel)
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES(1);
DROP TABLE t1;
test.t1: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0
SELECT * FROM t1;
i
1
DROP TABLE t1;
14 changes: 14 additions & 0 deletions mysql-test/main/mysqldump-win.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--source include/windows.inc
--source include/not_embedded.inc

--echo # Test mysqldump specific features (pipe connection, with parallel)
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES(1);

--exec $MYSQL_DUMP --host=. --tab=$MYSQLTEST_VARDIR/tmp/ test --parallel=2
DROP TABLE t1;
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql
--exec $MYSQL_IMPORT test $MYSQLTEST_VARDIR/tmp/t1.txt
SELECT * FROM t1;
DROP TABLE t1;

9 changes: 9 additions & 0 deletions mysql-test/main/mysqldump.result
Original file line number Diff line number Diff line change
Expand Up @@ -6658,3 +6658,12 @@ drop table t1;
# End of 10.4 tests
#
mariadb-dump: --xml can't be used with --tab.
select @@max_connections into @save_max_connections;
set global max_connections=10;
mariadb-dump: Got error: 1040: "Too many connections" when trying to connect
set global max_connections=300;
mariadb-dump: Too many connections
set global max_connections=@save_max_connections;
#
# End of 11.4 tests
#
23 changes: 22 additions & 1 deletion mysql-test/main/mysqldump.test
Original file line number Diff line number Diff line change
Expand Up @@ -2482,7 +2482,7 @@ INSERT INTO t2 VALUES (3), (4);
SELECT * FROM t1;
SELECT * FROM t2;

--exec $MYSQL_DUMP --default-character-set=utf8mb4 --tab=$MYSQLTEST_VARDIR/tmp/ db_20772273
--exec $MYSQL_DUMP --default-character-set=utf8mb4 --tab=$MYSQLTEST_VARDIR/tmp/ --parallel=2 db_20772273
--exec $MYSQL db_20772273 < $MYSQLTEST_VARDIR/tmp/t1.sql
--exec $MYSQL db_20772273 < $MYSQLTEST_VARDIR/tmp/t2.sql

Expand Down Expand Up @@ -3023,3 +3023,24 @@ drop table t1;
--replace_result mariadb-dump.exe mariadb-dump
--error 1
--exec $MYSQL_DUMP --xml --tab=$MYSQLTEST_VARDIR/tmp 2>&1

#
# MDEV-32589 parallel-mysqldump - test "too many connections"
#
select @@max_connections into @save_max_connections;
set global max_connections=10;
--replace_result mariadb-dump.exe mariadb-dump
--error 2
--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --parallel=20 mysql 2>&1
#
# MDEV-32589 test builtin 256 connections limit
#
set global max_connections=300;
--replace_result mariadb-dump.exe mariadb-dump
--error 1
--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --parallel=280 mysql 2>&1
set global max_connections=@save_max_connections;

--echo #
--echo # End of 11.4 tests
--echo #
3 changes: 3 additions & 0 deletions sql/sql_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3399,6 +3399,9 @@ int select_export::send_data(List<Item> &items)
uint used_length=0,items_left=items.elements;
List_iterator_fast<Item> li(items);

DBUG_EXECUTE_IF("select_export_kill", {
thd->killed= KILL_QUERY;
});
if (my_b_write(&cache,(uchar*) exchange->line_start->ptr(),
exchange->line_start->length()))
goto err;
Expand Down

0 comments on commit a5802ed

Please sign in to comment.