Anomalies
Lost Update Problem

- Update of $T_1$ is overwritten by update of $T_2$.
- Update of $T_1$ is essentially lost forever
Dirty Read Problem

- Update on $X$ of $T_1$ fails, and the changes of $X$ should be undone
- However, $T_2$ already used the incorrect results from $T_1$
Locks
read_lock:
- 属于 shared lock
- 允许其他线程 read,但不允许 write
write_lock:
- 属于 exclusive lock
- 不允许 read,也不允许 write
Granularity of Lock
Definition: size of the data item being locked
-
e.g. Block / Table / Tuple (record) / Field (column)
-
does not impact correctness, does impact performance
| Lock Size: |
Small |
Big |
| Lock conflict prob. |
Low |
High |
| Concurrency |
High |
Low |
| Overhead |
High |
Low |