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
XIDを周回させてみよう
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
ISHIDA Akio
August 09, 2011
Programming
23
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
XIDを周回させてみよう
ISHIDA Akio
August 09, 2011
More Decks by ISHIDA Akio
See All by ISHIDA Akio
SQLを実行したときに、PostgreSQLはどのようにデータにアクセスしているのか
iakio
0
300
Prophecyを使った ユニットテスト
iakio
0
15
phpspecで学ぶLondon School TDD
iakio
0
9
PostgreSQLの範囲型と排他制約
iakio
0
26
使いこなそうGUC
iakio
0
9
Other Decks in Programming
See All in Programming
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.3k
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
660
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
440
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
190
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
500
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
250
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
300
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.2k
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
190
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
360
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
260
Verilogで学ぶCPU自作入門.pdf
uyuki234
3
2k
Featured
See All Featured
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
460
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
500
First, design no harm
axbom
PRO
2
1.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Code Review Best Practice
trishagee
74
20k
The Pragmatic Product Professional
lauravandoore
37
7.5k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
410
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
730
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Become a Pro
speakerdeck
PRO
31
6.3k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
440
Transcript
XIDを 周回させてみよう 2011-08-09 PostgreSQL勉強会@札幌 @iakio
今日の話 • PostgreSQLを長期間運用していると、突然有るはずの データが見えなくなってしまうという、XIDの周回問題と呼 ばれる現象があるらしい • でも滅多にお目にかかれません • じゃあ無理矢理にでもやってみよう
トランザクションIDとは INSERT INTO r(i) VALUES(1); INSERT INTO r(i) VALUES(2); INSERT
INTO r(i) VALUES(3); SELECT xmin, xmax, i FROM r; xmin xmax i 664 0 1 665 0 2 666 0 3
トランザクションIDとは INSERT INTO r(i) VALUES(1); INSERT INTO r(i) VALUES(2); INSERT
INTO r(i) VALUES(3); SELECT xmin, xmax, i FROM r; DELETE FROM r WHERE i = 1; UPDATE r SET i = 4 WHERE i = 2; xmin xmax i 664 667 1 665 668 2 666 0 3 668 0 4
古い 新しい • XIDは32bit(40億) • T1に対してT2が新しいか 古いかは、T2-T1で決ま る • XIDを20億ちょい進める
と、新旧が逆転する
• なので、現在のXIDを例えば30億ほど進めれば、いきなり 見えてたものが見えなくなります • でもそんなのはつまらないですよね • 見えなくなる瞬間を見たい。が、それにはいくつかの壁
XIDの周回を防止する仕組み1 • 0から2は特殊なXID • 2がFrozenXIDと呼ばれ、どのXIDよりも古いとみなされる • 十分に古いXIDをFrozenXIDに置き換えることで、XIDの周 回を防止する • autovacuumがOFFでも実行される
XIDの周回を防止する仕組み1 • 前回のFreezeからXIDが2億進んだら (autovacuum_freeze_max_age) • 5千万より前のXIDをFrozenXIDにおきかえる (vacuum_freeze_min_age) • どこまで凍結したかをpg_class.relfrozenxidに記録する 2億
5千万 2億 5千万
XIDの周回を防止する仕組み2 • 残り1000万トランザクションで警告 • 残り100万トランザクションでエラーとなり、新しいトラン ザクションを受け入れなくなる(standalone modeで起動し なおしてvacuumを行う必要がある)
これがXIDを周回させる方法だ • データベースを停止 • pg_resetxlogでXIDを2^31に進める • pg_resetxlog -x 0x80000000 •
standaloneモードで起動し、pg_database.datfrozenxidと pg_class.relfrozenxidを2^31に進める • データベースを起動 • ちまちまXIDを消費(SELECT txid_current())
参考 • PostgreSQLドキュメント 「23.1.4. トランザクションIDの周回エラーの防止」 http://www.postgresql.jp/document/current/html/routine-vacuu