Time Stamp Protocols
Time Stamp Protocols
ON TIMESTAMP
PROTOCOLS
BY:
PRASHANT PRIYADARSHI (110103135)
PRASHANT SAINI (110103134)
RONIT RAJ (110103160)
PRIYANKA KUMARI(110103139)
INTRODUCTION
•Typically, timestamp values are assigned in the order in which the transactions
are submitted to the system, so a timestamp can be thought of as the transaction
start time.
•One possibility is to use a counter that is incremented each time its value is
assigned to a transaction. The transaction timestamps are numbered 1, 2, 3, . . .
in this scheme.
•A computer counter has a finite maximum value, so the system must periodically
reset the counter to zero when no transactions are executing for some short
period of time.
•Notice how this differs from 2PL, where a schedule is serializable by being
equivalent to some serial schedule allowed by the locking protocols.
•The algorithm must ensure that, for each item accessed by conflicting
operations in the schedule, the order in which the item is accessed does not
violate the serializability order.
•To do this, the algorithm associates with each database item X two timestamp
(TS) values:-
1. Read_TS(X): The read timestamp of item X; this is the largest timestamp
among all the timestamps of transactions that have successfully read item X—
that is, read _TS(X) = TS(T), where T is the youngest transaction that has
read X successfully.
2. Write_TS(X): The write timestamp of item X; this is the largest of all the
timestamps of transactions that have successfully written item X—that is,
write_ TS(X) = TS(T), where T is the youngest transaction that has
written X successfully.
BASIC TIMESTAMP ORDERING
•Whenever some transaction T tries to issue a read_item(X) or a write_item(X)
operation, the basic TO algorithm compares the timestamp of T with read_TS(X)
and write_TS(X) to ensure that the timestamp order of transaction execution is
not violated.
a. If read_TS(X) > TS(T) or if write_TS(X) > TS(T), then abort and roll back T and
reject the operation. This should be done because some younger transaction
with a timestamp greater than TS(T)—and henceafter T in the timestamp
ordering—has already read or written the value of item X before T had a chance
to write X, thus violating the timestamp ordering.
b. If the condition in part (a) does not occur, then execute the write_item(X)
operation of T and set write_TS(X) to TS(T).
2. Transaction T issues a read_item(X) operation:
a. If write_TS(X) > TS(T), then abort and roll back T and reject the operation. This
should be done because some younger transaction with timestamp greater than
TS(T)—and hence after T in the timestamp ordering—has already written the value of
item X before T had a chance to read X.
b. If write_TS(X) <= TS(T), then execute the read_item(X) operation of T and set
read_TS(X) to the larger of TS(T) and the current read_TS(X).
STRICT TIMESTAMP ORDERING
1. If read_TS(X) > TS(T), then abort and roll back T and reject the operation.
2. If write_TS(X) > TS(T), then do not execute the write operation but continue
processing. This is because some transaction with timestamp greater than TS(T)—
and hence after T in the timestamp ordering—has already written the value of X.
Hence, we must ignore the write_item(X) operation of T because it is already
outdated and obsolete. Notice that any conflict arising from this situation would
be detected by case (1).
3. If neither the condition in part (1) nor the condition in part (2) occurs, then
execute the write_item(X) operation of T and set write_TS(X) to TS(T).
Correctness of Timestamp-Ordering
• The timestamp-ordering protocol guarantees serializability
since all the arcs in the precedence graph are of the form:
transaction transaction
with smaller with larger
timestamp timestamp