1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Bug#20041860: SLAVE ERROR WHEN DROP DATABASE

Fix:
===
Backport Bug#11756194 to mysql-5.5. slave breaks if
'drop database' fails on master and mismatched tables on
slave.

'DROP TABLE <deleted tables>' was binlogged when
'DROP DATABASE' failed and at least one table was deleted
from the database. The log event would lead slave SQL thread
stop if some of the tables did not exist on slave.

After this patch, It is always binlogged with 'IF EXISTS'
option.
This commit is contained in:
s.sujatha
2014-12-29 12:17:55 +05:30
parent 901ce5314b
commit 5da083ef67
5 changed files with 150 additions and 5 deletions

View File

@@ -39,10 +39,31 @@ master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE `tt1` /* generated by server */
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
FLUSH STATUS;
# 'DROP TABLE IF EXISTS <deleted tables>' is binlogged
# when 'DROP DATABASE' fails and at least one table is deleted
# from the database.
RESET MASTER;
CREATE DATABASE testing_1;
USE testing_1;
CREATE TABLE t1(c1 INT);
CREATE TABLE t2(c1 INT);
# Create a file in the database directory
SELECT 'hello' INTO OUTFILE 'fake_file.FAKE_FILE';
# 'DROP DATABASE' will fail if there is any other file in the the
# database directory
DROP DATABASE testing_1;
ERROR HY000: Error dropping database (can't rmdir './testing_1/', errno: 17)
# Remove the fake file.
# Now we can drop the database.
DROP DATABASE testing_1;
#
# Bug#11765416 58381: FAILED DROP DATABASE CAN BREAK STATEMENT
# BASED REPLICATION
#
USE test;
DROP DATABASE IF EXISTS db1;
DROP TABLE IF EXISTS t3;
CREATE DATABASE db1;
@@ -58,7 +79,7 @@ Tables_in_db1
t2
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `db1`; DROP TABLE `t1`
master-bin.000001 # Query # # use `db1`; DROP TABLE IF EXISTS `t1`
DROP TABLE t3;
DROP DATABASE db1;
set binlog_format=mixed;
@@ -102,10 +123,31 @@ master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE `tt1` /* generated by server */
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
FLUSH STATUS;
# 'DROP TABLE IF EXISTS <deleted tables>' is binlogged
# when 'DROP DATABASE' fails and at least one table is deleted
# from the database.
RESET MASTER;
CREATE DATABASE testing_1;
USE testing_1;
CREATE TABLE t1(c1 INT);
CREATE TABLE t2(c1 INT);
# Create a file in the database directory
SELECT 'hello' INTO OUTFILE 'fake_file.FAKE_FILE';
# 'DROP DATABASE' will fail if there is any other file in the the
# database directory
DROP DATABASE testing_1;
ERROR HY000: Error dropping database (can't rmdir './testing_1/', errno: 17)
# Remove the fake file.
# Now we can drop the database.
DROP DATABASE testing_1;
#
# Bug#11765416 58381: FAILED DROP DATABASE CAN BREAK STATEMENT
# BASED REPLICATION
#
USE test;
DROP DATABASE IF EXISTS db1;
DROP TABLE IF EXISTS t3;
CREATE DATABASE db1;
@@ -121,7 +163,7 @@ Tables_in_db1
t2
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `db1`; DROP TABLE `t1`
master-bin.000001 # Query # # use `db1`; DROP TABLE IF EXISTS `t1`
DROP TABLE t3;
DROP DATABASE db1;
set binlog_format=row;
@@ -166,10 +208,31 @@ master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`tt1` /* generated by server */
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
FLUSH STATUS;
# 'DROP TABLE IF EXISTS <deleted tables>' is binlogged
# when 'DROP DATABASE' fails and at least one table is deleted
# from the database.
RESET MASTER;
CREATE DATABASE testing_1;
USE testing_1;
CREATE TABLE t1(c1 INT);
CREATE TABLE t2(c1 INT);
# Create a file in the database directory
SELECT 'hello' INTO OUTFILE 'fake_file.FAKE_FILE';
# 'DROP DATABASE' will fail if there is any other file in the the
# database directory
DROP DATABASE testing_1;
ERROR HY000: Error dropping database (can't rmdir './testing_1/', errno: 17)
# Remove the fake file.
# Now we can drop the database.
DROP DATABASE testing_1;
#
# Bug#11765416 58381: FAILED DROP DATABASE CAN BREAK STATEMENT
# BASED REPLICATION
#
USE test;
DROP DATABASE IF EXISTS db1;
DROP TABLE IF EXISTS t3;
CREATE DATABASE db1;
@@ -185,7 +248,7 @@ Tables_in_db1
t2
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `db1`; DROP TABLE `t1`
master-bin.000001 # Query # # use `db1`; DROP TABLE IF EXISTS `t1`
DROP TABLE t3;
DROP DATABASE db1;
show databases;