Notes and Study Materials

Concurrency Control With Time Stamping

 

 

The time stamping approach to scheduling concurrent transactions assigns a global, unique time stamp to each transaction. The time stamp value produces an explicit order in which transactions are submitted to the DBMS. Time stamps must have two properties: uniqueness and monotonicity. Uniqueness ensures that no equal time stamp values can exist, and monotonicity ensures that time stamp values always increase.

All database operations (Read and Write) within the same transaction must have the same time stamp. The DBMS executes conflicting operations in time stamp order, thereby ensuring serializability of the transactions. If two transactions conflict, one is stopped, rolled back, rescheduled, and assigned a new time stamp value.

The disadvantage of the time stamping approach is that each value stored in the database requires two additional time stamp fields: one for the last time the field was read and one for the last update. Time stamping thus increases memory needs and the database’s processing overhead. Time stamping demands a lot of system resources because many transactions might have to be stopped, rescheduled, and restamped.

 

You May Also Like:


Transaction and Its Properties

Concurrency Problems

Concurrency Control with Locking

 

Wait/Die and Wound/Wait Schemes

 

You have learned that time stamping methods are used to manage concurrent transaction execution. In this section, you will learn about two schemes used to decide which transaction is rolled back and which continues executing:

 

 

The wait/die scheme and the wound/wait scheme.

 

An example illustrates the difference. Assume that you have two conflicting transactions: T1 and T2, each with a unique time stamp. Suppose T1 has a time stamp of 11548789 and T2 has a time stamp of 19562545. You can deduce from the time stamps that T1 is the older transaction (the lower time stamp value) and T2 is the newer transaction. Given that scenario, the four possible outcomes are shown in the following Table.


 concurrency control with time stamping methods

Using the wait/die scheme:

• If the transaction requesting the lock is the older of the two transactions, it will wait until the other transaction is completed and the locks are released.

 

• If the transaction requesting the lock is the younger of the two transactions, it will die (roll back) and is rescheduled using the same time stamp.

 

In short, in the wait/die scheme, the older transaction waits for the younger to complete and release its locks

 

In the wound/wait scheme:

 

• If the transaction requesting the lock is the older of the two transactions, it will preempt (wound) the younger transaction (by rolling it back). T1 preempts T2 when T1 rolls back T2. The younger, preempted transaction is rescheduled using the same time stamp.

 

• If the transaction requesting the lock is the younger of the two transactions, it will wait until the other transaction is completed and the locks are released.

 

In short, in the wound/wait scheme, the older transaction rolls back the younger transaction and reschedules it.

 

 

In both schemes, one of the transactions waits for the other transaction to finish and release the locks. However, in many cases, a transaction requests multiple locks. How long does a transaction have to wait for each lock request? Obviously, that scenario can cause some transactions to wait indefinitely, causing a deadlock. To prevent that type of deadlock, each lock request has an associated time-out value. If the lock is not granted before the time-out expires, the transaction is rolled back.

You May Also Like:

Concurrency Control With Optimistic Method

Deadlocks in DBMS

Back to DBMS Questions