Bug #30415 Rep: DROP Extra Column from master causes SQL thread to stop
Submitted: 14 Aug 2007 18:00 Modified: 24 Dec 2012 8:21
Reporter: Jonathan Miller Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:mysql5.1-telco-6.2 OS:Linux
Assigned to: Mats Kindahl CPU Architecture:Any

[14 Aug 2007 18:00] Jonathan Miller
Description:
When dropping an extra column from the end of the master table, the slave SQL thread stops with:

Last_Errno      1091 Last_Error      Error 'Can't DROP 'c7'; check that column/key exists' on query. Default database: 'test'. Query: 'ALTER TABLE t14 DROP COLUMN c7'

How to repeat:
--echo *** Create t14 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t14 (c1 INT PRIMARY KEY, c4 BLOB, c5 CHAR(5)
                       ) ENGINE=$engine_type;

--echo *** Create t14 on Master ***
connection master;
eval CREATE TABLE t14 (c1 INT KEY, c4 BLOB, c5 CHAR(5),
                      c6 INT DEFAULT '1',
                      c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
                      )ENGINE=$engine_type;

RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;
ALTER TABLE t14 ADD COLUMN c2 DECIMAL(8,2) AFTER c1;
ALTER TABLE t14 ADD COLUMN c3 TEXT AFTER c2;
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
INSERT INTO t14 () VALUES(1,1.00,'Replication Testing Extra Col',@b1,'Kyle',DEFAULT,DEFAULT),
                        (2,2.00,'This Test Should work',@b1,'JOE',DEFAULT,DEFAULT),
                        (3,3.00,'If is does not, I will open a bug',@b1,'QA',DEFAULT,DEFAULT);
--replace_column 7 CURRENT_TIMESTAMP
SELECT * FROM t14 ORDER BY c1;
--echo *** Select on Slave ****
sync_slave_with_master;
SELECT * FROM t14 ORDER BY c1;

####################################################
# - Alter Master Dropping columns from the middle. #
#   Expect: columns dropped                        #
####################################################

--echo *** connect to master and drop columns ***
connection master;
ALTER TABLE t14 DROP COLUMN c2;
ALTER TABLE t14 DROP COLUMN c7;
--echo *** Select from Master ***
SELECT * FROM t14 ORDER BY c1;

#--echo *** Select from Slave ***
#sync_slave_with_master;
#SELECT * FROM t14 ORDER BY c1;

connection slave;
wait_for_slave_to_stop;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 #
--query_vertical SHOW SLAVE STATUS
STOP SLAVE;
RESET SLAVE;
--echo *** Drop t14  ***
DROP TABLE t14;

connection master;
DROP TABLE t14;
RESET MASTER;

Suggested fix:
A warning should be issues to the slave error log, but SQL thread should not stop.
[30 Nov 2007 19:21] Jonathan Miller
From latest mysql-5.1-new-rpl clone

071130 22:18:42 [ERROR] Slave SQL: Error 'Can't DROP 'c7'; check that column/key exists
' on query. Default database: 'test'. Query: 'ALTER TABLE t14 DROP COLUMN c7', Error_co
de: 1091
071130 22:18:42 [Warning] Slave: Can't DROP 'c7'; check that column/key exists Error_co
de: 1091
071130 22:18:42 [ERROR] Error running query, slave SQL thread aborted. Fix the problem,
 and restart the slave SQL thread with "SLAVE START". We stopped at log 'master-bin.000
001' position 735
071130 22:19:13 [Note] Got signal 15 to shutdown mysqld

To repeat, 

edit /mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test

search for bug 30415 and uncomment the slave line that are commented out.

Best wishes,
Jonathan
[24 Dec 2012 8:21] Erlend Dahl
From internal bug system:

[11 Dec 2012 5:50] Sven Sandberg (SVSANDB)

I think the error is expected. If you use different table definitions on
master and slave, and execute a statement that only works on master's table
definition, then surely the slave will generate an error. No reason to demote
this to a warning - maybe the difference between master is expected in some
applications and unexpected in others.

The workaround is to disable binary logging while executing statements that
do not work on slave.

Seems this bug stems from an internal test case - if there is a real use
case, please explain and re-open the bug.