Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
hbstyle-20141211.pdf
Search
rrreeeyyy
December 11, 2014
0
24
hbstyle-20141211.pdf
rrreeeyyy
December 11, 2014
Tweet
Share
More Decks by rrreeeyyy
See All by rrreeeyyy
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
An Efficient Incident Response Training with AI / SRE NEXT 2024 Sponsor Session
rrreeeyyy
1
3.4k
カンファレンスから見る SRE トレンド 2024 / SRE Trends from Conferences in 2024 #SRE_Findy
rrreeeyyy
4
2.2k
信頼性の育て方 / mackerel-meetup-15
rrreeeyyy
9
2.4k
SRE の歩き方・進め方 / sre-walk-through-procedure
rrreeeyyy
0
8.5k
「信頼性」を保ちつつ大規模サービスをリニューアルする / cookpad-tech-kitchen-service-embedded-sres
rrreeeyyy
11
12k
Cookpad and Prometheus
rrreeeyyy
6
20k
SRE-Lounge-8-Cookpad-Microservice-Architecture-Overview
rrreeeyyy
5
5.2k
A survey of anomaly detection methodologies for web system
rrreeeyyy
5
1.2k
Featured
See All Featured
The Cult of Friendly URLs
andyhume
78
6k
Scaling GitHub
holman
458
140k
A Philosophy of Restraint
colly
203
16k
Building Adaptive Systems
keathley
38
2.3k
Navigating Team Friction
lara
183
14k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Writing Fast Ruby
sferik
627
61k
How GitHub (no longer) Works
holman
310
140k
Making Projects Easy
brettharned
115
5.9k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Transcript
MySQL ϨϓϦέʔγϣϯͷόάͱ ݪҼಛఆʹ͍ͭͯ YOSHIKAWA Ryota hbstyle-2014-12-11 1
ܦҢ • MySQL (5.5.32) ʹͯɺϨϓϦέʔγϣϯͷෆ۩߹͕ൃੜ • DDL શͯө͞ΕΔ • DML
ಛఆͷςʔϒϧʹͯө͞Εͳ͍ • Slave_(IO|SQL)_Running ڞʹ Yes • Τϥʔແ͠ • ͪͳΈʹ MySQL 5.6.10 Ҏલશ͕ͯόάͷରͱͳ͍ͬͯΔ YOSHIKAWA Ryota hbstyle-2014-12-11 2
ݪҼ • MasterDB ͷ table_id ͕ UINT_MAX Λ͑Δ • SlaveDB
ͷ table_id ͕Φʔόʔϑϩʔ • MasterDB ͕͍࣋ͬͯΔ table_id ͱ, ϨϓϦέʔγϣϯͰୡ͞ΕΔ table_id ʹෆ߹͕ൃੜ • binlog ͕ Row|Mixed ͷϨϓϦέʔγϣϯͰӨڹ • http://bugs.mysql.com/bug.php?id=67352 YOSHIKAWA Ryota hbstyle-2014-12-11 3
ݪҼ (ଓ͖) • Slave ͕อ࣋͢Δ table_id uint • 64bit
Linux ڥͰ 4294967295 ͕࠷େ • Master ͕อ࣋͢Δ table_id (table_map_id) ulong • 64bit Linux ڥͰ 18446744073709551615 ͕࠷େ • ςʔϒϧͷ࡞Γ͠, TRUNCATE Ͱ table_id ͕ߋ৽͞ΕΔ • ෆ߹͕ى͖Δͱ Slave σʔλΛߋ৽Ͱ͖ͳ͍ (Τϥʔແ) YOSHIKAWA Ryota hbstyle-2014-12-11 4
• σόοάϩά table_mapping::set_table(ulong,TABLE*): enter: table_id: 20497567 table: 0x3d361f0 (check_repl) table_mapping::set_table(ulong,TABLE*):
info: tid 20497567 -> table 0x3d361f0 (check_repl) table_mapping::get_table(ulong): enter: table_id: 4315464863 table_mapping::get_table(ulong): info: tid 4315464863 is not mapped! ... 20497567 = 4315464863 - (4294967295 + 1) ... (4294967295 + 1) UINT_MAX • ιʔείʔυ * table_map_id > # grep -n "ulong table_map_id" sql/table.h > 645: ulong table_map_id; /* for row-based replication */ * table_id > # grep -n "uint table_id" sql/table.h > 1457: uint table_id; /* table id (from binlog) for opened table */ YOSHIKAWA Ryota hbstyle-2014-12-11 5
Ͳ͏ͬͯಛఆ͔ͨ͠ YOSHIKAWA Ryota hbstyle-2014-12-11 6
Day1 YOSHIKAWA Ryota hbstyle-2014-12-11 7
ਪଌʹΑΔԾઆݕূͷ܁Γฦ͠ • ਓ͕ؒ૾Ͱ͖Δൣғͷόάͩͱ͜ͷํ๏͕ߴ(ܦݧతʹ) • ಉ༷ͷݱ(slave ߋ৽ෆՄ)Λ google Ͱͻͨ͢Βݕࡧɾݕূ • ਓؒͷ૾Ͱ͖ͳ͍ൣғͷόάͩͱϋϚΔ
• લྫͷݟ͕ݕࡧͮ͠Β͍/ແ͍߹ಛʹ • ܦݧΛੵΉࣄͰൣғΛ͛Δ͜ͱՄೳͳؾ͢Δ YOSHIKAWA Ryota hbstyle-2014-12-11 8
Day2 YOSHIKAWA Ryota hbstyle-2014-12-11 9
ࣄͷ࠶ݱɾΓ͚ • ࣗͷݕࡧɾਪଌग़དྷΔϨϕϧΛ͍͑ͯΔࣄΛೝࣝ • ຊ൪ػͷ binlog ΛோΊͯոͦ͠͏ͳૢ࡞Λચ͍ग़͢ • Slave ͷσʔλΛݟͯԿ࣌ࠒʹෆ߹͕ى͖͔ͨ֬ೝ
• ෆ۩߹͕ى͖ͯΔ DB ͰࣄͷΓ͚ • σʔλϑΝΠϧͷ༰ྔຊʹ૿͍͑ͯͳ͍͔ • ϦϨʔϩάʹॻ͖ࠐΈ͕͋Δ͔... YOSHIKAWA Ryota hbstyle-2014-12-11 10
Day3 YOSHIKAWA Ryota hbstyle-2014-12-11 11
࠶ݱࡁΈڥͰͷσόοά • ো͕ى͖͍ͯͨ Master ʹผͷ Slave Λܨ͙ͱ࠶ݱग़དྷͨ • Slave ʹؔΘΒͣো͕ى͖Δ
=> Master ͓͔ͦ͠͏ • Slave ͷ MySQL Λ Debug ༗ޮͰϏϧυͯ͠ܨ͍ͰΈΔ cmake . -DWITH_DEBUG=1 -DMYSQL_MAINTAINER_MODE=0 • ਖ਼ৗͳ Master ʹܨ͍ͩ࣌ͷϩάͱҟৗͳϩάΛݟൺΔ • ϩάͱιʔείʔυΛൺֱͯ͠Ͳ͜ͰԿ͕ى͖ͯΔ͔Ѳ YOSHIKAWA Ryota hbstyle-2014-12-11 12
ʹཱͬͨπʔϧ • mysqlbinlog (binlog, relaylog ղੳ) • tcpdump & Percona
Toolkit (ύέοτɾσʔλෆ߹ௐࠪ) • icdiff (֤छϩάͷൺֱ) • gdb (MySQL ͷσόοά) • vim & ctags & Unite grep ... (ιʔείʔυϦʔσΟϯά) YOSHIKAWA Ryota hbstyle-2014-12-11 13
ʹཱͬͨݟ (1) • hbstyle Ͱͷݟ • @indigo13love ͞Μͷੲͷൃද • sql/slave.cc
ϨϓϦέʔγϣϯͷݟ • ܭࢉػՊֶͷݟ • MySQL Packet ͷϔομ͙Β͍ͳΒಡΊΔ • ֶ෦ͷ࣌ʹύέοτோΊͨݟ YOSHIKAWA Ryota hbstyle-2014-12-11 14
ʹཱͬͨݟ (2) • ιʔείʔυϦʔσΟϯάͷݟ • ֶ෦࢛Ͱ৭ΜͳιϑτΣΞͷιʔείʔυಡΜͩݟ • Apache, Nginx, Keepalived,
LVS ... • ϏϏΒͳ͍͜ͱ • ϩάͱಥ͖߹Θͤ • ͏πʔϧͷݟ YOSHIKAWA Ryota hbstyle-2014-12-11 15
πʔϧͷ͍ํͱ͔ιʔεಡΈͱ͔ͪΐͬͱ͚ͩ YOSHIKAWA Ryota hbstyle-2014-12-11 16
ল YOSHIKAWA Ryota hbstyle-2014-12-11 17
Don't guess, measure! — Robert C. Pike YOSHIKAWA Ryota hbstyle-2014-12-11
18
ল • ਪଌ͢ΔͳɺܭଌͤΑ • ύϑΥʔϚϯε͚ͩͰͳ͘όάಉ͡ • (ఆͷ)؆୯ͳόάΛ૬खʹͯ͠ΔͱΕΔ͜ͱ͋Δ • ࣄɾݪҼΓ͚ɾιʔείʔυ͕શͯ •
ϩάΛݟΔɾιʔείʔυΛݟΔ YOSHIKAWA Ryota hbstyle-2014-12-11 19
• νϟοτͱ͔ͷݺͼ͔͚Ͱڠྗͯͩͬͨ͘͠͞օ͞Μ͋Γ͕ ͱ͏͍͟͝·ͨ͠ • ಛʹ @saito @takamoto @hosokoshi @matsuu ...
• ͬͱݕࡧྗ͕ߴ͚ΕҰൃͰͨͲΓண͍͔ͨ͠Εͳ͍ • http://bugs.mysql.com/bug.php?id=67352 • ʮݪҼΈ͚ͭΔͷʹֻ͔ͬͪΌͬͨʯ ͱͷ͜ͱ • ͱ͍͑ MySQL ʹͪΐͬͱৄ͘͠ͳΕͯΑ͔ͬͨ YOSHIKAWA Ryota hbstyle-2014-12-11 20