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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Transcript
13 slides
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
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
120
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
Believing is Seeing
oripsolob
1
280
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
320
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
460
How to make the Groovebox
asonas
2
2.6k
Everyday Curiosity
cassininazir
0
400
Docker and Python
trallard
47
4.3k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
980
The Mindset for Success: Future Career Progression
greggifford
PRO
0
560
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Thoughts on Productivity
jonyablonski
76
5.5k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k