十四:事务Event的生成和写入流程(笔记)

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 RDS MySQL Serverless,价值2615元额度,1个月
简介: 关于各个Event的生成时机直接debug前面讲Event的时候给出的各个接口即可。一、Query_log_event栈帧:初始化#0 Query_log_event::Query_log_event (this=0x7fffec0f30d0, thd_arg=0x7ffe7c000b70...

关于各个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

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2月前
使用 SAP UI5 Event Bus 机制,修复 SAP UI5 分页显示数据的一个 bug 试读版
使用 SAP UI5 Event Bus 机制,修复 SAP UI5 分页显示数据的一个 bug 试读版
22 0
|
3天前
|
前端开发
flowable流程设计器的几个bug修改记录
flowable流程设计器的几个bug修改记录
10 0
|
7月前
|
Dart
带你读《深入浅出Dart》二十六、状态管理(1)
带你读《深入浅出Dart》二十六、状态管理(1)
|
7月前
|
Dart
带你读《深入浅出Dart》二十六、状态管理(2)
带你读《深入浅出Dart》二十六、状态管理(2)
|
存储 SQL 关系型数据库
事务简介
事务简介
71 0
|
消息中间件 存储 Dubbo
事务消息应用场景、实现原理与项目实战(附全部源码)
从应用场景出发,给出解决方案与实现原理,并提供整套工业级实现源码。
126 0
事务消息应用场景、实现原理与项目实战(附全部源码)
|
SQL 关系型数据库 MySQL
如何使用事务
如何使用事务
如何使用事务
|
算法 调度
十八、同步
十八、同步
|
SQL 存储 NoSQL
事务功能使用及原理介绍(一)|学习笔记
快速学习事务功能使用及原理介绍
256 0
事务功能使用及原理介绍(一)|学习笔记
|
存储 SQL NoSQL
事务功能使用及原理介绍(二)|学习笔记
快速学习事务功能使用及原理介绍
172 0
事务功能使用及原理介绍(二)|学习笔记