Timestamp-Based Protocols
- Each transaction Ti is issued a timestamp TS(Ti)
when it enters the system.
•
Each transaction has a unique timestamp
•
Newer transactions have timestamps strictly greater than earlier ones
•
Timestamp could be based on a logical counter
§ Real time may not be unique
§ Can use (wall-clock time, logical
counter) to ensure
- Timestamp-based protocols
manage concurrent execution such that
time-stamp order = serializability order - Several alternative protocols
based on timestamps
The timestamp
ordering (TSO) protocol
- Maintains for each data Q two
timestamp values:
•
W-timestamp(Q) is the largest
time-stamp of any transaction that executed write(Q)
successfully.
•
R-timestamp(Q) is the largest
time-stamp of any transaction that executed read(Q) successfully.
- Imposes rules on read and
write operations to ensure that
•
Any conflicting operations
are executed in timestamp order
Out of
order operations cause transaction rollback
Suppose a
transaction Ti issues a read(Q)
1. If TS(Ti) < W-timestamp(Q),
then Ti needs to read a value of Q that
was already overwritten.
- Hence, the read
operation is rejected, and Ti is rolled back.
2. If TS(Ti) ³ W-timestamp(Q),
then the read operation is executed, and
R-timestamp(Q) is set to
max(R-timestamp(Q), TS(Ti)).
Suppose
that transaction Ti issues write(Q).
1. If TS(Ti) <
R-timestamp(Q), then the value of Q that Ti is
producing
was needed previously, and the system
assumed that that value
would never be produced.
Ø Hence, the write operation
is rejected, and Ti is rolled back.
2. If TS(Ti) <
W-timestamp(Q), then Ti is attempting to write an
obsolete value of Q.
Ø Hence, this write operation
is rejected, and Ti is rolled back.
3. Otherwise, the write operation is executed, and
W-timestamp(Q) is
set to TS(Ti).
n
Recoverable schedule — if a transaction Tj reads a data items
previously written by a transaction Ti , the commit operation
of Ti appears before
the commit operation of Tj.
The following schedule (Schedule 11) is not recoverable if T9 commits immediately after the read
If T8 should abort, T9
would have read (and possibly shown to the user) an inconsistent database
state. Hence database must ensure that
schedules are recoverable
Cascading rollback – a single transaction failure leads to a series of transaction
rollbacks. Consider the following
schedule where none of the transactions has yet committed (so the schedule is
recoverable)
n
If T10 fails,
T11 and T12 must also be rolled back.
n
Can lead to the undoing of a
significant amount of work
n
Cascadeless schedules — cascading rollbacks cannot occur; for each pair of transactions Ti
and Tj such that Tj reads a data item previously written by Ti,
the commit operation of Ti appears before the read operation of Tj.
n
Every cascadeless schedule is
also recoverable
n
It is desirable to restrict the
schedules to those that are cascadeless
System is deadlocked if there is a
set of transactions such that every transaction in the set is waiting for
another transaction in the set.
No comments:
Post a Comment