mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
merge from mysql-trunk-runtime
This commit is contained in:
96
mysql-test/include/check_concurrent_insert.inc
Normal file
96
mysql-test/include/check_concurrent_insert.inc
Normal file
@ -0,0 +1,96 @@
|
||||
#
|
||||
# SUMMARY
|
||||
# Check if statement reading table '$table' allows concurrent
|
||||
# inserts in it.
|
||||
#
|
||||
# PARAMETERS
|
||||
# $table Table in which concurrent inserts should be allowed.
|
||||
# $con_aux1 Name of the first auxiliary connection to be used by this
|
||||
# script.
|
||||
# $con_aux2 Name of the second auxiliary connection to be used by this
|
||||
# script.
|
||||
# $statement Statement to be checked.
|
||||
# $restore_table Table which might be modified affected by statement to be
|
||||
# checked and thus needs backing up before its execution
|
||||
# and restoring after it (can be empty).
|
||||
#
|
||||
# EXAMPLE
|
||||
# lock_sync.test
|
||||
#
|
||||
--disable_result_log
|
||||
--disable_query_log
|
||||
|
||||
# Reset DEBUG_SYNC facility for safety.
|
||||
set debug_sync= "RESET";
|
||||
|
||||
if (`SELECT '$restore_table' <> ''`)
|
||||
{
|
||||
--eval create table t_backup select * from $restore_table;
|
||||
}
|
||||
|
||||
connection $con_aux1;
|
||||
set debug_sync='after_lock_tables_takes_lock SIGNAL parked WAIT_FOR go';
|
||||
--send_eval $statement;
|
||||
|
||||
connection $con_aux2;
|
||||
set debug_sync='now WAIT_FOR parked';
|
||||
--send_eval insert into $table values (0);
|
||||
|
||||
--enable_result_log
|
||||
--enable_query_log
|
||||
connection default;
|
||||
# Wait until concurrent insert is successfully executed while
|
||||
# statement being checked has its tables locked.
|
||||
# We use wait_condition.inc instead of simply executing
|
||||
# concurrent insert here in order to avoid deadlocks if test
|
||||
# fails and timing out instead.
|
||||
let $wait_condition=
|
||||
select count(*) = 0 from information_schema.processlist
|
||||
where info = "insert into $table values (0)";
|
||||
--source include/wait_condition.inc
|
||||
|
||||
--disable_result_log
|
||||
--disable_query_log
|
||||
|
||||
if ($success)
|
||||
{
|
||||
# Apparently concurrent insert was successfully executed.
|
||||
# To be safe against wait_condition.inc succeeding due to
|
||||
# races let us first reap concurrent insert to ensure that
|
||||
# it has really been successfully executed.
|
||||
connection $con_aux2;
|
||||
--reap
|
||||
connection default;
|
||||
set debug_sync= 'now SIGNAL go';
|
||||
connection $con_aux1;
|
||||
--reap
|
||||
connection default;
|
||||
--echo Success: '$statement' allows concurrent inserts into '$table'.
|
||||
}
|
||||
if (!$success)
|
||||
{
|
||||
# Waiting has timed out. Apparently concurrent insert was blocked.
|
||||
# So to be able to continue we need to end our statement first.
|
||||
set debug_sync= 'now SIGNAL go';
|
||||
connection $con_aux1;
|
||||
--reap
|
||||
connection $con_aux2;
|
||||
--reap
|
||||
connection default;
|
||||
--echo Error: '$statement' doesn't allow concurrent inserts into '$table'!
|
||||
}
|
||||
|
||||
--eval delete from $table where i = 0;
|
||||
|
||||
if (`SELECT '$restore_table' <> ''`)
|
||||
{
|
||||
--eval truncate table $restore_table;
|
||||
--eval insert into $restore_table select * from t_backup;
|
||||
drop table t_backup;
|
||||
}
|
||||
|
||||
# Clean-up. Reset DEBUG_SYNC facility after use.
|
||||
set debug_sync= "RESET";
|
||||
|
||||
--enable_result_log
|
||||
--enable_query_log
|
81
mysql-test/include/check_no_concurrent_insert.inc
Normal file
81
mysql-test/include/check_no_concurrent_insert.inc
Normal file
@ -0,0 +1,81 @@
|
||||
#
|
||||
# SUMMARY
|
||||
# Check that statement reading table '$table' doesn't allow concurrent
|
||||
# inserts in it.
|
||||
#
|
||||
# PARAMETERS
|
||||
# $table Table in which concurrent inserts should be disallowed.
|
||||
# $con_aux1 Name of the first auxiliary connection to be used by this
|
||||
# script.
|
||||
# $con_aux2 Name of the second auxiliary connection to be used by this
|
||||
# script.
|
||||
# $statement Statement to be checked.
|
||||
# $restore_table Table which might be modified affected by statement to be
|
||||
# checked and thus needs backing up before its execution
|
||||
# and restoring after it (can be empty).
|
||||
#
|
||||
# EXAMPLE
|
||||
# lock_sync.test
|
||||
#
|
||||
--disable_result_log
|
||||
--disable_query_log
|
||||
|
||||
# Reset DEBUG_SYNC facility for safety.
|
||||
set debug_sync= "RESET";
|
||||
|
||||
if (`SELECT '$restore_table' <> ''`)
|
||||
{
|
||||
--eval create table t_backup select * from $restore_table;
|
||||
}
|
||||
|
||||
connection $con_aux1;
|
||||
set debug_sync='after_lock_tables_takes_lock SIGNAL parked WAIT_FOR go';
|
||||
--send_eval $statement;
|
||||
|
||||
connection $con_aux2;
|
||||
set debug_sync='now WAIT_FOR parked';
|
||||
--send_eval insert into $table values (0);
|
||||
|
||||
--enable_result_log
|
||||
--enable_query_log
|
||||
connection default;
|
||||
# Wait until concurrent insert is successfully blocked because
|
||||
# of our statement.
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state = "Table lock" and info = "insert into $table values (0)";
|
||||
--source include/wait_condition.inc
|
||||
|
||||
--disable_result_log
|
||||
--disable_query_log
|
||||
|
||||
set debug_sync= 'now SIGNAL go';
|
||||
connection $con_aux1;
|
||||
--reap
|
||||
connection $con_aux2;
|
||||
--reap
|
||||
connection default;
|
||||
|
||||
if ($success)
|
||||
{
|
||||
--echo Success: '$statement' doesn't allow concurrent inserts into '$table'.
|
||||
}
|
||||
if (!$success)
|
||||
{
|
||||
--echo Error: '$statement' allows concurrent inserts into '$table'!
|
||||
}
|
||||
|
||||
--eval delete from $table where i = 0;
|
||||
|
||||
if (`SELECT '$restore_table' <> ''`)
|
||||
{
|
||||
--eval truncate table $restore_table;
|
||||
--eval insert into $restore_table select * from t_backup;
|
||||
drop table t_backup;
|
||||
}
|
||||
|
||||
# Clean-up. Reset DEBUG_SYNC facility after use.
|
||||
set debug_sync= "RESET";
|
||||
|
||||
--enable_result_log
|
||||
--enable_query_log
|
71
mysql-test/include/check_no_row_lock.inc
Normal file
71
mysql-test/include/check_no_row_lock.inc
Normal file
@ -0,0 +1,71 @@
|
||||
#
|
||||
# SUMMARY
|
||||
# Check if statement affecting or reading table '$table' doesn't
|
||||
# take any kind of locks on its rows.
|
||||
#
|
||||
# PARAMETERS
|
||||
# $table Table for which presence of row locks should be checked.
|
||||
# $con_aux Name of auxiliary connection to be used by this script.
|
||||
# $statement Statement to be checked.
|
||||
#
|
||||
# EXAMPLE
|
||||
# innodb_mysql_lock2.test
|
||||
#
|
||||
--disable_result_log
|
||||
--disable_query_log
|
||||
|
||||
connection default;
|
||||
begin;
|
||||
--eval select * from $table for update;
|
||||
|
||||
connection $con_aux;
|
||||
begin;
|
||||
--send_eval $statement;
|
||||
|
||||
--enable_result_log
|
||||
--enable_query_log
|
||||
|
||||
connection default;
|
||||
# Wait until statement is successfully executed while
|
||||
# all rows in table are X-locked. This means that it
|
||||
# does not acquire any row locks.
|
||||
# We use wait_condition.inc instead of simply executing
|
||||
# statement here in order to avoid deadlocks if test
|
||||
# fails and timing out instead.
|
||||
let $wait_condition=
|
||||
select count(*) = 0 from information_schema.processlist
|
||||
where info = "$statement";
|
||||
--source include/wait_condition.inc
|
||||
|
||||
--disable_result_log
|
||||
--disable_query_log
|
||||
|
||||
if ($success)
|
||||
{
|
||||
# Apparently statement was successfully executed and thus it
|
||||
# has not required any row locks.
|
||||
# To be safe against wait_condition.inc succeeding due to
|
||||
# races let us first reap the statement being checked to
|
||||
# ensure that it has been successfully executed.
|
||||
connection $con_aux;
|
||||
--reap
|
||||
rollback;
|
||||
connection default;
|
||||
rollback;
|
||||
--echo Success: '$statement' doesn't take row locks on '$table'.
|
||||
}
|
||||
if (!$success)
|
||||
{
|
||||
# Waiting has timed out. Apparently statement was blocked on
|
||||
# some row lock. So to be able to continue we need to unlock
|
||||
# rows first.
|
||||
rollback;
|
||||
connection $con_aux;
|
||||
--reap
|
||||
rollback;
|
||||
connection default;
|
||||
--echo Error: '$statement' takes some row locks on '$table'!
|
||||
}
|
||||
|
||||
--enable_result_log
|
||||
--enable_query_log
|
61
mysql-test/include/check_shared_row_lock.inc
Normal file
61
mysql-test/include/check_shared_row_lock.inc
Normal file
@ -0,0 +1,61 @@
|
||||
#
|
||||
# SUMMARY
|
||||
# Check if statement reading table '$table' takes shared locks
|
||||
# on some of its rows.
|
||||
#
|
||||
# PARAMETERS
|
||||
# $table Table for which presence of row locks should be checked.
|
||||
# $con_aux Name of auxiliary connection to be used by this script.
|
||||
# $statement Statement to be checked.
|
||||
# $wait_statement Sub-statement which is supposed to acquire locks (should
|
||||
# be the same as $statement for ordinary statements).
|
||||
#
|
||||
# EXAMPLE
|
||||
# innodb_mysql_lock2.test
|
||||
#
|
||||
--disable_result_log
|
||||
--disable_query_log
|
||||
|
||||
connection default;
|
||||
begin;
|
||||
--eval select * from $table for update;
|
||||
|
||||
connection $con_aux;
|
||||
begin;
|
||||
--send_eval $statement;
|
||||
|
||||
--enable_result_log
|
||||
--enable_query_log
|
||||
|
||||
connection default;
|
||||
# Wait until statement is successfully blocked because
|
||||
# all rows in table are X-locked. This means that at
|
||||
# least it acquires S-locks on some of rows.
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state in ("Sending data","statistics", "preparing") and
|
||||
info = "$wait_statement";
|
||||
--source include/wait_condition.inc
|
||||
|
||||
--disable_result_log
|
||||
--disable_query_log
|
||||
|
||||
rollback;
|
||||
|
||||
connection $con_aux;
|
||||
--reap
|
||||
rollback;
|
||||
|
||||
connection default;
|
||||
--enable_result_log
|
||||
--enable_query_log
|
||||
|
||||
if ($success)
|
||||
{
|
||||
--echo Success: '$statement' takes shared row locks on '$table'.
|
||||
}
|
||||
|
||||
if (!$success)
|
||||
{
|
||||
--echo Error: '$statement' hasn't taken shared row locks on '$table'!
|
||||
}
|
Reference in New Issue
Block a user