Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
2PC between Binlog and InnoDB
Search
tom--bo
May 21, 2024
380
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
2PC between Binlog and InnoDB
tom--bo
May 21, 2024
More Decks by tom--bo
See All by tom--bo
DDLが取得するMDLの調査(私的)まとめ
tombo
3
180
安全なDDLの実行を目指して 〜(その1)取得するMDLの把握〜
tombo
0
200
SQL SECURITY特性の扱いと作ったパッチ
tombo
1
110
MyRaft論文紹介
tombo
3
1k
WIP: 2PC between binlog and InnoDB
tombo
1
280
Dive into InnoDB from redo logs
tombo
3
1.9k
MySQLアンカンファレンス01_mysqlredo
tombo
1
1.2k
MySQLアンカンファレンス 開催概要
tombo
0
340
Featured
See All Featured
Site-Speed That Sticks
csswizardry
13
1.5k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6.2k
Fireside Chat
paigeccino
43
4k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
700
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
We Are The Robots
honzajavorek
0
360
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.3k
A Tale of Four Properties
chriscoyier
163
24k
AI: The stuff that nobody shows you
jnunemaker
PRO
9
990
Into the Great Unknown - MozCon
thekraken
41
2.7k
Test your architecture with Archunit
thirion
2
2.4k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Transcript
binlogとinnodbの2PC @MySQLアンカンファレンス #004 (2024/05/20) tom__bo
疑問 • redoログばかり⾒ていたけど、binlogとの関係は? • ファイルが違うので、binlogでコミットされていて、innodb(redo log)でコ ミットされていない事はありえる? • => どうやら2
Phase Commit (2PC)しているらしい • https://www.slideshare.net/takanorisejima/binary-log-2pc-group-commit • by @ts4thさん • 5.7.12時点の主要なクラスや関数を列挙しながら説明がされている • => 8.0.32での実装を調査してみた(今回の内容) • 以前8.0.28くらいの頃に整理したのですが、結構変わってました
2 Phase Commitとは • 分散システム上で調停者と参加者の全員がコミットするか、 アボートするか決定するAtomic Commitment Protocolの1つ • 最初のフェーズでvote(prepare)を⾏い、全参加者がYesだったら、
第2フェーズでCommit, そうでなければAbortメッセージを送る Coordinator Partitcipant Partitcipant 2. Yes 2’. Yes 1. Vote? Coordinator Partitcipant Partitcipant 3. Commit 3. Commit 3’. Commit
2PCのイメージ
2PCのリカバリイメージ • 各コンポーネントでメッセージの送信前にログを書く • 復旧後にコンポーネントでVoteに”Yes”, コーディネータに Commitのログが残っていたら復元 System Failure
BinlogとInnoDB間の2PC • リカバリのために利⽤ • システム障害時に、両者がCommitに合意したTxをリカバリ • サーバで発番するXIDを基準にして2PCを進⾏ • トランザクションコーディネータ(TC_LOG)が調停 •
binlogとの2PCはMYSQL_BIN_LOGクラスが進⾏ 2PCってコンセンサスとしてはあまり良くないんじゃなかった? Þ BInlogとInnoDBは分散していない(同⼀プロセス中の別コンポーネント) Þ コーディネータがSPOF、タイムアウトどう扱うか問題は気にしなくて良い
BinlogとInnoDB間の2PCとリカバリ • 通常処理は基本的に2PCの流れと同じ • メッセージの送受信ではなくて関数の呼び出し • XIDはTHD構造体に参加者が取りに⾏く • リカバリはBinlogでのコミットが基準 •
2フェーズ⽬のコミットの処理中にシステム障害が発⽣した場合、 Binlogでコミット(xidイベントの永続化)できていて、InnoDBでPrepare できているトランザクションはコミット済みとしてリカバリ
BinlogとInnoDB間の2PCのイメージ
INSERT処理の流れ • BEGIN; INSERT INTO ...; COMMIT;を実⾏し、その時の処理の流れ を整理する • “主要コンポーネント”で説明したServer,
Hander, MYSQL_BINLOG, InnoDB, Binlog間の関数呼び出しの流れを⽰す • シーケンス図画像は以下 • https://drive.google.com/drive/u/0/folders/1HRpvFq7YRxWOMx1gxdoLjd A7oqTCQeUa?ths=true
(シーケンス図で説明)
MySQL 2PCからのリカバリ 1. 最後のbinlogファイルに書かれているxid⼀覧を取得 • Binlog_recovery::recover() 2. xidのうち、innodbでprepareされているものTXをcommit • innobase_xa_recover()
-> trx_recover_for_mysql()
Future work • 2PC(TC_LOG)のインタフェース整理 • Abortするケースの処理 • トランザクショナルでないSEの対応 • InnoDBの実装に依存しているように⾒えるが他のAPIもあるのか?
• Binlogがレプリカに送信されるタイミングがいつなのか調査 • Semi-syncレプリのackを待つのは度のタイミングか? • Group Commit (and/or Ordered Commit)の仕組みの詳細調査 • 細かい確認事項 • cache_mngr->trx_cache.finalize()とGTID取得の前後関係
None