Transaction Processing Concepts: Goals
Transaction Processing Concepts: Goals
Transaction Processing Concepts: Goals
Example of a Transaction T
read(A,x)
x := x - 200
write(x,A) Transaction Schedule reflects
read(B,y) chronological order of operations
y := y + 100
write(y,B)
Lost Update
Time Transaction T1 Transaction T2
1 read(A,x)
2 x:=x+200
3 read(A,y)
4 y:=y+100
5 write(x,A)
6 write(y,A)
7 commit
8 commit
Dirty Read
Time Transaction T1 Transaction T2
1 read(A,x)
2 x:=x+100
3 write(x,A)
4 read(A,y)
5 write(y,B)
6 rollback
Serializability
DBMS must control concurrent execution of transactions to
ensure read consistency, i.e., to avoid dirty reads etc.
Ti Tj Ti Tj
write(x,A) write(x,A)
read(A,y) write(y,A)
(order matters) (order matters)
Lock-Compatibility Matrix:
E.g., xlock(A) has to wait until all slock(A) have been released.
In PostgreSQL (or Oracle) the user can specify the following locks
on relations and tuples using the command
lock table in <mode> mode;
T1 T2
set transaction isolation
level serializable
set transaction . . .
update R set A = new
where B = 1
commit
update R set A = new
where B = 1
→ ERROR