In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Simple recording, which may be incorrect, mainly records important interfaces for later use.
I. Operation instructions
I built a simple table and inserted a simple data.
Mysql > create table testin (id int); Query OK, 0 rows affected (2.38 sec) mysql > insert into testin values (10); Query OK, 1 row affected (0.02 sec)
Mainly track the experience of this simple insert statement in the insertion process. It mainly focuses on the insertion process and the submission process, not including the other stages in the previous stage.
Here are all the stages that this statement goes through:
| 126Troup2: | THD::enter_stage: 'starting' / root/mysql5.7.14/percona-server-5.7.14-7/sql/conn_handler/socket_connection.cc:100 349 Test2: | | THD::enter_stage:' checking permissions' / root/mysql5.7.14/percona-server-5.7.14-7/sql/auth/sql_authorization.cc:843 359 Troup2: | | | THD::enter_stage: 'Opening tables' / root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_base.cc:5719 1078 Toner 2: | THD::enter_stage:' init' / root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_insert.cc:470 1155 Toner 2: | THD::enter_stage: 'System lock | '/ root/mysql5.7.14/percona-server-5.7.14-7/sql/lock.cc:321 1253 titled 2: | THD::enter_stage:' update' / root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_insert.cc:663 1535 titled 2: | THD::enter_stage: 'end' / root/mysql5.7.14/percona-server-5.7 .14-7/sql/sql_insert.cc:881 1544 Toner 2: | THD::enter_stage: 'query end' / root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_parse.cc:5174 1603 Toner 2: | THD::enter_stage:' closing tables' / root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_parse.cc:5252 1730 T @ 2: | THD::enter_stage: 'freeing items' / root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_parse.cc:5855 1793 Troup2: | | THD::enter_stage:' cleaning up' / root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_parse.cc:1884 1824 Thum2: | THD::enter_stage: 'starting' / root/ Mysql5.7.14/percona-server-5.7.14-7/sql/conn_handler/socket_connection.cc:100
It is mainly focused on:
Updatequery end
Two stages
Second, the general process 1. Optimistic insertion process Sql_cmd_insert::mysql_insert > Sql_cmd_insert::mysql_insert > switch session status to update > enter insertion logic > handler::ha_write_row > ha_innobase::write_row > row_insert_for_mysql > row_insert_for_mysql_using_ins_graph > trx_start_if_not_started_xa_low > trx_start _ low activates things The state of things has changed from not_active to active > row_ins_step > row_ins > row_ins_index_entry_step > row_ins_index_entry > row_ins_clust_index_entry > row_ins_clust_index_entry_low > btr. _ cur_search_to_nth_level find location data > btr_cur_optimistic_insert for optimistic insertion > btr_cur_ins_lock_and_undo > trx_undo_report_row_operation > trx_undo_page_report_insert record undo record of insert > trx_undo_page_set_next_prev_and_add > trx_undof_page_add_undo_rec_log record redo log of undo into redo buffer > page_cur_tuple_insert for insert tuple insertion And the actual insertion operation > redo log of page_cur_insert_rec_write_log record insertion into redo buffer > binlog_log_row > write_locked_table_maps > THD::binlog_write_table_map > binlog_start_trans_and_stmt > binlog_cache_data:: Write_event binlog event is written to binlog cache 2, The submission process enters the submission logic mysql_execute_command > switches the session status to query end > trans_commit_stmt > ha_commit_trans > MYSQL_BIN_LOG::prepare > ha_prepare_low > binlog_prepare generates last_commit > innobase_xa_prepare > trx_prepare_for_mysql > trx_prepare Change the state of things to The state of things has changed from active to prepare > MYSQL_BIN_LOG::commit > MYSQL_BIN_LOG::ordered_commit > MYSQL_BIN_LOG::process_flush_stage_queue > ha_flush_logs > plugin_foreach_with_mask > flush_handlerton > innobase_flush_logs > log_buffer_flush_to_disk > log_write_up_to > log_group_write_buf. Innodb group submission Make sure redo disk is removed > MYSQL_BIN_LOG::flush_thread_caches > binlog_cache_mngr::flush > binlog_cache_data::flush binlog cache to flush to binlog file > MYSQL_BIN_LOG::sync_binlog_file fsync binlog file to os cache disk > MYSQL_BIN_LOG::process_commit_stage_queue > ha_commit_low > innobase_commit > innobase_commit_low > trx_commit_in_memory innodb to submit The state of things changes from prepare to not_active.
You can see that the flow of the whole statement is about
Session state transitions to update
The state of activated things changed from not_active to active.
Find location data
Make optimistic insertion
Record insert's undo record record undo's redo log into redo buffer for insert tuple insertion, and the actual insert operation record inserted redo log into redo buffer
Binlog event is written to binlog cache
Session state transitions to query end
Enter the submission preparation
Binlog prepares innodb layer transaction preparation, the state changes from active to prepare
Enter the submission stage
Innodb makes group submission to ensure that the redo disk is removed from binlog cache to flush to binlog file fsync binlog file to os cache and innodb to submit, and the transaction status is changed from prepare to not_active.
This is just a lot of details about the process, but it might be easier to analyze with an entry function.
3. Alternate stack frame Num Type Disp Enb Address What 1 breakpoint keep y 0x0000000000ebd5f3 in main (int, char**) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/main.cc:25 breakpoint already hit 1 time 5 breakpoint keep y 0x0000000001a90776 in page_cur_insert_rec_write_log (rec_t*, ulint, rec_t*, dict_index_t*) Mtr_t*) at / root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/page/page0cur.cc:964 breakpoint already hit 7 times 8 breakpoint keep y 0x0000000001bc8f96 in trx_undo_page_report_insert (ib_page_t*, trx_t*, dict_index_t*, dtuple_t const* Mtr_t*) at / root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/trx/trx0rec.cc:478 breakpoint already hit 5 times 9 breakpoint keep y 0x0000000001bc84c4 in trx_undof_page_add_undo_rec_log (ib_page_t*, ulint, ulint Mtr_t*) at / root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/trx/trx0rec.cc:67 breakpoint already hit 20 times 10 breakpoint keep y 0x00000000019a932d in innobase_start_trx_and_assign_read_view (handlerton* THD*) at / root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:4499 11 breakpoint keep y 0x0000000001bddbfc in trx_start_low (trx_t* Bool) at / root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/trx/trx0trx.cc:1380 breakpoint already hit 3 times 12 breakpoint keep y 0x0000000001c1e9eb in btr_cur_search_to_nth_level (dict_index_t*, ulint, dtuple_t const*, page_cur_mode_t, ulint, btr_cur_t*, ulint, char const*, ulint Mtr_t*) at / root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/btr/btr0cur.cc:770 breakpoint already hit 13 times 13 breakpoint keep y 0x0000000001859c85 in binlog_start_trans_and_stmt (THD*, Log_event*) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/binlog.cc:9737 breakpoint already hit 1 time 14 breakpoint keep y 0x0000000001845822 in binlog_cache_data::write_event (THD* Log_event*) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/binlog.cc:1114 breakpoint already hit 3 times 15 breakpoint keep y 0x000000000153a2a3 in THD::enter_stage (PSI_stage_info const*, PSI_stage_info*, char const*, char const* Unsigned int) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_class.cc:732 breakpoint already hit 8 times 17 breakpoint keep y 0x0000000001be195a in trx_prepare (trx_t*) at / root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/trx/trx0trx.cc:2947 breakpoint already hit 3 times 19 breakpoint Keep y 0x0000000000f63801 in ha_commit_trans (THD* Bool, bool) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:1684 breakpoint already hit 21 times 21 breakpoint keep y 0x0000000001846901 in binlog_prepare (handlerton*, THD*, bool) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/binlog.cc:1578 breakpoint already hit 3 times 24 breakpoint keep y 0x00000000019c2c64 in innobase_xa_prepare (handlerton*, THD* Bool) at / root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:17458 breakpoint already hit 2 times 25 breakpoint keep y 0x00000000019a9788 in innobase_commit (handlerton*, THD* Bool) at / root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:4652 breakpoint already hit 2 times 26 breakpoint keep y 0x0000000001846442 in binlog_cache_data::flush (THD*, my_off_t* Bool*) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/binlog.cc:1408 breakpoint already hit 2 times 27 breakpoint keep y 0x0000000001857c19 in MYSQL_BIN_LOG::sync_binlog_file (bool) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/binlog.cc:8802 breakpoint already hit 1 time 28 breakpoint keep y 0x0000000001bdf2f5 in trx_commit_in_memory (trx_t*, mtr_t const* Bool) at / root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/trx/trx0trx.cc:1973
Author Wechat:
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.