diff --git a/mysql-test/include/restart_mysqld.inc b/mysql-test/include/restart_mysqld.inc index 7cb9c7994d8..49f6dfd5364 100644 --- a/mysql-test/include/restart_mysqld.inc +++ b/mysql-test/include/restart_mysqld.inc @@ -14,8 +14,8 @@ if ($rpl_inited) --exec echo "wait" > $_expect_file_name # Send shutdown to the connected server and give -# it 10 seconds to die before zapping it -shutdown_server 10; +# it 60 seconds to die before zapping it +shutdown_server 60; # Write file to make mysql-test-run.pl start up the server again --exec echo "restart" > $_expect_file_name diff --git a/mysql-test/suite/binlog/t/binlog_mdev342.test b/mysql-test/suite/binlog/t/binlog_mdev342.test index 02310b87a76..024fa884f91 100644 --- a/mysql-test/suite/binlog/t/binlog_mdev342.test +++ b/mysql-test/suite/binlog/t/binlog_mdev342.test @@ -44,8 +44,7 @@ connection con1; --error 2006,2013 reap; ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect restart-binlog_mdev342.test EOF diff --git a/mysql-test/suite/binlog/t/binlog_xa_recover.test b/mysql-test/suite/binlog/t/binlog_xa_recover.test index d3914e60b10..903044ca5bd 100644 --- a/mysql-test/suite/binlog/t/binlog_xa_recover.test +++ b/mysql-test/suite/binlog/t/binlog_xa_recover.test @@ -117,8 +117,7 @@ connection con4; --error 2006,2013 reap; ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect restart-group_commit_binlog_pos.test EOF @@ -212,8 +211,7 @@ SET SESSION debug_dbug="+d,crash_commit_after_log"; --error 2006,2013 INSERT INTO t1 VALUES (14, NULL); ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect restart-group_commit_binlog_pos.test EOF @@ -257,8 +255,7 @@ SET SESSION debug_dbug="+d,crash_before_write_checkpoint_event"; --error 2006,2013 INSERT INTO t1 VALUES (24, REPEAT("x", 4100)); ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect restart-group_commit_binlog_pos.test EOF diff --git a/mysql-test/suite/innodb/t/innodb_bug12902967.test b/mysql-test/suite/innodb/t/innodb_bug12902967.test index 1183c4ceff6..8e1b8199524 100644 --- a/mysql-test/suite/innodb/t/innodb_bug12902967.test +++ b/mysql-test/suite/innodb/t/innodb_bug12902967.test @@ -24,7 +24,7 @@ alter table t1 add constraint c1 foreign key (f1) references t1(f1); perl; $file = $ENV{error_log}; open (FILE, '<', $file) or die "can't open(< $file): $!\n"; -print ((grep { /^InnoDB:/ and not /aio/i } )[-2..-1]); +print ((grep { /^InnoDB:/ and not /aio/i and not /io_setup\(\) attempt [0-9]+ failed/ } )[-2..-1]); EOF drop table t1; diff --git a/mysql-test/suite/rpl/t/rpl_gtid_crash.test b/mysql-test/suite/rpl/t/rpl_gtid_crash.test index ce3ccb9d05e..19fe20d0d56 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_crash.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_crash.test @@ -53,8 +53,7 @@ SET SESSION debug_dbug="+d,crash_dispatch_command_before"; SELECT 1; --source include/wait_until_disconnected.inc ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect restart-rpl_gtid_crash.test EOF @@ -113,8 +112,7 @@ SET SESSION debug_dbug="+d,crash_dispatch_command_before"; SELECT 1; --source include/wait_until_disconnected.inc ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect restart EOF @@ -148,8 +146,7 @@ INSERT INTO t1 VALUES (4); --connection server_2 --source include/wait_until_disconnected.inc ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect restart: --skip-slave-start=0 EOF @@ -173,8 +170,7 @@ INSERT INTO t1 VALUES (5); --connection server_2 --source include/wait_until_disconnected.inc ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect restart: --skip-slave-start=0 EOF @@ -198,8 +194,7 @@ INSERT INTO t1 VALUES (6); --connection server_2 --source include/wait_until_disconnected.inc ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect restart: --skip-slave-start=0 EOF @@ -223,8 +218,7 @@ INSERT INTO t1 VALUES (7); --connection server_2 --source include/wait_until_disconnected.inc ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect restart: --skip-slave-start=0 EOF @@ -248,8 +242,7 @@ INSERT INTO t1 VALUES (8); --connection server_2 --source include/wait_until_disconnected.inc ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect restart: --skip-slave-start=0 EOF diff --git a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test index a0665110792..262d86a294e 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test @@ -41,8 +41,7 @@ INSERT INTO t1 VALUES (3); --source include/show_binary_logs.inc # Let the slave mysqld server start again. ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect restart: --skip-slave-start=0 EOF @@ -72,8 +71,7 @@ EOF --shutdown_server 30 --source include/wait_until_disconnected.inc ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect restart EOF diff --git a/mysql-test/suite/rpl/t/rpl_mdev382.test b/mysql-test/suite/rpl/t/rpl_mdev382.test index 5df382f6f06..3e4031d989b 100644 --- a/mysql-test/suite/rpl/t/rpl_mdev382.test +++ b/mysql-test/suite/rpl/t/rpl_mdev382.test @@ -210,8 +210,7 @@ EOF --shutdown_server 30 ---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect restart-rpl_mdev382.test EOF diff --git a/mysql-test/suite/storage_engine/alter_tablespace.test b/mysql-test/suite/storage_engine/alter_tablespace.test index 508639c7dc5..ac206b8e328 100644 --- a/mysql-test/suite/storage_engine/alter_tablespace.test +++ b/mysql-test/suite/storage_engine/alter_tablespace.test @@ -53,8 +53,7 @@ EOF --replace_result $datadir --copy_file $datadir/test/t1.ibd $datadir/test/t1.ibd.save - --remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect - --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect restart EOF diff --git a/sql/log_event.cc b/sql/log_event.cc index 90ec5f52178..4b7c022aebb 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -4236,8 +4236,19 @@ Query_log_event::do_shall_skip(Relay_log_info *rli) bool Query_log_event::peek_is_commit_rollback(const char *event_start, - size_t event_len) + size_t event_len, uint8 checksum_alg) { + if (checksum_alg == BINLOG_CHECKSUM_ALG_CRC32) + { + if (event_len > BINLOG_CHECKSUM_LEN) + event_len-= BINLOG_CHECKSUM_LEN; + else + event_len= 0; + } + else + DBUG_ASSERT(checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF || + checksum_alg == BINLOG_CHECKSUM_ALG_OFF); + if (event_len < LOG_EVENT_HEADER_LEN + QUERY_HEADER_LEN || event_len < 9) return false; return !memcmp(event_start + (event_len-7), "\0COMMIT", 7) || @@ -6050,10 +6061,23 @@ Gtid_log_event::Gtid_log_event(THD *thd_arg, uint64 seq_no_arg, */ bool Gtid_log_event::peek(const char *event_start, size_t event_len, + uint8 checksum_alg, uint32 *domain_id, uint32 *server_id, uint64 *seq_no, uchar *flags2) { const char *p; + + if (checksum_alg == BINLOG_CHECKSUM_ALG_CRC32) + { + if (event_len > BINLOG_CHECKSUM_LEN) + event_len-= BINLOG_CHECKSUM_LEN; + else + event_len= 0; + } + else + DBUG_ASSERT(checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF || + checksum_alg == BINLOG_CHECKSUM_ALG_OFF); + if (event_len < LOG_EVENT_HEADER_LEN + GTID_HEADER_LEN) return true; *server_id= uint4korr(event_start + SERVER_ID_OFFSET); @@ -6100,7 +6124,7 @@ Gtid_log_event::make_compatible_event(String *packet, bool *need_dummy_event, flags2= (*packet)[ev_offset + LOG_EVENT_HEADER_LEN + 12]; if (flags2 & FL_STANDALONE) { - if (need_dummy_event) + if (*need_dummy_event) return Query_log_event::dummy_event(packet, ev_offset, checksum_alg); else return 0; diff --git a/sql/log_event.h b/sql/log_event.h index 1c2b2769915..5026b280b27 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -1946,7 +1946,7 @@ public: /* !!! Public in this patch to allow old usage */ const char *query_arg, uint32 q_len_arg); static bool peek_is_commit_rollback(const char *event_start, - size_t event_len); + size_t event_len, uint8 checksum_alg); #endif /* HAVE_REPLICATION */ /* If true, the event always be applied by slave SQL thread or be printed by @@ -3084,6 +3084,7 @@ public: static int make_compatible_event(String *packet, bool *need_dummy_event, ulong ev_offset, uint8 checksum_alg); static bool peek(const char *event_start, size_t event_len, + uint8 checksum_alg, uint32 *domain_id, uint32 *server_id, uint64 *seq_no, uchar *flags2); #endif diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 3434228b540..fd8b990b6c3 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1595,8 +1595,21 @@ static void close_connections(void) Events::deinit(); end_slave(); - /* Give threads time to die. */ - for (int i= 0; *(volatile int32*) &thread_count && i < 100; i++) + /* + Give threads time to die. + + In 5.5, this was waiting 100 rounds @ 20 milliseconds/round, so as little + as 2 seconds, depending on thread scheduling. + + From 10.0, we increase this to 1000 rounds / 20 seconds. The rationale is + that on a server with heavy I/O load, it is quite possible for eg. an + fsync() of the binlog or whatever to cause something like LOCK_log to be + held for more than 2 seconds. We do not want to force kill threads in + such cases, if it can be avoided. Note that normally, the wait will be + much smaller than even 2 seconds, this is only a safety fallback against + stuck threads so server shutdown is not held up forever. + */ + for (int i= 0; *(volatile int32*) &thread_count && i < 1000; i++) my_sleep(20000); /* diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 42d54044b5a..3eaa00e992c 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1160,7 +1160,8 @@ gtid_state_from_pos(const char *name, uint32 offset, { rpl_gtid gtid; uchar flags2; - if (Gtid_log_event::peek(packet.ptr(), packet.length(), >id.domain_id, + if (Gtid_log_event::peek(packet.ptr(), packet.length(), + current_checksum_alg, >id.domain_id, >id.server_id, >id.seq_no, &flags2)) { errormsg= "Corrupt gtid_log_event found while scanning binlog to find " @@ -1253,6 +1254,7 @@ send_event_to_slave(THD *thd, NET *net, String* const packet, ushort flags, if (ev_offset > len || Gtid_log_event::peek(packet->ptr()+ev_offset, len - ev_offset, + current_checksum_alg, &domain_id, &server_id, &seq_no, &flags2)) return "Failed to read Gtid_log_event: corrupt binlog"; gtid= gtid_state->find(domain_id); @@ -1287,7 +1289,8 @@ send_event_to_slave(THD *thd, NET *net, String* const packet, ushort flags, if (event_type == XID_EVENT || (event_type == QUERY_EVENT && Query_log_event::peek_is_commit_rollback(packet->ptr() + ev_offset, - len - ev_offset))) + len - ev_offset, + current_checksum_alg))) *gtid_skip_group= GTID_SKIP_NOT; return NULL; case GTID_SKIP_NOT: @@ -1727,13 +1730,15 @@ impossible position"; while (!net->error && net->vio != 0 && !thd->killed) { Log_event_type event_type= UNKNOWN_EVENT; + killed_state killed; /* reset the transmit packet for the event read from binary log file */ if (reset_transmit_packet(thd, flags, &ev_offset, &errmsg)) goto err; - while (!(error = Log_event::read_log_event(&log, packet, log_lock, + while (!(killed= thd->killed) && + !(error = Log_event::read_log_event(&log, packet, log_lock, current_checksum_alg))) { #ifndef DBUG_OFF @@ -1818,6 +1823,8 @@ impossible position"; if (reset_transmit_packet(thd, flags, &ev_offset, &errmsg)) goto err; } + if (killed) + goto end; /* TODO: now that we are logging the offset, check to make sure