MySQL並行複製-原始碼理解記錄
MySQL並行複製中,文章中提到在prepare階段中的事務是可以並行執行的,那麼這裡指的處於prepare階段的事務已經獲取了鎖,更新了資料檔案,就等commit階段的提交,更新事務狀態,釋放undo ,鎖資源,所以prepare階段的事務互相之間是不衝突的。看下程式碼中的順序,確認下是否是先獲取鎖,然後在設定prepare狀態的。
在鎖以及設定prepare的函式上設定斷點,可以看到,是先執行了設定鎖的語句,然後才進入prepare的
鎖的堆疊
mysqld!lock_rec_lock(bool, unsigned long, buf_block_t const*, unsigned long, dict_index_t*, que_thr_t*) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/storage/innobase/lock/lock0lock.cc:2048) mysqld!lock_clust_rec_read_check_and_lock(unsigned long, buf_block_t const*, unsigned char const*, dict_index_t*, unsigned long const*, lock_mode, unsigned long, que_thr_t*) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/storage/innobase/lock/lock0lock.cc:6422) mysqld!sel_set_rec_lock(btr_pcur_t*, unsigned char const*, dict_index_t*, unsigned long const*, unsigned long, unsigned long, que_thr_t*, mtr_t*) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/storage/innobase/row/row0sel.cc:1260) mysqld!row_search_mvcc(unsigned char*, page_cur_mode_t, row_prebuilt_t*, unsigned long, unsigned long) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/storage/innobase/row/row0sel.cc:5530) mysqld!ha_innobase::index_read(unsigned char*, unsigned char const*, unsigned int, ha_rkey_function) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/storage/innobase/handler/ha_innodb.cc:8753) mysqld!handler::index_read_map(unsigned char*, unsigned char const*, unsigned long, ha_rkey_function) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/handler.h:2818) mysqld!handler::ha_index_read_map(unsigned char*, unsigned char const*, unsigned long, ha_rkey_function) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/handler.cc:3046) mysqld!handler::read_range_first(st_key_range const*, st_key_range const*, bool, bool) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/handler.cc:7411) mysqld!handler::multi_range_read_next(char**) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/handler.cc:6476) mysqld!DsMrr_impl::dsmrr_next(char**) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/handler.cc:6868) mysqld!ha_innobase::multi_range_read_next(char**) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/storage/innobase/handler/ha_innodb.cc:20587) mysqld!QUICK_RANGE_SELECT::get_next() (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/opt_range.cc:11247) mysqld!rr_quick(READ_RECORD*) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/records.cc:405) mysqld!Sql_cmd_delete::mysql_delete(THD*, unsigned long long) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/sql_delete.cc:470) mysqld!Sql_cmd_delete::execute(THD*) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/sql_delete.cc:1400) mysqld!mysql_execute_command(THD*, bool) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/sql_parse.cc:3616) mysqld!mysql_parse(THD*, Parser_state*) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/sql_parse.cc:5584) mysqld!dispatch_command(THD*, COM_DATA const*, enum_server_command) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/sql_parse.cc:1491) mysqld!do_command(THD*) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/sql_parse.cc:1032) mysqld!::handle_connection(void *) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/conn_handler/connection_handler_per_thread.cc:313)
進入prepare的堆疊
mysqld!ha_prepare_low(THD*, bool) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/handler.cc:2339) mysqld!MYSQL_BIN_LOG::prepare(THD*, bool) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/binlog.cc:8607) mysqld!ha_commit_trans(THD*, bool, bool) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/handler.cc:1791) mysqld!trans_commit_stmt(THD*) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/transaction.cc:465) mysqld!mysql_execute_command(THD*, bool) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/sql_parse.cc:4995) mysqld!mysql_parse(THD*, Parser_state*) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/sql_parse.cc:5584) mysqld!dispatch_command(THD*, COM_DATA const*, enum_server_command) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/sql_parse.cc:1491) mysqld!do_command(THD*) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/sql_parse.cc:1032) mysqld!::handle_connection(void *) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/sql/conn_handler/connection_handler_per_thread.cc:313) mysqld!::pfs_spawn_thread(void *) (/Users/xiaoyu.bai/Downloads/mysql-5.7.29/storage/perfschema/pfs.cc:2197) libsystem_pthread.dylib!_pthread_start (未知源:0) libsystem_pthread.dylib!thread_start (未知源:0)
關於從庫並行執行的相關程式碼,在
MySQL原始碼上理解下commit_order writeset writeset_session
中
看了程式碼能清楚的知道是怎麼排程分發事件的。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25719946/viewspace-2935710/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 5.7 並行複製MySql並行
- mysql 並行複製原理MySql並行
- MySQL 5.7並行複製MySql並行
- [Mysql]Mysql5.7並行複製MySql並行
- MySQL並行複製(MTS)原理(完整版)MySql並行
- MySQL Case-MySQL8.0真正的並行複製writesetMySql並行
- MySQL Case-MySQL5.7無效的並行複製MySql並行
- Mysql Master-slave複製簡單配置記錄MySqlAST
- MySQL刪除重複記錄並保留第一條MySql
- MySQL並行複製延時時間不準確MySql並行
- MySQL 並行複製方案演進歷史及原理分析MySql並行
- MySQL 主從複製之多執行緒複製MySql執行緒
- MySQL案例-並行複製亂序提交引起的同步異常MySql並行
- list複製踩坑記錄
- mysql主從複製的理解和搭建MySql
- Centos8.3、mysql8.0主從複製實戰記錄CentOSMySql
- 複製資訊記錄表|全方位認識 mysql 系統庫MySql
- MySQL複製MySql
- Redis原始碼剖析之主從複製Redis原始碼
- mysql複製--主從複製配置MySql
- MySQL 主從複製的執行流程MySql
- 例項解讀:MySQL並行複製如何解決特定的主從問題?MySql並行
- JavaScript物件複製理解JavaScript物件
- mysql複製那點事(2)-binlog組提交原始碼分析和實現MySql原始碼
- MySQL 8 複製(三)——延遲複製與部分複製MySql
- MySQL主從複製之GTID複製MySql
- MySQL 8 複製(一)——非同步複製MySql非同步
- MySQL 8 複製(二)——半同步複製MySql
- MySQL 8 複製(四)——GTID與複製MySql
- MySQL 8 複製(五)——配置GTID複製MySql
- 【RocketMQ】Dledger日誌複製原始碼分析MQ原始碼
- MySQL防止重複插入相同記錄 insert if not existsMySql
- MySQL 複製全解析 Part 11 使用xtrabackup建立MySQL複製MySql
- MySQL主從複製之半同步複製MySql
- MySQL主從複製之非同步複製MySql非同步
- 遞迴處理複製變數目錄按原路徑複製到新目錄的指令碼遞迴變數指令碼
- 第16節:基於WRITESET的並行複製方式並行
- VasSonic原始碼之並行載入原始碼並行