diff --git a/client/mysql.cc b/client/mysql.cc index 715d74f18b2..60f724863ff 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2671,7 +2671,7 @@ You can turn off this feature to get a quicker startup with -A\n\n"); mysql_free_result(fields); break; } - field_names[i][num_fields*2]= '\0'; + field_names[i][num_fields*2]= NULL; j=0; while ((sql_field=mysql_fetch_field(fields))) { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 99d3203fb51..8086c641d11 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -100,6 +100,8 @@ use mtr_results; use IO::Socket::INET; use IO::Select; +push @INC, "."; + require "lib/mtr_process.pl"; require "lib/mtr_io.pl"; require "lib/mtr_gcov.pl"; diff --git a/mysql-test/suite/rpl/r/rpl_bug72457.result b/mysql-test/suite/rpl/r/rpl_bug72457.result new file mode 100644 index 00000000000..308ddb71197 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_bug72457.result @@ -0,0 +1,38 @@ +# +# Bug #72457 "Replication with no tmpdir space can break replication" +# (https://bugs.mysql.com/bug.php?id=72457) +# Bug #86991 "binlog corruption when tmpdir gets full" +# (https://bugs.mysql.com/bug.php?id=86991) +# Bug #88223 "Replication with no tmpdir space and InnoDB as tmp_storage_engine can break" +# (https://bugs.mysql.com/bug.php?id=88223) +# +include/master-slave.inc +[connection master] +call mtr.add_suppression("Slave SQL: The incident LOST_EVENTS occured on the master\\. Message: error writing to the binary log"); +CREATE TABLE t1(f1 TEXT) ENGINE=MyISAM; +INSERT INTO t1 VALUES(MD5(1)); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +include/rpl_sync.inc +[connection master] +SET SESSION debug = "+d,simulate_disk_full_at_flush_pending"; +INSERT INTO t1 SELECT * FROM t1; +ERROR HY000: Error writing file (Errcode: ##) +SET SESSION debug = "-d,simulate_disk_full_at_flush_pending"; +[connection slave] +include/wait_for_slave_sql_error.inc [errno=1590] +Last_SQL_Error = 'The incident LOST_EVENTS occured on the master. Message: error writing to the binary log' +include/stop_slave_io.inc +RESET SLAVE; +DROP TABLE t1; +[connection master] +DROP TABLE t1; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_bug72457.test b/mysql-test/suite/rpl/t/rpl_bug72457.test new file mode 100644 index 00000000000..cb16be00e27 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_bug72457.test @@ -0,0 +1,49 @@ +--source include/have_debug.inc +--source include/have_binlog_format_row.inc +--source include/have_log_bin.inc + +--echo # +--echo # Bug #72457 "Replication with no tmpdir space can break replication" +--echo # (https://bugs.mysql.com/bug.php?id=72457) +--echo # Bug #86991 "binlog corruption when tmpdir gets full" +--echo # (https://bugs.mysql.com/bug.php?id=86991) +--echo # Bug #88223 "Replication with no tmpdir space and InnoDB as tmp_storage_engine can break" +--echo # (https://bugs.mysql.com/bug.php?id=88223) +--echo # + +--source include/master-slave.inc + +call mtr.add_suppression("Slave SQL: The incident LOST_EVENTS occured on the master\\. Message: error writing to the binary log"); + +CREATE TABLE t1(f1 TEXT) ENGINE=MyISAM; +INSERT INTO t1 VALUES(MD5(1)); + +--let $i = 10 +while($i) +{ + INSERT INTO t1 SELECT * FROM t1; + --dec $i +} +--source include/rpl_sync.inc + +--source include/rpl_connection_master.inc +SET SESSION debug = "+d,simulate_disk_full_at_flush_pending"; +--replace_regex /Error writing file .*/Error writing file (Errcode: ##)/ +--error 3 +INSERT INTO t1 SELECT * FROM t1; +SET SESSION debug = "-d,simulate_disk_full_at_flush_pending"; + +--source include/rpl_connection_slave.inc +# 1590 == ER_SLAVE_INCIDENT +--let $slave_sql_errno = 1590 +--let $show_slave_sql_error = 1 +--source include/wait_for_slave_sql_error.inc +--source include/stop_slave_io.inc +RESET SLAVE; +DROP TABLE t1; + +--source include/rpl_connection_master.inc +DROP TABLE t1; + +--let $rpl_only_running_threads = 1 +--source include/rpl_end.inc diff --git a/sql/log.cc b/sql/log.cc index 493aae8f2ff..f05ed46dafc 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1968,23 +1968,33 @@ void MYSQL_BIN_LOG::set_write_error(THD *thd, bool is_transactional) DBUG_VOID_RETURN; } +static bool check_write_error_code(uint error_code) +{ + return error_code == ER_TRANS_CACHE_FULL || + error_code == ER_STMT_CACHE_FULL || + error_code == ER_ERROR_ON_WRITE || + error_code == ER_BINLOG_LOGGING_IMPOSSIBLE; +} + bool MYSQL_BIN_LOG::check_write_error(THD *thd) { DBUG_ENTER("MYSQL_BIN_LOG::check_write_error"); - bool checked= FALSE; - if (!thd->is_error()) - DBUG_RETURN(checked); + DBUG_RETURN(false); + + bool checked= check_write_error_code(thd->stmt_da->sql_errno()); - switch (thd->stmt_da->sql_errno()) + if (!checked) { - case ER_TRANS_CACHE_FULL: - case ER_STMT_CACHE_FULL: - case ER_ERROR_ON_WRITE: - case ER_BINLOG_LOGGING_IMPOSSIBLE: - checked= TRUE; - break; + /* Check all conditions for one that matches the expected error */ + const MYSQL_ERROR *err; + List_iterator_fast it(thd->warning_info->warn_list()); + + while ((err= it++) != NULL && !checked) + { + checked= check_write_error_code(err->get_sql_errno()); + } } DBUG_RETURN(checked);