三津石智巳

👦🏻👦🏻👧🏻 Father of 3 | 🗺️ Service Reliability Engineering Manager at Rakuten Travel | 📚 Avid Reader | 👍 Wagashi | 👍 Caffe Latte | 👍 Owarai

【感想】7. Transactions - Designing Data-Intensive Applications

"Thus, the database guarantees that if the transactions behave correctly when run individually, they continue to be correct when run concurrently—in other words, the database prevents all possible race conditions."

via Check out this quote from Designing Data-Intensive Applications - https://learning.oreilly.com/library/view/designing-data-intensive-applications/9781491903063/ch07.html

consistency anomaliesを暗記する必要はない。なぜなら、serializable isolationを使えば全ての問題は解決するのだから。

"

  • Literally executing transactions in a serial order (see “Actual Serial Execution”)
  • Two-phase locking (see “Two-Phase Locking (2PL)”), which for several decades was the only viable option
  • Optimistic concurrency control techniques such as serializable snapshot isolation (see “Serializable Snapshot Isolation (SSI)”

"

via Check out this quote from Designing Data-Intensive Applications - https://learning.oreilly.com/library/view/designing-data-intensive-applications/9781491903063/ch07.html

しかも、serializable isolationの実装は限られている。あとは選ぶだけだ。

"In the early days of databases, the intention was that a database transaction could encompass an entire flow of user activity. For example, booking an airline ticket is a multi-stage process (searching for routes, fares, and available seats; deciding on an itinerary; booking seats on each of the flights of the itinerary; entering passenger details; making payment). Database designers thought that it would be neat if that entire process was one transaction so that it could be committed atomically."

via Check out this quote from Designing Data-Intensive Applications - https://learning.oreilly.com/library/view/designing-data-intensive-applications/9781491903063/ch07.html

これ、言われてみれば自然な発想だが、全然意識できていなかった。
例えば旅行代理店の窓口で最初から最後まで一人の店員さんが対応するようなイメージにトランザクションの出自がある。

"With stored procedures and in-memory data, executing all transactions on a single thread becomes feasible. As they don’t need to wait for I/O and they avoid the overhead of other concurrency control mechanisms, they can achieve quite good throughput on a single thread."

via Check out this quote from Designing Data-Intensive Applications - https://learning.oreilly.com/library/view/designing-data-intensive-applications/9781491903063/ch07.html

actual serial executionの文脈においてstored procedureは

  • 2つ以上のobjectの読み書きからなるトランザクションを可能にする
  • (アプリケーション・クライアントからみた時の)ネットワークラウンドトリップを0にする

"On top of snapshot isolation, SSI adds an algorithm for detecting serialization conflicts among writes and determining which transactions to abort."

via Check out this quote from Designing Data-Intensive Applications - https://learning.oreilly.com/library/view/designing-data-intensive-applications/9781491903063/ch07.html

期待の新人ことserializable snapshot isolationについてはまた今度。