diff options
author | unknown <aelkin/elkin@koti.dsl.inet.fi> | 2007-10-29 15:20:59 +0200 |
---|---|---|
committer | unknown <aelkin/elkin@koti.dsl.inet.fi> | 2007-10-29 15:20:59 +0200 |
commit | 95f3db7be1b3425b47f34090f33c7eeb52f97703 (patch) | |
tree | 7ee3c865779ddc72072daa205d4b5d3c3c0280fa /sql/sql_load.cc | |
parent | c8b6d1050933f0b9b18367c421702c9f16907de5 (diff) | |
download | mariadb-git-95f3db7be1b3425b47f34090f33c7eeb52f97703.tar.gz |
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.
Diffstat (limited to 'sql/sql_load.cc')
-rw-r--r-- | sql/sql_load.cc | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 0dc02ac4a68..d687ceff393 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -85,7 +85,8 @@ static int read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, #ifndef EMBEDDED_LIBRARY static bool write_execute_load_query_log_event(THD *thd, bool duplicates, bool ignore, - bool transactional_table); + bool transactional_table, + THD::killed_state killed_status); #endif /* EMBEDDED_LIBRARY */ /* @@ -135,6 +136,7 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, char *tdb= thd->db ? thd->db : db; // Result is never null ulong skip_lines= ex->skip_lines; bool transactional_table; + THD::killed_state killed_status= THD::NOT_KILLED; DBUG_ENTER("mysql_load"); #ifdef EMBEDDED_LIBRARY @@ -404,7 +406,16 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, free_blobs(table); /* if pack_blob was used */ table->copy_blobs=0; thd->count_cuted_fields= CHECK_FIELD_IGNORE; - + /* + simulated killing in the middle of per-row loop + must be effective for binlogging + */ + DBUG_EXECUTE_IF("simulate_kill_bug27571", + { + error=1; + thd->killed= THD::KILL_QUERY; + };); + killed_status= (error == 0)? THD::NOT_KILLED : thd->killed; /* We must invalidate the table in query cache before binlog writing and ha_autocommit_... @@ -446,7 +457,8 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, { if (thd->transaction.stmt.modified_non_trans_table) write_execute_load_query_log_event(thd, handle_duplicates, - ignore, transactional_table); + ignore, transactional_table, + killed_status); else { Delete_file_log_event d(thd, db, transactional_table); @@ -477,7 +489,8 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, read_info.end_io_cache(); if (lf_info.wrote_create_file) write_execute_load_query_log_event(thd, handle_duplicates, - ignore, transactional_table); + ignore, transactional_table, + killed_status); } #endif /*!EMBEDDED_LIBRARY*/ if (transactional_table) @@ -504,7 +517,8 @@ err: /* Not a very useful function; just to avoid duplication of code */ static bool write_execute_load_query_log_event(THD *thd, bool duplicates, bool ignore, - bool transactional_table) + bool transactional_table, + THD::killed_state killed_err_arg) { Execute_load_query_log_event e(thd, thd->query, thd->query_length, @@ -512,7 +526,7 @@ static bool write_execute_load_query_log_event(THD *thd, (char*)thd->lex->fname_end - (char*)thd->query, (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE : (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR), - transactional_table, FALSE); + transactional_table, FALSE, killed_err_arg); return mysql_bin_log.write(&e); } |