MySQL启动过程详解五:GTID的处理

MySQL启动过程中 GTID 的处理:

  1. 在核心模块启动函数 init_server_components() 会调用 gtid_server_init() 初始化 gtid server

  2. 调用 init_server_auto_options() 初始化并获取数据库的 server_uuid,从 auto.cnf 文件中读取,如果没有则重新生成

  3. 调用 gtid_state->init() 将 server_uuid 添加到 sid_map 中。

  4. 读取 mysql.gtid_executed表,读取 mysql.gtid_executed 的值

  5. 接下来,要从 mysql.gtid_executed 表和 binlog 文件中初始化 gtid_executed 和 gtid_purged 的值

  6. 对 mysql.gtid_executed 表中的 gtid_executed 进行修正,更新 lost_gtids & gtids_only_in_table & previous_gtids_logged 的值

  7. 将 previous_gtids_logged 写入最新的binlog文件

涉及到的源码如下:

cpp;gutter:true;
从 binlog 文件中读取 gtids_in_binlog 和 purged_gtids_from_binlog的init_gtid_sets() 函数代码解析如下:

Original: https://www.cnblogs.com/juanmaofeifei/p/16143948.html
Author: 卷毛狒狒
Title: MySQL启动过程详解五:GTID的处理

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/590933/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球