楽観的ロックとは?
楽観的ロックは、トランザクションをロックせずに進めさせ、書き込み時に、通常はバージョン番号やタイムスタンプを介して、読み取り以降その行が変更されていないことを検証する並行性戦略です。バージョンが一致しなくなっている場合、その更新は競合として拒否されます。アプリケーションはその後、再試行するか、競合をユーザーに提示します。
なぜ重要か
ロックを保持しないことで、競合がまれなときにスループットを高く保てます。その代償として、時折の衝突を未然に防ぐのではなく、検出して再試行しなければなりません。
関連ガイド
What Is Pessimistic Locking?Pessimistic locking takes a lock on data as soon as it is read, blocking other transactions from changing it…
What Is a Database Deadlock?A database deadlock occurs when two transactions each hold a lock the other needs, so neither can proceed unt…
What Is a Unit of Work?A unit of work tracks changes to objects during a business operation and commits them together as a single co…