Transaction 2
Transaction 2
Transaction 2
write lock x
unlock x
write lock x, y
unlock x, y
write lock y
unlock y
Result:
• balx = 200 by T9
• balx = 220 T10
• baly = 440 T10
• baly = 340 T10
• The end result: balx == 220, baly == 340 does not
match either of the serial schedules
• Even adding exclusive locks around each read/write doesn’t
guarantee serializability
Example - Incorrect Locking Schedule
• Problem is that transactions release locks too soon,
resulting in loss of total isolation and atomicity.
• To guarantee serializability, need an additional
protocol concerning the positioning of lock and
unlock operations in every transaction.
• Several issues:
• choice of deadlock victim;
• how far to roll a transaction back;
• avoiding starvation
• Where one transaction (say the longest one) is not explicitly
prevented from progressing, but actually never does progress
• Wait-Die: long transactions repeatedly aborted to give priority to
shorter transactions
• Wound-Wait: short transactions never started because longer
transactions are always in process
• Tradeoff:
• coarser, the lower the degree of concurrency;
• finer, more locking information that is needed to be
stored.
• Best item size depends on the types of
transactions.