• unknown's avatar
    Bug #27571 asynchronousity in setting mysql_`query`::error and · 95f3db7b
    unknown authored
               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.
    95f3db7b
binlog_killed_bug27571.test 1.81 KB