赞
踩
本文是我《深入理解MySQL主从原理》 系列的笔记部分,具体可以点击:ttps://j.youzan.com/yEY_Xi
slave_rows_search_algorithms默认。
一些debug的断点:
1、主库
delete from tkkk where a=15;
删除3条记录
-
- #0 btr_cur_search_to_nth_level (index=0x7ffedc1d3180, level=0, tuple=0x7ffedc1d4260, mode=PAGE_CUR_GE, latch_mode=1, cursor=0x7ffedc1d4070, has_search_latch=0,
- file=0x23a5988 "/mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc", line=5176, mtr=0x7fffec5ea240)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/btr/btr0cur.cc:770
- #1 0x0000000001bec437 in btr_pcur_open_with_no_init_func (index=0x7ffedc1d3180, tuple=0x7ffedc1d4260, mode=PAGE_CUR_GE, latch_mode=1, cursor=0x7ffedc1d4070,
- has_search_latch=0, file=0x23a5988 "/mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc", line=5176, mtr=0x7fffec5ea240)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/include/btr0pcur.ic:521
- #2 0x0000000001bf73f1 in row_search_mvcc (buf=0x7ffedc030a50 "\377", mode=PAGE_CUR_GE, prebuilt=0x7ffedc1d3e50, match_mode=1, direction=0)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc:5176
- #3 0x0000000001a53113 in ha_innobase::index_read (this=0x7ffedc02f020, buf=0x7ffedc030a50 "\377", key_ptr=0x7ffedc1d7c00 "", key_len=5, find_flag=HA_READ_KEY_EXACT)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/handler/ha_innodb.cc:9536
- #4 0x0000000000f933c2 in handler::index_read_map (this=0x7ffedc02f020, buf=0x7ffedc030a50 "\377", key=0x7ffedc1d7c00 "", keypart_map=1, find_flag=HA_READ_KEY_EXACT)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.h:2942
- #5 0x0000000000f83dac in handler::ha_index_read_map (this=0x7ffedc02f020, buf=0x7ffedc030a50 "\377", key=0x7ffedc1d7c00 "", keypart_map=1,
- find_flag=HA_READ_KEY_EXACT) at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:3248
- #6 0x0000000000f8e844 in handler::read_range_first (this=0x7ffedc02f020, start_key=0x7ffedc02f108, end_key=0x7ffedc02f128, eq_range_arg=true, sorted=true)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:7750
- #7 0x0000000000f8c775 in handler::multi_range_read_next (this=0x7ffedc02f020, range_info=0x7fffec5eb6a0)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:6817
- #8 0x0000000000f8d68d in DsMrr_impl::dsmrr_next (this=0x7ffedc02f490, range_info=0x7fffec5eb6a0) at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:7204
- #9 0x0000000001a6689a in ha_innobase::multi_range_read_next (this=0x7ffedc02f020, range_info=0x7fffec5eb6a0)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/handler/ha_innodb.cc:22211
- #10 0x00000000017bdbd8 in QUICK_RANGE_SELECT::get_next (this=0x7ffedc1cfa40) at /mysqldata/percona-server-locks-detail-5.7.22/sql/opt_range.cc:11237
- #11 0x00000000014e27f5 in rr_quick (info=0x7fffec5eb990) at /mysqldata/percona-server-locks-detail-5.7.22/sql/records.cc:399
- #12 0x00000000017f42a1 in Sql_cmd_delete::mysql_delete (this=0x7ffedc007148, thd=0x7ffedc000b90, limit=18446744073709551615)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:452
回表
-
- #0 btr_cur_search_to_nth_level (index=0x7ffedc1d1c00, level=0, tuple=0x7ffedc1d43c8, mode=PAGE_CUR_LE, latch_mode=1, cursor=0x7ffedc1d4168, has_search_latch=0,
- file=0x23a5988 "/mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc", line=3546, mtr=0x7fffec5ea240)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/btr/btr0cur.cc:770
- #1 0x0000000001bec437 in btr_pcur_open_with_no_init_func (index=0x7ffedc1d1c00, tuple=0x7ffedc1d43c8, mode=PAGE_CUR_LE, latch_mode=1, cursor=0x7ffedc1d4168,
- has_search_latch=0, file=0x23a5988 "/mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc", line=3546, mtr=0x7fffec5ea240)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/include/btr0pcur.ic:521
- #2 0x0000000001bf3b3c in row_sel_get_clust_rec_for_mysql (prebuilt=0x7ffedc1d3e50, sec_index=0x7ffedc1d3180, rec=0x7fffcf69016e "\200", thr=0x7ffedc1d4948,
- out_rec=0x7fffec5eaaf0, offsets=0x7fffec5eaac8, offset_heap=0x7fffec5eaad0, vrow=0x0, mtr=0x7fffec5ea240)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc:3546
- #3 0x0000000001bf915f in row_search_mvcc (buf=0x7ffedc030a50 "\377", mode=PAGE_CUR_GE, prebuilt=0x7ffedc1d3e50, match_mode=1, direction=0)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc:5932
- #4 0x0000000001a53113 in ha_innobase::index_read (this=0x7ffedc02f020, buf=0x7ffedc030a50 "\377", key_ptr=0x7ffedc1d7c00 "", key_len=5, find_flag=HA_READ_KEY_EXACT)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/handler/ha_innodb.cc:9536
- #5 0x0000000000f933c2 in handler::index_read_map (this=0x7ffedc02f020, buf=0x7ffedc030a50 "\377", key=0x7ffedc1d7c00 "", keypart_map=1, find_flag=HA_READ_KEY_EXACT)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.h:2942
- #6 0x0000000000f83dac in handler::ha_index_read_map (this=0x7ffedc02f020, buf=0x7ffedc030a50 "\377", key=0x7ffedc1d7c00 "", keypart_map=1,
- find_flag=HA_READ_KEY_EXACT) at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:3248
- #7 0x0000000000f8e844 in handler::read_range_first (this=0x7ffedc02f020, start_key=0x7ffedc02f108, end_key=0x7ffedc02f128, eq_range_arg=true, sorted=true)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:7750
- #8 0x0000000000f8c775 in handler::multi_range_read_next (this=0x7ffedc02f020, range_info=0x7fffec5eb6a0)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:6817
删除操作
-
- #0 btr_cur_search_to_nth_level (index=0x7ffedc1d3180, level=0, tuple=0x7ffedc1d65a0, mode=PAGE_CUR_LE, latch_mode=4098, cursor=0x7fffec5eae80, has_search_latch=0,
- file=0x23a38c8 "/mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0row.cc", line=1073, mtr=0x7fffec5ea970)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/btr/btr0cur.cc:770
- #1 0x0000000001be4233 in btr_pcur_open_low (index=0x7ffedc1d3180, level=0, tuple=0x7ffedc1d65a0, mode=PAGE_CUR_LE, latch_mode=4098, cursor=0x7fffec5eae80,
- file=0x23a38c8 "/mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0row.cc", line=1073, mtr=0x7fffec5ea970)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/include/btr0pcur.ic:465
- #2 0x0000000001be67b9 in row_search_index_entry (index=0x7ffedc1d3180, entry=0x7ffedc1d65a0, mode=4098, pcur=0x7fffec5eae80, mtr=0x7fffec5ea970)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0row.cc:1073
- #3 0x0000000001c1b792 in row_upd_sec_index_entry (node=0x7ffedc1d4a10, thr=0x7ffedc1d4d48)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc:2241
- #4 0x0000000001c1bd5f in row_upd_sec_step (node=0x7ffedc1d4a10, thr=0x7ffedc1d4d48)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc:2364
- #5 0x0000000001c1d9e1 in row_upd (node=0x7ffedc1d4a10, thr=0x7ffedc1d4d48) at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc:3071
- #6 0x0000000001c1dd41 in row_upd_step (thr=0x7ffedc1d4d48) at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc:3188
- #7 0x0000000001bbaf8c in row_update_for_mysql_using_upd_graph (mysql_rec=0x7ffedc030a50 "\361\017", prebuilt=0x7ffedc1d3e50)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0mysql.cc:3040
- #8 0x0000000001bbb28d in row_update_for_mysql (mysql_rec=0x7ffedc030a50 "\361\017", prebuilt=0x7ffedc1d3e50)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0mysql.cc:3131
- #9 0x0000000001a52493 in ha_innobase::delete_row (this=0x7ffedc02f020, record=0x7ffedc030a50 "\361\017")
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/handler/ha_innodb.cc:9141
- #10 0x0000000000f90d11 in handler::ha_delete_row (this=0x7ffedc02f020, buf=0x7ffedc030a50 "\361\017")
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:8543
- #11 0x00000000017f410f in Sql_cmd_delete::mysql_delete (this=0x7ffedc007148, thd=0x7ffedc000b90, limit=18446744073709551615)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:468
- #12 0x00000000017f7098 in Sql_cmd_delete::execute (this=0x7ffedc007148, thd=0x7ffedc000b90) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:1386
- #13 0x00000000015cc801 in mysql_execute_command (thd=0x7ffedc000b90, first_level=true) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:3756
访问下一条数据
不会触发二级索引的 定位函数
回表
-
- #0 btr_cur_search_to_nth_level (index=0x7ffedc1d1c00, level=0, tuple=0x7ffedc1d43c8, mode=PAGE_CUR_LE, latch_mode=1, cursor=0x7ffedc1d4168, has_search_latch=0,
- file=0x23a5988 "/mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc", line=3546, mtr=0x7fffec5ea290)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/btr/btr0cur.cc:770
- #1 0x0000000001bec437 in btr_pcur_open_with_no_init_func (index=0x7ffedc1d1c00, tuple=0x7ffedc1d43c8, mode=PAGE_CUR_LE, latch_mode=1, cursor=0x7ffedc1d4168,
- has_search_latch=0, file=0x23a5988 "/mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc", line=3546, mtr=0x7fffec5ea290)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/include/btr0pcur.ic:521
- #2 0x0000000001bf3b3c in row_sel_get_clust_rec_for_mysql (prebuilt=0x7ffedc1d3e50, sec_index=0x7ffedc1d3180, rec=0x7fffcf69017e "\200", thr=0x7ffedc1d4948,
- out_rec=0x7fffec5eab40, offsets=0x7fffec5eab18, offset_heap=0x7fffec5eab20, vrow=0x0, mtr=0x7fffec5ea290)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc:3546
- #3 0x0000000001bf915f in row_search_mvcc (buf=0x7ffedc030a50 "\361\017", mode=PAGE_CUR_GE, prebuilt=0x7ffedc1d3e50, match_mode=1, direction=1)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc:5932
- #4 0x0000000001a53fac in ha_innobase::general_fetch (this=0x7ffedc02f020, buf=0x7ffedc030a50 "\361\017", direction=1, match_mode=1)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/handler/ha_innodb.cc:9854
- #5 0x0000000001a542af in ha_innobase::index_next_same (this=0x7ffedc02f020, buf=0x7ffedc030a50 "\361\017", key=0x7ffedc1d7c08 "", keylen=5)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/handler/ha_innodb.cc:9945
- #6 0x0000000000f85bea in handler::ha_index_next_same (this=0x7ffedc02f020, buf=0x7ffedc030a50 "\361\017", key=0x7ffedc1d7c08 "", keylen=5)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:3555
- #7 0x0000000000f8e965 in handler::read_range_next (this=0x7ffedc02f020) at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:7793
- #8 0x0000000000f8c6bc in handler::multi_range_read_next (this=0x7ffedc02f020, range_info=0x7fffec5eb6a0)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:6796
- #9 0x0000000000f8d68d in DsMrr_impl::dsmrr_next (this=0x7ffedc02f490, range_info=0x7fffec5eb6a0) at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:7204
- #10 0x0000000001a6689a in ha_innobase::multi_range_read_next (this=0x7ffedc02f020, range_info=0x7fffec5eb6a0)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/handler/ha_innodb.cc:22211
- #11 0x00000000017bdbd8 in QUICK_RANGE_SELECT::get_next (this=0x7ffedc1cfa40) at /mysqldata/percona-server-locks-detail-5.7.22/sql/opt_range.cc:11237
- #12 0x00000000014e27f5 in rr_quick (info=0x7fffec5eb990) at /mysqldata/percona-server-locks-detail-5.7.22/sql/records.cc:399
- #13 0x00000000017f42a1 in Sql_cmd_delete::mysql_delete (this=0x7ffedc007148, thd=0x7ffedc000b90, limit=18446744073709551614)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:452
- #14 0x00000000017f7098 in Sql_cmd_delete::execute (this=0x7ffedc007148, thd=0x7ffedc000b90) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:1386
- #15 0x00000000015cc801 in mysql_execute_command (thd=0x7ffedc000b90, first_level=true) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:3756
- #16 0x00000000015d2fde in mysql_parse (thd=0x7ffedc000b90, parser_state=0x7fffec5ed600) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:5901
- #17 0x00000000015c6b72 in dispatch_command (thd=0x7ffedc000b90, com_data=0x7fffec5edd70, command=COM_QUERY)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1490
- #18 0x00000000015c58ff in do_command (thd=0x7ffedc000b90) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1021
- #19 0x000000000170e578 in handle_connection (arg=0x674cc40) at /mysqldata/percona-server-locks-detail-5.7.22/sql/conn_handler/connection_handler_per_thread.cc:312
- #20 0x0000000001945538 in pfs_spawn_thread (arg=0x67a1530) at /mysqldata/percona-server-locks-detail-5.7.22/storage/perfschema/pfs.cc:2190
- #21 0x00007ffff7bcfaa1 in start_thread () from /lib64/libpthread.so.0
- #22 0x00007ffff6b37c4d in clone () from /lib64/libc.so.6
删除
-
- #0 btr_cur_search_to_nth_level (index=0x7ffedc1d1c00, level=0, tuple=0x7ffedc1d6900, mode=PAGE_CUR_LE, latch_mode=2, cursor=0x7ffedc02f678, has_search_latch=0,
- file=0x23aca80 "/mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc", line=2864, mtr=0x7fffec5ea8f0)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/btr/btr0cur.cc:770
- #1 0x0000000001cdf27c in btr_pcur_open_with_no_init_func (index=0x7ffedc1d1c00, tuple=0x7ffedc1d6900, mode=PAGE_CUR_LE, latch_mode=2, cursor=0x7ffedc02f678,
- has_search_latch=0, file=0x23aca80 "/mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc", line=2864, mtr=0x7fffec5ea8f0)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/include/btr0pcur.ic:521
- #2 0x0000000001ce01b6 in btr_pcur_restore_position_func (latch_mode=2, cursor=0x7ffedc02f678,
- file=0x23aca80 "/mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc", line=2864, mtr=0x7fffec5ea8f0)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/btr/btr0pcur.cc:395
- #3 0x0000000001c1d0ad in row_upd_clust_step (node=0x7ffedc1d4a10, thr=0x7ffedc1d4d48)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc:2864
- #4 0x0000000001c1d860 in row_upd (node=0x7ffedc1d4a10, thr=0x7ffedc1d4d48) at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc:3042
- #5 0x0000000001c1dd41 in row_upd_step (thr=0x7ffedc1d4d48) at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc:3188
- #6 0x0000000001bbaf8c in row_update_for_mysql_using_upd_graph (mysql_rec=0x7ffedc030a50 "\361\017", prebuilt=0x7ffedc1d3e50)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0mysql.cc:3040
- #7 0x0000000001bbb28d in row_update_for_mysql (mysql_rec=0x7ffedc030a50 "\361\017", prebuilt=0x7ffedc1d3e50)
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/row/row0mysql.cc:3131
- #8 0x0000000001a52493 in ha_innobase::delete_row (this=0x7ffedc02f020, record=0x7ffedc030a50 "\361\017")
- at /mysqldata/percona-server-locks-detail-5.7.22/storage/innobase/handler/ha_innodb.cc:9141
- #9 0x0000000000f90d11 in handler::ha_delete_row (this=0x7ffedc02f020, buf=0x7ffedc030a50 "\361\017")
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:8543
- #10 0x00000000017f410f in Sql_cmd_delete::mysql_delete (this=0x7ffedc007148, thd=0x7ffedc000b90, limit=18446744073709551614)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:468
- #11 0x00000000017f7098 in Sql_cmd_delete::execute (this=0x7ffedc007148, thd=0x7ffedc000b90) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:1386
- #12 0x00000000015cc801 in mysql_execute_command (thd=0x7ffedc000b90, first_level=true) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:3756
- #13 0x00000000015d2fde in mysql_parse (thd=0x7ffedc000b90, parser_state=0x7fffec5ed600) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:5901
- #14 0x00000000015c6b72 in dispatch_command (thd=0x7ffedc000b90, com_data=0x7fffec5edd70, command=COM_QUERY)
- at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1490
- #15 0x00000000015c58ff in do_command (thd=0x7ffedc000b90) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1021
- #16 0x000000000170e578 in handle_connection (arg=0x674cc40) at /mysqldata/percona-server-locks-detail-5.7.22/sql/conn_handler/connection_handler_per_thread.cc:312
- #17 0x0000000001945538 in pfs_spawn_thread (arg=0x67a1530) at /mysqldata/percona-server-locks-detail-5.7.22/storage/perfschema/pfs.cc:2190
- #18 0x00007ffff7bcfaa1 in start_thread () from /lib64/libpthread.so.0
- #19 0x00007ffff6b37c4d in clone () from /lib64/libc.so.6
2、备库
第一行数据定位 ha_innobase::index_read
-
- #0 btr_cur_search_to_nth_level (index=0x7ffe78a90f30, level=0, tuple=0x7ffe78933290, mode=PAGE_CUR_GE, latch_mode=1, cursor=0x7ffe789330a0, has_search_latch=0,
- file=0x239d910 "/root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc", line=5176, mtr=0x7fffec062630)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/btr/btr0cur.cc:770
- #1 0x0000000001b6e89b in btr_pcur_open_with_no_init_func (index=0x7ffe78a90f30, tuple=0x7ffe78933290, mode=PAGE_CUR_GE, latch_mode=1, cursor=0x7ffe789330a0,
- has_search_latch=0, file=0x239d910 "/root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc", line=5176, mtr=0x7fffec062630)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/include/btr0pcur.ic:521
- #2 0x0000000001b79855 in row_search_mvcc (buf=0x7ffe78011810 "\361\017", mode=PAGE_CUR_GE, prebuilt=0x7ffe78932e80, match_mode=1, direction=0)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc:5176
- #3 0x00000000019d5493 in ha_innobase::index_read (this=0x7ffe7892f2f0, buf=0x7ffe78011810 "\361\017", key_ptr=0x7ffe78934150 "", key_len=5,
- find_flag=HA_READ_KEY_EXACT) at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/handler/ha_innodb.cc:9536
- #4 0x0000000000f934aa in handler::index_read_map (this=0x7ffe7892f2f0, buf=0x7ffe78011810 "\361\017", key=0x7ffe78934150 "", keypart_map=18446744073709551615,
- find_flag=HA_READ_KEY_EXACT) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.h:2942
- #5 0x0000000000f83e94 in handler::ha_index_read_map (this=0x7ffe7892f2f0, buf=0x7ffe78011810 "\361\017", key=0x7ffe78934150 "", keypart_map=18446744073709551615,
- find_flag=HA_READ_KEY_EXACT) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:3248
- #6 0x00000000018583ed in Rows_log_event::next_record_scan (this=0x7ffe7415d150, first_read=true)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:10495
- #7 0x0000000001858cce in Rows_log_event::do_index_scan_and_update (this=0x7ffe7415d150, rli=0x7ffe7401fe10)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:10706
- #8 0x000000000185b0b5 in Rows_log_event::do_apply_event (this=0x7ffe7415d150, rli=0x7ffe7401fe10)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:11564
- #9 0x000000000186acf2 in Log_event::do_apply_event_worker (this=0x7ffe7415d150, w=0x7ffe7401fe10)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:765
- #10 0x00000000018e7672 in Slave_worker::slave_worker_exec_event (this=0x7ffe7401fe10, ev=0x7ffe7415d150)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/rpl_rli_pdb.cc:1890
- #11 0x00000000018e97ed in slave_worker_exec_job_group (worker=0x7ffe7401fe10, rli=0x7ffe7c026760)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/rpl_rli_pdb.cc:2671
- #12 0x00000000018c077a in handle_slave_worker (arg=0x7ffe7401fe10) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/rpl_slave.cc:6239
- #13 0x0000000001945620 in pfs_spawn_thread (arg=0x7ffe740249b0) at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/perfschema/pfs.cc:2190
- #14 0x00007ffff7bc6aa1 in start_thread () from /lib64/libpthread.so.0
- #15 0x00007ffff6719bcd in clone () from /lib64/libc.so.6
回表
-
- #0 btr_cur_search_to_nth_level (index=0x7ffe7892fde0, level=0, tuple=0x7ffe789333f8, mode=PAGE_CUR_LE, latch_mode=1, cursor=0x7ffe78933198, has_search_latch=0,
- file=0x239d910 "/root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc", line=3546, mtr=0x7fffec062630)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/btr/btr0cur.cc:770
- #1 0x0000000001b6e89b in btr_pcur_open_with_no_init_func (index=0x7ffe7892fde0, tuple=0x7ffe789333f8, mode=PAGE_CUR_LE, latch_mode=1, cursor=0x7ffe78933198,
- has_search_latch=0, file=0x239d910 "/root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc", line=3546, mtr=0x7fffec062630)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/include/btr0pcur.ic:521
- #2 0x0000000001b75fa0 in row_sel_get_clust_rec_for_mysql (prebuilt=0x7ffe78932e80, sec_index=0x7ffe78a90f30, rec=0x7fff33b5415e "\200", thr=0x7ffe78933978,
- out_rec=0x7fffec062ee0, offsets=0x7fffec062eb8, offset_heap=0x7fffec062ec0, vrow=0x0, mtr=0x7fffec062630)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc:3546
- #3 0x0000000001b7b5c3 in row_search_mvcc (buf=0x7ffe78011810 "\361\017", mode=PAGE_CUR_GE, prebuilt=0x7ffe78932e80, match_mode=1, direction=0)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0sel.cc:5932
- #4 0x00000000019d5493 in ha_innobase::index_read (this=0x7ffe7892f2f0, buf=0x7ffe78011810 "\361\017", key_ptr=0x7ffe78934150 "", key_len=5,
- find_flag=HA_READ_KEY_EXACT) at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/handler/ha_innodb.cc:9536
- #5 0x0000000000f934aa in handler::index_read_map (this=0x7ffe7892f2f0, buf=0x7ffe78011810 "\361\017", key=0x7ffe78934150 "", keypart_map=18446744073709551615,
- find_flag=HA_READ_KEY_EXACT) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.h:2942
- #6 0x0000000000f83e94 in handler::ha_index_read_map (this=0x7ffe7892f2f0, buf=0x7ffe78011810 "\361\017", key=0x7ffe78934150 "", keypart_map=18446744073709551615,
- find_flag=HA_READ_KEY_EXACT) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:3248
- #7 0x00000000018583ed in Rows_log_event::next_record_scan (this=0x7ffe7415d150, first_read=true)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:10495
- #8 0x0000000001858cce in Rows_log_event::do_index_scan_and_update (this=0x7ffe7415d150, rli=0x7ffe7401fe10)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:10706
- #9 0x000000000185b0b5 in Rows_log_event::do_apply_event (this=0x7ffe7415d150, rli=0x7ffe7401fe10)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:11564
- #10 0x000000000186acf2 in Log_event::do_apply_event_worker (this=0x7ffe7415d150, w=0x7ffe7401fe10)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:765
- #11 0x00000000018e7672 in Slave_worker::slave_worker_exec_event (this=0x7ffe7401fe10, ev=0x7ffe7415d150)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/rpl_rli_pdb.cc:1890
- #12 0x00000000018e97ed in slave_worker_exec_job_group (worker=0x7ffe7401fe10, rli=0x7ffe7c026760)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/rpl_rli_pdb.cc:2671
- #13 0x00000000018c077a in handle_slave_worker (arg=0x7ffe7401fe10) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/rpl_slave.cc:6239
- #14 0x0000000001945620 in pfs_spawn_thread (arg=0x7ffe740249b0) at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/perfschema/pfs.cc:2190
- #15 0x00007ffff7bc6aa1 in start_thread () from /lib64/libpthread.so.0
- #16 0x00007ffff6719bcd in clone () from /lib64/libc.so.6
-
- #0 btr_cur_search_to_nth_level (index=0x7ffe78a90f30, level=0, tuple=0x7ffe78a91c00, mode=PAGE_CUR_LE, latch_mode=4098, cursor=0x7fffec063090, has_search_latch=0,
- file=0x239b7e0 "/root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0row.cc", line=1073, mtr=0x7fffec062b80)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/btr/btr0cur.cc:770
- #1 0x0000000001b66697 in btr_pcur_open_low (index=0x7ffe78a90f30, level=0, tuple=0x7ffe78a91c00, mode=PAGE_CUR_LE, latch_mode=4098, cursor=0x7fffec063090,
- file=0x239b7e0 "/root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0row.cc", line=1073, mtr=0x7fffec062b80)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/include/btr0pcur.ic:465
- #2 0x0000000001b68c1d in row_search_index_entry (index=0x7ffe78a90f30, entry=0x7ffe78a91c00, mode=4098, pcur=0x7fffec063090, mtr=0x7fffec062b80)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0row.cc:1073
- #3 0x0000000001b9dbf6 in row_upd_sec_index_entry (node=0x7ffe78933a40, thr=0x7ffe78933d78)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc:2241
- #4 0x0000000001b9e1c3 in row_upd_sec_step (node=0x7ffe78933a40, thr=0x7ffe78933d78)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc:2364
- #5 0x0000000001b9fe45 in row_upd (node=0x7ffe78933a40, thr=0x7ffe78933d78) at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc:3071
- #6 0x0000000001ba01a5 in row_upd_step (thr=0x7ffe78933d78) at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0upd.cc:3188
- #7 0x0000000001b3d3f0 in row_update_for_mysql_using_upd_graph (mysql_rec=0x7ffe78011810 "\361\017", prebuilt=0x7ffe78932e80)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0mysql.cc:3040
- #8 0x0000000001b3d6f1 in row_update_for_mysql (mysql_rec=0x7ffe78011810 "\361\017", prebuilt=0x7ffe78932e80)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/row/row0mysql.cc:3131
- #9 0x00000000019d4813 in ha_innobase::delete_row (this=0x7ffe7892f2f0, record=0x7ffe78011810 "\361\017")
- at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/innobase/handler/ha_innodb.cc:9141
- #10 0x0000000000f90df9 in handler::ha_delete_row (this=0x7ffe7892f2f0, buf=0x7ffe78011810 "\361\017")
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:8543
- #11 0x000000000185f96a in Delete_rows_log_event::do_exec_row (this=0x7ffe7415d150, rli=0x7ffe7401fe10)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:13157
- #12 0x0000000001858059 in Rows_log_event::do_apply_row (this=0x7ffe7415d150, rli=0x7ffe7401fe10)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:10395
- #13 0x0000000001859025 in Rows_log_event::do_index_scan_and_update (this=0x7ffe7415d150, rli=0x7ffe7401fe10)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:10784
- #14 0x000000000185b0b5 in Rows_log_event::do_apply_event (this=0x7ffe7415d150, rli=0x7ffe7401fe10)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:11564
- #15 0x000000000186acf2 in Log_event::do_apply_event_worker (this=0x7ffe7415d150, w=0x7ffe7401fe10)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:765
- #16 0x00000000018e7672 in Slave_worker::slave_worker_exec_event (this=0x7ffe7401fe10, ev=0x7ffe7415d150)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/rpl_rli_pdb.cc:1890
-
- Rows_log_event::do_apply_event
- ->GTID 跳过逻辑
- ->打开表
- ->table 映射
- ->设置访问位图read_set 和 write_set
- ->准备Delete_rows_log_event::do_before_row_operations
- ->匹配索引Rows_log_event::row_operations_scan_and_key_setup
- ->decide_row_lookup_algorithm_and_key 决定用什么扫描方式
- 如果是hash需要初始化hash结构m_hash.init()
- ->循环event中的每一条数据
- ->调用相应的方法接口
- ->hash 方法 Rows_log_event::do_hash_scan_and_update
- ->将每条数据加入hash 区域 Rows_log_event::do_hash_row
- 如果有索引还会维护一个集合
- ->如过是Event中的最后一条数据调用Rows_log_event::do_scan_and_update
- 扫描整个表或者遍历集合进行索引查找定位查找数据
- 和HASH结构进行对比
- 对比成功在HASH结构中删除
- 调用删除接口删除数据
一个测试
主要测试从库在有主键和没有主键下接口调用:
slave_rows_search_algorithms=’INDEX_SCAN,HASH_SCAN’;
建表
-
- create table tmpk(a int primary key,name varchar(20));
数据
-
- mysql> select * from tmpk;
- +---+------+
- | a | name |
- +---+------+
- | 1 | gao |
- | 2 | gao |
- | 3 | gao |
- | 4 | gao |
- +---+------+
从库:
-
- mysql> set global slave_rows_search_algorithms='INDEX_SCAN,HASH_SCAN';
- Query OK, 0 rows affected (0.00 sec)
主库删除一条数据:
-
- mysql> delete from tmpk where a=1;
- Query OK, 1 row affected (0.08 sec)
从库调用接口:
-
- (gdb) bt
- #0 Rows_log_event::do_index_scan_and_update (this=0x7ffe70162a20, rli=0x7ffe70024a90) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:10603
- #1 0x000000000185b0b5 in Rows_log_event::do_apply_event (this=0x7ffe70162a20, rli=0x7ffe70024a90)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:11564
- #2 0x000000000186acf2 in Log_event::do_apply_event_worker (this=0x7ffe70162a20, w=0x7ffe70024a90)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:765
- #3 0x00000000018e7672 in Slave_worker::slave_worker_exec_event (this=0x7ffe70024a90, ev=0x7ffe70162a20)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/rpl_rli_pdb.cc:1890
- #4 0x00000000018e97ed in slave_worker_exec_job_group (worker=0x7ffe70024a90, rli=0x67633b0)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/rpl_rli_pdb.cc:2671
- #5 0x00000000018c077a in handle_slave_worker (arg=0x7ffe70024a90) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/rpl_slave.cc:6239
- #6 0x0000000001945620 in pfs_spawn_thread (arg=0x7ffe700296d0) at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/perfschema/pfs.cc:2190
- #7 0x00007ffff7bc6aa1 in start_thread () from /lib64/libpthread.so.0
- #8 0x00007ffff6719bcd in clone () from /lib64/libc.so.6
- (gdb) c
从库删除主键:
-
- mysql> alter table tmpk drop primary key;
- Query OK, 3 rows affected (1.23 sec)
- Records: 3 Duplicates: 0 Warnings: 0
主库再次删除一条数据:
-
- mysql> delete from tmpk where a=2;
- Query OK, 1 row affected (0.12 sec)
从库调用接口变为了hash算法:
-
- (gdb) bt
- #0 Rows_log_event::do_hash_scan_and_update (this=0x7ffe70162d50, rli=0x7ffe70024a90) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:11043
- #1 0x000000000185b0b5 in Rows_log_event::do_apply_event (this=0x7ffe70162d50, rli=0x7ffe70024a90)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:11564
- #2 0x000000000186acf2 in Log_event::do_apply_event_worker (this=0x7ffe70162d50, w=0x7ffe70024a90)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:765
- #3 0x00000000018e7672 in Slave_worker::slave_worker_exec_event (this=0x7ffe70024a90, ev=0x7ffe70162d50)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/rpl_rli_pdb.cc:1890
- #4 0x00000000018e97ed in slave_worker_exec_job_group (worker=0x7ffe70024a90, rli=0x67633b0)
- at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/rpl_rli_pdb.cc:2671
- #5 0x00000000018c077a in handle_slave_worker (arg=0x7ffe70024a90) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/rpl_slave.cc:6239
- #6 0x0000000001945620 in pfs_spawn_thread (arg=0x7ffe700296d0) at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/perfschema/pfs.cc:2190
- #7 0x00007ffff7bc6aa1 in start_thread () from /lib64/libpthread.so.0
- #8 0x00007ffff6719bcd in clone () from /lib64/libc.so.6
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7728585/viewspace-2649963/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/7728585/viewspace-2649963/
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。