What is the way to skip Event in the case of two hosts in MySQL
This article introduces the relevant knowledge of "what is the way to skip Event in the case of two hosts in MySQL". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
How to skip the same server id Event in the case of two hosts:
IO threads skip operations by comparing 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 ();}
The SQL thread constructs a 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);}
In this way, these Event will not be written to the relay log,SQL thread or read, and the pos will be increased accordingly.
This is the end of the content of "what is the way to skip Event in the case of two hosts in MySQL". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!