polardbxengine/mysql-test/suite/x/t/galaxy_parallel_kill.test

152 lines
3.0 KiB
Plaintext

## Test galaxy parallel kill behavior
--source include/xplugin_preamble.inc
--source include/xplugin_create_user.inc
## Test starts here
--write_file $MYSQL_TMP_DIR/galaxy_parallel_simple.tmp
## Test data
-->sql
## give access of galaxy session.
CREATE USER 'x_root'@'galaxy' IDENTIFIED WITH 'mysql_native_password';
GRANT ALL ON *.*TO 'x_root'@'galaxy' WITH GRANT OPTION;
FLUSH PRIVILEGES;
## disable the kill log
set global galaxyx_enable_galaxy_kill_log = OFF;
drop schema if exists xtest;
create schema xtest;
use xtest;
create table mytable (pk int primary key auto_increment, data varchar(100));
delimiter //
create procedure result_and_error ()
begin
select 1;
select * from invalid_table;
end//
-->endsql
## switch GSession ID to 2(1 is default session)
-->switchsid 2
## first start new session
Mysqlx.Session.NewSession {
}
## expect Mysqlx.Ok
-->recv
Mysqlx.Sql.GalaxyStmtExecute {
stmt: "insert into mytable values (DEFAULT, \'one\')"
db_name: "xtest"
}
## expect Mysqlx.Sql.StmtExecuteOk
-->recvresult
Mysqlx.Sql.GalaxyStmtExecute {
stmt: "insert into mytable values (DEFAULT, \'two\')"
}
## expect Mysqlx.Sql.StmtExecuteOk
-->recvresult
Mysqlx.Sql.GalaxyStmtExecute {
stmt: "insert into mytable values (DEFAULT, \'three\')"
}
## expect Mysqlx.Sql.StmtExecuteOk
-->recvresult
## switch to another session and lock the record
-->switchsid 3
Mysqlx.Session.NewSession {
}
## expect Mysqlx.Ok
-->recv
Mysqlx.Sql.GalaxyStmtExecute {
stmt: "begin"
db_name: "xtest"
token: 10000
}
## expect Mysqlx.Sql.StmtExecuteOk
-->recvresult
Mysqlx.Sql.GalaxyStmtExecute {
stmt: "select data from mytable where pk=1 for update"
token: 10000
}
## expect Mysqlx.Sql.StmtExecuteOk
-->recvresult
## Now data is locked, switch back to session 2 and read.
-->switchsid 2
## Test pipeline and cancel, enqueue blocking query first.
Mysqlx.Sql.GalaxyStmtExecute {
stmt: "select data from mytable where pk=1 for update"
token: 10000
}
## Then enqueue normal query.
Mysqlx.Sql.GalaxyStmtExecute {
stmt: "select * from mytable"
token: 10000
}
## Do cancel on first request.
Mysqlx.Session.KillSession {
type: CONNECTION
x_session_id: 2
}
-->recverror ER_QUERY_INTERRUPTED
## All session finished.
## Then enqueue normal query.
Mysqlx.Sql.GalaxyStmtExecute {
stmt: "select * from mytable"
token: 10000
}
-->recverror ER_XPLUGIN_ERROR_MSG
Mysqlx.Session.Close {
}
-->recverror ER_XPLUGIN_ERROR_MSG
## Close session 3.
-->switchsid 3
Mysqlx.Sql.GalaxyStmtExecute {
stmt: "rollback"
token: 10000
}
## expect Mysqlx.Sql.StmtExecuteOk
-->recvresult
Mysqlx.Session.Close {
}
## expect Mysqlx.Ok
-->recv
## switch back to default session.
-->switchsid 1
## Cleanup
-->sql
set global galaxyx_enable_galaxy_kill_log = ON;
drop schema if exists xtest;
DROP USER 'x_root'@'galaxy';
FLUSH PRIVILEGES;
-->endsql
EOF
--exec $GALAXYXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/galaxy_parallel_simple.tmp 2>&1
## Cleanup
--remove_file $MYSQL_TMP_DIR/galaxy_parallel_simple.tmp
--source include/xplugin_drop_user.inc