Bug #30434 Rep: Create Index Extra Column on master causes SQL thread to stop
Submitted: 15 Aug 2007 13:02 Modified: 24 Dec 2012 8:23
Reporter: Jonathan Miller Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:mysql5.1-telco-6.2 OS:Linux
Assigned to: Mats Kindahl CPU Architecture:Any

[15 Aug 2007 13:02] Jonathan Miller
Description:
Creating an index on the master table for a column that does not exist on slave causes SQL Thread to stop

070815 15:56:16 [ERROR] Slave: Error 'Key column 'c6' doesn't exist in table' on query. Default database: 'test'. Query: 'CREATE INDEX part_of_c6 ON t16 (c6)', Error_code: 1072
070815 15:56:16 [Warning] Slave: Key column 'c6' doesn't exist in table Error_code: 1072
070815 15:56:16 [Warning] Slave: Unknown error Error_code: 1105

How to repeat:
####################################################
# - Create index on Master column not on slave     #
#   Expect:Warning                                 #
####################################################

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

--echo *** Create t16 on Master ***
connection master;
eval CREATE TABLE t16 (c1 INT KEY, c4 BLOB, c5 CHAR(5),
                       ) ENGINE=$engine_type;

--echo *** Create t16 on Master ***
connection master;
eval CREATE TABLE t16 (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;
CREATE INDEX part_of_c6 ON t16 (c6);

Suggested fix:
Should issues warning, but not stop execution of slave SQL Thread
[30 Nov 2007 19:30] Jonathan Miller
071130 22:28:15 [ERROR] Slave SQL: Error 'Key column 'c6' doesn't exist in table' on qu
ery. Default database: 'test'. Query: 'CREATE INDEX part_of_c6 ON t16 (c6)', Error_code
: 1072
071130 22:28:15 [Warning] Slave: Key column 'c6' doesn't exist in table Error_code: 107
2
071130 22:28:15 [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 106
[24 Dec 2012 8:23] Erlend Dahl
From the 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.