Transaction Isolation in detail

Isolation:

Even though multiple transactions may execute concurrently, the system guarantees that, for every pair of transactions Ti and Tj , it appears to Ti that either Tj finished execution before Ti started, or Tj started execution after Ti finished. Thus, each transaction is unaware of other transactions executing concurrently in the system.

in simple words any Transaction that is running, will never effect any other transaction in execution.

Example:

Let Ti be a transaction that transfers $50 from account A to account B. This transaction
can be defined as:

read(A);
A := A − 50;
write(A);
read(B);
B := B + 50;
write(B).

Lets assume that, just before the execution of transaction Ti, the values of accounts A and B are $1000 and $2000, respectively.

Even if the consistency and atomicity properties are ensured for each transaction, if several transactions are executed concurrently, their operations may interleave in some undesirable way, resulting in an inconsistent state.

For example, as we saw earlier (while describing Atomicity), the database is temporarily inconsistent while the transaction to transfer funds from A to B is executing, with the deducted total written to A (now A value is $950) and the increased total yet to be written to B (B value still $2000).

If a second concurrently running transaction reads A and B at this intermediate point and computes A+B, it will observe an inconsistent value.

Furthermore, if this second transaction then performs updates on A and B based on the inconsistent values that it read, the database may be left in an inconsistent state
even after both transactions have completed.

A way to avoid the problem of concurrently executing transactions is to execute transactions serially—that is, one after the other.

However, concurrent execution of transactions provides significant performance benefits.

Other solutions have therefore been developed; they allow multiple transactions to execute concurrently.

The isolation property of a transaction ensures that the concurrent execution of transactions results in a system state (consistent state) that is equivalent to a state that could have been obtained had these transactions executed one at a time in some order.

Isolation property is the responsibility of a component of the database system called the concurrency-control component.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s