简单记录如下:
双主情况下跳过相同server id Event的方式:
- IO线程 通过对比SERVER_ID 进行跳过操作
{
mi->set_master_log_pos(mi->get_master_log_pos() + inc_pos);
memcpy(rli->ign_master_log_name_end, mi->get_master_log_name(), FN_REFLEN);
DBUG_ASSERT(rli->ign_master_log_name_end[0]);
rli->ign_master_log_pos_end= mi->get_master_log_pos();
}
- SQL线程构造一个Rotate_log_event
if (rli->ign_master_log_name_end[0])
{
/* We generate and return a Rotate, to make our positions advance */
DBUG_PRINT("info",("seeing an ignored end segment"));
ev= new Rotate_log_event(rli->ign_master_log_name_end,
0, rli->ign_master_log_pos_end, exec_relay_log_event
Rotate_log_event::DUP_NAME);
rli->ign_master_log_name_end[0]= 0;
mysql_mutex_unlock(log_lock);exec_relay_log_event
if (unlikely(!ev))
{
errmsg= "Slave SQL thread failed to create a Rotate event "
"(out of memory?), SHOW SLAVE STATUS may be inaccurate";
goto err;
}
ev->server_id= 0; // don't be ignored by slave SQL thread
DBUG_RETURN(ev);
}
这样这些Event不会写入到relay log,SQL线程也不会读取,同时pos 也会做相应的增加。
网友评论