十四:事務Event的生成和寫入流程(筆記)
歡迎關注我的《深入理解MySQL主從原理 32講 》,如下:
如果圖片不能顯示可檢視下面連結:
https://www.jianshu.com/p/d636215d767f
關於各個Event的生成時機直接debug前面講Event的時候給出的各個介面即可。
一、Query_log_event棧幀:
初始化
#0 Query_log_event::Query_log_event (this=0x7fffec0f30d0, thd_arg=0x7ffe7c000b70, query_arg=0x22e0614 "BEGIN", query_length=5, using_trans=true, immediate=false,
suppress_use=true, errcode=0, ignore_cmd_internals=true, __in_chrg=<value optimized out>, __vtt_parm=<value optimized out>)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:4036
#1 0x000000000188cc49 in binlog_start_trans_and_stmt (thd=0x7ffe7c000b70, start_event=0x7fffec0f4290)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/binlog.cc:10387
#2 0x000000000188ce88 in THD::binlog_write_table_map (this=0x7ffe7c000b70, table=0x7ffe7c9b8390, is_transactional=true, binlog_rows_query=false)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/binlog.cc:10430
#3 0x0000000000f8fbe7 in write_locked_table_maps (thd=0x7ffe7c000b70) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:8258
#4 0x0000000000f8fe2b in binlog_log_row (table=0x7ffe7c9b8390, before_record=0x7ffe7c9b77e0 "\375\001", after_record=0x0,
log_func=0xf95805 <Delete_rows_log_event::binlog_row_logging_function(THD*, TABLE*, bool, uchar const*, uchar const*)>)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:8327
#5 0x0000000000f90f90 in handler::ha_delete_row (this=0x7ffe7c9bb110, buf=0x7ffe7c9b77e0 "\375\001")
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:8549
#6 0x00000000017f41f7 in Sql_cmd_delete::mysql_delete (this=0x7ffe7c006c60, thd=0x7ffe7c000b70, limit=3)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:468
#7 0x00000000017f7180 in Sql_cmd_delete::execute (this=0x7ffe7c006c60, thd=0x7ffe7c000b70) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:1386
#8 0x00000000015cc8e9 in mysql_execute_command (thd=0x7ffe7c000b70, first_level=true) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:3756
#9 0x00000000015d30c6 in mysql_parse (thd=0x7ffe7c000b70, parser_state=0x7fffec0f6600) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:5901
#10 0x00000000015c6c5a in dispatch_command (thd=0x7ffe7c000b70, com_data=0x7fffec0f6d70, command=COM_QUERY)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1490
#11 0x00000000015c59e7 in do_command (thd=0x7ffe7c000b70) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1021
#12 0x000000000170e660 in handle_connection (arg=0x67de900) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/conn_handler/connection_handler_per_thread.cc:312
#13 0x0000000001945620 in pfs_spawn_thread (arg=0x675f7e0) at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/perfschema/pfs.cc:2190
#14 0x00007ffff7bc6aa1 in start_thread () from /lib64/libpth
二、Table_map_log_event棧幀:
初始化
#0 Table_map_log_event::Table_map_log_event (this=0x7fffec0f41f0, thd_arg=0x7ffe7c000b70, tbl=0x7ffe7c9b8390, tid=..., using_trans=true)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:12045
#1 0x000000000188ce68 in THD::binlog_write_table_map (this=0x7ffe7c000b70, table=0x7ffe7c9b8390, is_transactional=true, binlog_rows_query=false)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/binlog.cc:10428
#2 0x0000000000f8fbe7 in write_locked_table_maps (thd=0x7ffe7c000b70) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:8258
#3 0x0000000000f8fe2b in binlog_log_row (table=0x7ffe7c9b8390, before_record=0x7ffe7c9b77e0 "\375\001", after_record=0x0,
log_func=0xf95805 <Delete_rows_log_event::binlog_row_logging_function(THD*, TABLE*, bool, uchar const*, uchar const*)>)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:8327
#4 0x0000000000f90f90 in handler::ha_delete_row (this=0x7ffe7c9bb110, buf=0x7ffe7c9b77e0 "\375\001")
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:8549
#5 0x00000000017f41f7 in Sql_cmd_delete::mysql_delete (this=0x7ffe7c006c60, thd=0x7ffe7c000b70, limit=3)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:468
#6 0x00000000017f7180 in Sql_cmd_delete::execute (this=0x7ffe7c006c60, thd=0x7ffe7c000b70) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:1386
#7 0x00000000015cc8e9 in mysql_execute_command (thd=0x7ffe7c000b70, first_level=true) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:3756
#8 0x00000000015d30c6 in mysql_parse (thd=0x7ffe7c000b70, parser_state=0x7fffec0f6600) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:5901
#9 0x00000000015c6c5a in dispatch_command (thd=0x7ffe7c000b70, com_data=0x7fffec0f6d70, command=COM_QUERY)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1490
#10 0x00000000015c59e7 in do_command (thd=0x7ffe7c000b70) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1021
#11 0x000000000170e660 in handle_connection (arg=0x67de900) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/conn_handler/connection_handler_per_thread.cc:312
#12 0x0000000001945620 in pfs_spawn_thread (arg=0x675f7e0) at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/perfschema/pfs.cc:2190
#13 0x00007ffff7bc6aa1 in start_thread () from /lib64/libpthread.so.0
#14 0x00007ffff6719bcd in clone () from /lib64/libc.so.6
三、Delete_rows_log_event
Delete_rows_log_event::Delete_rows_log_event
初始化Event:
#0 Delete_rows_log_event::Delete_rows_log_event (this=0x7ffe7cdc7a60, thd_arg=0x7ffe7c000b70, tbl_arg=0x7ffe7c9b8390, tid=..., is_transactional=true,
extra_row_info=0x0, __in_chrg=<value optimized out>, __vtt_parm=<value optimized out>) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:13086
#1 0x000000000189687f in THD::binlog_prepare_pending_rows_event<Delete_rows_log_event> (this=0x7ffe7c000b70, table=0x7ffe7c9b8390, serv_id=953340, needed=5,
is_transactional=true, hint=0x0, extra_row_info=0x0) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/binlog.cc:11688
#2 0x000000000189003b in THD::binlog_delete_row (this=0x7ffe7c000b70, table=0x7ffe7c9b8390, is_trans=true, record=0x7ffe7c9b77e0 "\375\001", extra_row_info=0x0)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/binlog.cc:11963
#3 0x0000000000f95844 in Delete_rows_log_event::binlog_row_logging_function (thd=0x7ffe7c000b70, table=0x7ffe7c9b8390, is_transactional=true,
before_record=0x7ffe7c9b77e0 "\375\001", after_record=0x0) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.h:3722
#4 0x0000000000f8fe9e in binlog_log_row (table=0x7ffe7c9b8390, before_record=0x7ffe7c9b77e0 "\375\001", after_record=0x0,
log_func=0xf95805 <Delete_rows_log_event::binlog_row_logging_function(THD*, TABLE*, bool, uchar const*, uchar const*)>)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:8340
#5 0x0000000000f90f90 in handler::ha_delete_row (this=0x7ffe7c9bb110, buf=0x7ffe7c9b77e0 "\375\001")
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:8549
#6 0x00000000017f41f7 in Sql_cmd_delete::mysql_delete (this=0x7ffe7c006c60, thd=0x7ffe7c000b70, limit=3)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:468
#7 0x00000000017f7180 in Sql_cmd_delete::execute (this=0x7ffe7c006c60, thd=0x7ffe7c000b70) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:1386
#8 0x00000000015cc8e9 in mysql_execute_command (thd=0x7ffe7c000b70, first_level=true) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:3756
#9 0x00000000015d30c6 in mysql_parse (thd=0x7ffe7c000b70, parser_state=0x7fffec0f6600) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:5901
#10 0x00000000015c6c5a in dispatch_command (thd=0x7ffe7c000b70, com_data=0x7fffec0f6d70, command=COM_QUERY)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1490
#11 0x00000000015c59e7 in do_command (thd=0x7ffe7c000b70) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1021
#12 0x000000000170e660 in handle_connection (arg=0x67de900) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/conn_handler/connection_handler_per_thread.cc:312
#13 0x0000000001945620 in pfs_spawn_thread (arg=0x675f7e0) 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
資料加入Rows_log_event::do_add_row_data 將本次迴圈的加入到event中
#0 Rows_log_event::do_add_row_data (this=0x7ffe7cdc7a60, row_data=0x7ffe7c9b78e0 "\376\001", length=5)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.cc:9676
#1 0x00000000018929ad in Rows_log_event::add_row_data (this=0x7ffe7cdc7a60, data=0x7ffe7c9b78e0 "\376\001", length=5)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.h:3067
#2 0x0000000001890073 in THD::binlog_delete_row (this=0x7ffe7c000b70, table=0x7ffe7c9b8390, is_trans=true, record=0x7ffe7c9b77e0 "\375\001", extra_row_info=0x0)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/binlog.cc:11968
#3 0x0000000000f95844 in Delete_rows_log_event::binlog_row_logging_function (thd=0x7ffe7c000b70, table=0x7ffe7c9b8390, is_transactional=true,
before_record=0x7ffe7c9b77e0 "\375\001", after_record=0x0) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/log_event.h:3722
#4 0x0000000000f8fe9e in binlog_log_row (table=0x7ffe7c9b8390, before_record=0x7ffe7c9b77e0 "\375\001", after_record=0x0,
log_func=0xf95805 <Delete_rows_log_event::binlog_row_logging_function(THD*, TABLE*, bool, uchar const*, uchar const*)>)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:8340
#5 0x0000000000f90f90 in handler::ha_delete_row (this=0x7ffe7c9bb110, buf=0x7ffe7c9b77e0 "\375\001")
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:8549
#6 0x00000000017f41f7 in Sql_cmd_delete::mysql_delete (this=0x7ffe7c006c60, thd=0x7ffe7c000b70, limit=3)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:468
#7 0x00000000017f7180 in Sql_cmd_delete::execute (this=0x7ffe7c006c60, thd=0x7ffe7c000b70) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:1386
#8 0x00000000015cc8e9 in mysql_execute_command (thd=0x7ffe7c000b70, first_level=true) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:3756
#9 0x00000000015d30c6 in mysql_parse (thd=0x7ffe7c000b70, parser_state=0x7fffec0f6600) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:5901
#10 0x00000000015c6c5a in dispatch_command (thd=0x7ffe7c000b70, com_data=0x7fffec0f6d70, command=COM_QUERY)
at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1490
#11 0x00000000015c59e7 in do_command (thd=0x7ffe7c000b70) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1021
#12 0x000000000170e660 in handle_connection (arg=0x67de900) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/conn_handler/connection_handler_per_thread.cc:312
#13 0x0000000001945620 in pfs_spawn_thread (arg=0x675f7e0) 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
四、XID_EVENT
可debug Xid_apply_log_event::Xid_apply_log_event
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7728585/viewspace-2649955/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- spring事務管理原始碼分析(一)配置和事務增強代理的生成流程Spring原始碼
- 十五:MySQL層事務提交流程簡析(筆記)MySql筆記
- Spring事務筆記Spring筆記
- MySQL 筆記 - 事務&鎖MySql筆記
- SQL筆記(14)——事務SQL筆記
- Spring筆記(4) - Spring的程式設計式事務和宣告式事務詳解Spring筆記程式設計
- ES 筆記十四:Index Template 和 Dynamic Template筆記Index
- 筆記-YUV和RGB的那些事~筆記
- Event Loop 學習筆記OOP筆記
- 資料庫學習筆記:事務的特性和隔離級別資料庫筆記
- 筆記:DB常用sql列印+事務使用筆記SQL
- Javasript學習筆記-Event事件Java筆記事件
- 手寫 Spring 事務、IOC、DI 和 MVCSpringMVC
- ES 筆記二十四:使用 Search Template 和 Index Alias筆記Index
- ❤️🔥 Solon Cloud Event 新的事務特性與應用Cloud
- MySQL 學習筆記(一)MySQL 事務的ACID特性MySql筆記
- 【廖雪峰python入門筆記】列表生成式Python筆記
- [高效能MYSQL學習筆記]事務MySql筆記
- 筆記:第二節快速入門 流程圖的使用(下)筆記流程圖
- dotnet學習筆記-專題04-配置的讀取和寫入-01筆記
- Java學習筆記3事務的四大特性Java筆記
- 【spring】事務底層的實現流程Spring
- Django筆記三十四之分頁操作Django筆記
- Event Loop、 巨集任務和微任務OOP
- Spring學習筆記3(JDBC模板&事務管理)Spring筆記JDBC
- mysql隱式提交事務transaction一點筆記MySql筆記
- 事務隔離級別讀書筆記分享筆記
- MySQL事務學習筆記(一) 初遇篇MySql筆記
- Spring 事務學習筆記(一) 初遇篇Spring筆記
- MySQL事務學習筆記(三) 甚歡篇MySql筆記
- MySQL事務學習筆記(二) 相識篇MySql筆記
- 筆記53-Spring jdbcTemplate&宣告式事務筆記SpringJDBC
- 入門筆記 --- Golang 語法注意事項(一)筆記Golang
- 從入門到進階,印象筆記那些事筆記
- 關於Spring Aop和事務記錄Spring
- MySQL定時器EVENT學習筆記MySql定時器筆記
- Event Bus 設計模式學習筆記設計模式筆記
- 寫給程式設計師的機器學習入門 (十四) - 對抗生成網路 如何造假臉程式設計師機器學習