Transactions
Efficient MySQL Performance
Contents
Row Locking
MVCC and the Undo Logs
History List Length
Common Problems
Reporting
Contents -detail
Row Locking
Record and next-key locks
Gap locks
Secondary Indexes
Insert Intention Locks
MVCC and the Undo Logs
History List Length
Common Problems
Large Transactions(Transaction Size)
Long-Running Transactions
Stalled Transactions
Abandoned Transactions
Reporting
Active Transactions: Latest
Active Transactions: Summary
Active Transaction: History
Committed Transactions: Summary
Summary
Isolation Levelはrow locking(data locks)に影響する
基本的なInnoDBのロックモードは
record lock(single index record)
next-key lock
gap lock
insert intention lock(allows INSERT into a gap)
デフォルトであるREPEATABLE READは行レンジをgap lockする
READ COMMITTEDはgap lockを無効化する
InnoDBはREPEATABLE READにおいてはConsistent snapshotsを使って他のトランザクションが行を変更したとしてもSELECTが同一内容を返すようにする
Consistent snapshotsはInnoDBにundo logの保存を要求する。古いバージョンの行の状態を再構築するためである。
Histry list length(HLL)はpurgeもflushもされていない古いrow versionの量を測る
data lockとundo logはCOMMIT/ROLLBACKによりtransactionが終了した時に解放される
ありがちなtransactionの問題:
large transactions(modify too many rows)
long-running transactions
stalled transactions
abandoned transactions
Performance Schemaで詳しいtransaction reportingができる
transactionのパフォーマンスはクエリのパフォーマンスと同じくらい重要だ
Intro
行ロックと分離レベルの関係
MVCCとundo logs
history list lengthと問題のあるトランザクション
よくある問題
レポート
Row Locking
特殊な場合を除きReadは行をlockしないがWriteは行をlockする
REPEATABLE READにおいては、実際に書き込むよりも多くの行をロックすることがある
Transactional Information Systems - Theory, Algorithms, and The Practice of Concurrency Control And Recovery
isolated とは何か
as if there were no other transactions and hence no concurrency
あるトランザクションは、あたかも他のトランザクションが存在しないかのように実行されることができるということ
Transactional Information Systems - Theory, Algorithms, and The Practice of Concurrency Control And Recoveryのp6の説明
High Performance MySQL
transactionとは原子的に扱われるSQL文の集まりのことである
all or nothing
transactionだけで話は終わらない
もし途中でDBサーバーがクラッシュしたら?
もし他のプロセスが途中でテーブルを消したら?
コネクションが切れたら?
これらを緩和するために複雑で遅い2相コミット(two-phase-commit)が存在する
システムがACID特性のテストをクリアしなければtransactionは十分ではない
Isolation_Level
Deadlocks
Transaction Logging
Transactions in MySQL