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
PKでのDELETE後INSERTでDEAD LOCKする問題事象のご説明
Search
Kentoku SHIBA
October 17, 2018
Technology
300
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PKでのDELETE後INSERTでDEAD LOCKする問題事象のご説明
REPEATABLE READで、PKでのDELETE後INSERTでDEAD LOCKする 問題事象について
Kentoku SHIBA
October 17, 2018
More Decks by Kentoku SHIBA
See All by Kentoku SHIBA
New features and enhancements of Spider Storage Engine for sharding
kentoku
0
1.2k
Spiderストレージエンジンのご紹介 2019/05/21
kentoku
2
1.2k
全スレーブが同時にレプリケーションを停止する問題事象
kentoku
0
270
Dead lock by inserting after deleting by primary key
kentoku
0
120
突然全てのスレーブのレプリケーションがunknown error reading log event on the masterというエラーで停止したら。おまけで、Spider Storage Engineを少し。
kentoku
1
26k
An issue of all slaves stop replication
kentoku
0
3.3k
Other Decks in Technology
See All in Technology
NDIでApple Vision Proにリアルタイム映像送信
jyouryuusui
0
130
Classmethod Company Deck
satoshi7
1
740
Rustuna: Rustによる高速なOptuna実装
pfn
PRO
0
200
古い指輪から広がった JAVA コミュニティ とのつながり
yamad
0
130
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
5
1.2k
自作バイナリを動かす「入口」8選
puhitaku
2
1.3k
Gemini Intelligence 入門 ― AppFunctions と Gemini Nano
takuroabe
0
310
Conditional PED-ANOVA: Hyperparameter Importance in Hierarchical & Dynamic Search Spaces
pfn
PRO
0
140
OptunaHub: ブラックボックス最適化のためのプラットフォーム
pfn
PRO
0
140
AI駆動で「他アプリの音を加工できる」アプリを作った
satomasahiro2005
0
180
PHPカンファレンス関西の招待状 / Invitation to PHP Conference Kansai
ykanoh
0
210
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
360
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
67k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
The Limits of Empathy - UXLibs8
cassininazir
2
720
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
43k
We Are The Robots
honzajavorek
0
400
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
Into the Great Unknown - MozCon
thekraken
41
2.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
BBQ
matthewcrist
90
10k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.3k
Transcript
PKでのDELETE後INSERTでDEAD LOCKする 問題事象のご説明 Kentoku SHIBA
- トランザクション隔離レベルREPEATABLE READ - 同じレコードをPKを指定して、同時にDELETEすると、一方は成 功し、もう一方はロック待ちとなる。 - DELETEに成功した方の接続で、削除したPKのレコードを INSERTするとDEAD LOCKになる。
問題事象
接続1 接続2 start transaction 接続2は、pk=1のレコードロック取得時にLOCK待ちになる。 接続1は、INSERT INTENTION GAP LOCKのチェックで、接続2のGAP LOCKにより待たされるためDEAD
LOCKとなる。 問題事象 start transaction delete from t1 where pk = 1; delete from t1 where pk = 1; LOCK待ちになる insert into t1 (pk) values (1); DEAD LOCKになる
- INSERT INTENTION GAP LOCK INSERTレコードのネクストキーに対して、GAP LOCK(INSERT INTENTION GAP LOCKを除く)もしくは、NOT
GAPではないレ コードLOCKがある場合、LOCK WAITとなる。 このチェックを通過後、 INSERT INTENTION GAP LOCKは即 時解除される。 - 暗黙レコードLOCK このレコードに対してLOCKのチェックが行われる際に、NOT GAPのレコードLOCKとして実体化する。 INSERT時はINSERT INTENTION GAP LOCKでLOCK競合を 確認し、INSERT後は暗黙レコードLOCKによって競合を確認する。 INSERT時のLOCK(REPEATABLE READ)抜粋
INSERT時のLOCKの挙動を踏まえると、 以下のケースのいずれかに該当すれば、 INSERT INTENTION GAP LOCKのチェックを省略できる。 - INSERTするレコードに既に排他レコードLOCKを取得している。 (DELETE、UPDATEが行われた場合など) INSERT
INTENTION GAP LOCKの省略の検討
- READ COMMITTEDが利用可能であるかを検討し、 READ COMMITTEDで、DELETE→INSERTを行う。 - 同一レコードに対する処理が同時に行われないように、追加の排 他制御を行う。 - リトライが可能であるかを検討し、リトライ処理を行う。
現時点での対応策