20250119

This week will be busy. I hope I can make it through.

Designing Data-Intensive Applications - Chapter 7 - Transactions

Transactions are a database feature that helps prevent anomalies caused by read/write conflicts, allowing the application layer to avoid handling these situations.

An example of a conflict is when two clients increment the same counter. Both clients read the counter (almost) simultaneously, seeing the value as 3, and each writes 4 to the database. Ideally, the counter should be 5 because the increment occurs twice, but concurrent reads lead to this conflict. This is called lost updates.

In addition to lost updates, the following are examples of race conditions caused by concurrency:

This chapter also covers other concurrency issues such as read skew, write skew, and phantom reads.

To prevent concurrency issues, three widely used isolation levels are:

There are three main approaches to implementing serializable transactions.

PostgreSQL: Documentation: 17:13.2. Transaction Isolation

The Serializable isolation level is implemented using a technique known in academic database literature as Serializable Snapshot Isolation…


TODO:


index 20250117 20250120