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
400
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
200
安全なDDLの実行を目指して 〜(その1)取得するMDLの把握〜
tombo
0
200
SQL SECURITY特性の扱いと作ったパッチ
tombo
1
110
MyRaft論文紹介
tombo
3
1k
WIP: 2PC between binlog and InnoDB
tombo
1
290
Dive into InnoDB from redo logs
tombo
3
2k
MySQLアンカンファレンス01_mysqlredo
tombo
1
1.3k
MySQLアンカンファレンス 開催概要
tombo
0
360
Featured
See All Featured
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Paper Plane
katiecoart
PRO
5
55k
The browser strikes back
jonoalderson
0
1.9k
The agentic SEO stack - context over prompts
schlessera
0
1k
Typedesign – Prime Four
hannesfritz
42
3.2k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
620
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
790
Ethics towards AI in product and experience design
skipperchong
2
460
Done Done
chrislema
187
17k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
570
A designer walks into a library…
pauljervisheath
211
25k
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