Description:
When the slave mysqld is started it reads the user name and password from the slave my.cnf and adds it to the mysql.user table. Then if you added the grant permissions to the master these are replicated to the slave. The slave finds that the user already exist and issues an error 121. "MySQL error code 121: Duplicate key on write or update" and stops the slave dead in its tracks.
I do not think that stopping replication due to there being a record that already exists in the user table is the correct action. Instead I think logging the error and allowing replication to continue would be a better solution.
Last_Errno: 121
Last_Error: Error in Write_rows event: error during transaction execution on table mysql.user
Host: %.mysql.com
User: rep
Password: *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
Repl_slave_priv: Y
Repl_client_priv: N
5 rows in set (0.00 sec)
051028 14:10:39 [ERROR] Slave: Error in Write_rows event: row application failed, Error_code: 121051028 14:10:39 [ERROR] Slave: Error in Write_rows event: error during transaction execution on table mysql.user, Error_code: 121
051028 14:10:39 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'master1.000001' position 102
"ndb10.slave.err" 37L, 2467C 37,1 Bot
How to repeat:
Make sure user and password for replication exist in slave my.cnf
Start slave cluster with --skip-slave-start
Start master cluster
reset master;
grant replication for replication user;
reset slave;
start slave;
Suggested fix:
logging the error for user table only and allowing replication to continue would be a better solution.