Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SQL thread and sql_slave_skip_counter parameter analysis of slave library

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "from the SQL thread and sql_slave_skip_counter parameter analysis of the library", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "SQL thread and sql_slave_skip_counter parameter analysis from the library".

1. The calling process is roughly as follows: handle_slave_sql-> whether slave_preserve_commit_order and log_slave_updates parameters are enabled. If enabled, you need to set the submission order manager if (opt_slave_preserve_commit_order & & rli- > opt_slave_parallel_workers > 0 & & opt_bin_log & & opt_log_slave_updates) commit_order_mngr= new Commit_order_manager (rli- > opt_slave_parallel_workers). / / order commit manager rli- > set_commit_order_manager (commit_order_mngr);-> if it is MTS, you need to start the worker thread if (slave_start_workers (rli, rli- > opt_slave_parallel_workers, & mts_inited)! = 0) / start the worker thread {mysql_cond_broadcast (& rli- > start_cond); mysql_mutex_unlock (& rli- > run_lock) Rli- > report (ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, ER (ER_SLAVE_FATAL_ERROR), "Failed during slave workers initialization"); goto err -> check whether rep table is a transaction type. If not, warn if (! rli- > is_transactional ()) / / if it is table or file type is table type, transaction rli- > report (WARNING_LEVEL, 0, "If a crash happens this configuration does not guarantee that the relay"log info will be consistent") is supported. -> initialize the access location of relay log if (rli- > init_relay_log_pos (rli- > get_group_relay_log_name (), rli- > get_group_relay_log_pos (), true/*need_data_lock=true*/, & errmsg) 1 / * look for a description_event*/)) / / initialize the access location of the relay log, which is critical, that is, where to start reading our relay log. If an error occurs, it will result in a read relay log error. Therefore, we need to ensure the security of the rep info, if recover relay log is set, it will be initialized to the start position of the latest relay log, because all outstanding binlog event will be pulled again, and the old relay log is no longer important. We'll talk about it later. -> GTID event has no way to use sql_slave_skip_counter. See Log_event::do_shall_skip mysql > set global sql_slave_skip_counter=1; ERROR 1858 (HY000): sql_slave_skip_counter can not be set when the server is running with @ @ GLOBAL.GTID_MODE = ON. Instead, for each transaction that you want to skip, generate an empty transaction with the same GTID as the transaction enter the loop until the SQL thread is killed-> enter the state stage_reading_event_from_the_relay_log-> make a skip event judgment and log output GTID event has no way to use sql_slave_skip_counter its specific meaning reference: Log_event::do_shall_skip mysql > set global sql_slave_skip_counter=1 ERROR 1858 (HY000): sql_slave_skip_counter can not be set when the server is running with @ @ GLOBAL.GTID_MODE = ON. Instead, for each transaction that you want to skip, generate an empty transaction with the same GTID as the transaction-> exec_relay_log_event read the upper layer interface of an event-> next_event reads the checkpoint of the next Event completion MTS-> get the start position rli- > set_event_start_pos (my_b_tell (cur_log)) -> Log_event::read_log_event-> if MTS needs to checkpoint 1, check whether it exceeds the checkpoint cycle set_timespec_nsec (& curr_clock, 0) inside the function mts_checkpoint_routine; ulonglong diff= diff_timespec (& curr_clock, & rli- > last_clock); if (! force & & diff)

< period) { /* We do not need to execute the checkpoint now because the time elapsed is not enough. */ DBUG_RETURN(FALSE); } 2、是否已经GAQ已经满了 bool force= (rli->

Checkpoint_seqno > (rli- > checkpoint_group-1)) / / if the size of GAQ is set to force to force checkpoint-> whether the relay log size has reached the maximum, whether relay log switching is required, but it should be noted that you cannot switch if this thing is not finished / * If we have reached the limit of the relay space and we if we reach the relay_log_space_limit limit, we need to notify IO THREAD to switch the clean space ```are going to sleep Waiting for more events: 1. If outside a group SQL thread asks the IO thread to force a rotation so that the SQL thread purges logs next time it processes an event (thus space Is freed). 2. If in a group SQL thread asks the IO thread to ignore the limit and queues yet one more event so that the SQL thread finishes the group And is are able to rotate and purge sometime soon. * / if (rli- > log_space_limit & & Rli- > log_space_limit

< rli->

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report