1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-07 17:42:39 +03:00
Files
mariadb/mysql-test/t/binlog_killed_bug27571.test
unknown 95f3db7be1 Bug #27571 asynchronousity in setting mysql_query::error and
Query_log_event::error_code

A query can perform completely having the local var error of mysql_$query
zero, where $query in insert, update, delete, load,
and be  binlogged with error_code e.g KILLED_QUERY while there is no
reason do to so.
That can happen because Query_log_event consults thd->killed flag to
evaluate error_code.

Fixed with implementing a scheme suggested and partly implemented at
time of bug@22725 work-on. error_status is cached immediatly after the
control leaves the main rows-loop and that instance always corresponds
to `error' the local of mysql_$query functions. The cached value
is passed to Query_log_event constructor, not the default thd->killed
which can be changed in between of the caching and the constructing.


mysql-test/r/binlog_killed.result:
  results changed
mysql-test/t/binlog_killed.test:
  Demonstrating that effective killing during rows-loop execution leads to the speficied actions:
  binlogging with the error for a query modified a not-transactional table or
  rolling back effects for transactional table;
  
  fixing possible non-determinism with ID when query_log_enabled;
  
  leave commented out tests for multi-update,delete due to another bug;
  
  removing an obsolete tests template;
  
  changing system rm to --remove_file.
sql/log_event.cc:
  adding killed status arg
sql/log_event.h:
  added killed status arg
sql/sql_delete.cc:
  deploying the update part patch for delete, multi-delete
sql/sql_insert.cc:
  deploying the update-part patch for insert..select
sql/sql_load.cc:
  deploying the update-part patch for load data.
  simulation added.
sql/sql_update.cc:
  Impementing the fix as described in the comments left by bug@22725.
  Also simulation of killing after the loop that would affect binlogging in the old code.
mysql-test/t/binlog_killed_bug27571-master.opt:
  post rows-loop killing simulation's options
mysql-test/t/binlog_killed_bug27571.test:
  Checking that if killing happens inbetween of the end of rows loop and
  recording into binlog that will not lead to recording any error incl
  the killed error.
mysql-test/t/binlog_killed_simulate-master.opt:
  simulation options
mysql-test/t/binlog_killed_simulate.test:
  tests for 
  a query (update is choosen) being killed after the row-loop;
  load data killed within the loop - effective killed error in the event is gained.
2007-10-29 15:20:59 +02:00

69 lines
1.8 KiB
Plaintext

--source include/have_innodb.inc
--source include/not_embedded.inc
--source include/have_log_bin.inc
#
# bug#27571 asynchronous setting mysql_`query`::error and Query_log_e::error_code
#
# Checking that if killing happens inbetween of the end of rows loop and
# recording into binlog that will not lead to recording any error incl
# the killed error.
#
connect (looser, localhost, root,,);
connect (killer, localhost, root,,);
create table t1 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB;
delete from t1;
insert into t1 values (1,1),(2,2);
reset master;
connection looser;
let $ID= `select connection_id()`;
send update t1 set b=11 where a=2;
connection killer;
sleep 1; # let 1 second for the update to get to the sleeping point
--replace_result $ID ID
eval kill query $ID;
connection looser;
--error 0 # zero even though the query must be got killed while it was sleepin for 5 secs
reap;
#
# this is another possible artifact. The killed error was not caught
# as that is logical as killing was not effective:
# data are ok and well as binlog event is without killed error (further).
# The reason of the following `show error' is to prove that
# killing simulation was effective
#
show errors;
connection killer;
# nothing is rolled back
select * from t1 where a=2 /* must be 11 */;
# a proof the query is binlogged with an error
--exec $MYSQL_BINLOG --start-position=98 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select
(@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
let $error_code= `select @a like "%#%error_code=0%"`;
eval select $error_code /* must return 1*/;
#
# cleanup
#
drop table t1;
--echo end of the tests