Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
5Activity
0 of .
Results for:
No results containing your search query
P. 1
Transaction Management and Con Currency Control

Transaction Management and Con Currency Control

Ratings:

5.0

(1)
|Views: 45 |Likes:
Published by shevadanze

More info:

Published by: shevadanze on Feb 05, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

07/12/2013

pdf

text

original

 
Transaction Management and Concurrency control
Definition;
Transaction
– refers to an action or series of actions carried out by a single user or application program which accesses or changes the contents of the database.It is a logical unit of work on the database.A transaction can have one of two outcomes;1.If it completes successfully, it is said to have committed and the database reachesa new consistent state.2.On the other hand, if the transaction does not execute successfully, it is said tohave aborted and the database is restored to its original consistent state before theconcerned transaction started.Such a transaction is said to have rolled back or undone. A committed transactioncannot be aborted.If a transaction is committed by mistake, then another one has to be initiated to reversethe previous transaction’s effects. This new transaction is sometimes called acompensating transaction.Most DBMSs do not have an inbuilt way of determining which actions are groupedtogether to form a single transaction.A way of circumventing this is to provide key indicators for these important boundaries.Keywords like BEGIN, END, COMMIT and/or ROLLBACK (or their equivalent) areused.If these delimiters are not used, the entire program is usually regarded as a singletransaction, with the DBMS performing an automatic COMMIT when the programterminates correctly and a ROLLBACK if it does not.
Properties of transactions
1.Atomicity (the “all or nothing property”)
A transaction is an indivisible unit that is either performed in its entirety or not performedat all.
2.Consistency
A transaction must transform the database from one consistent state to another consistentstate.
3.Isolation
Transactions execute independently of one another. This means that any partial effects of one incomplete transaction are not “visible” to other transactions.
 
Transaction management & concurrency control
4.Durability
The effects of a successfully completed (committed) transaction are permanentlyrecorded in the database and must not be lost as a result of a subsequent failure.If a failure occurs during a transaction, then the database could be inconsistent. DifferentDBMSs provide for different ways of avoiding this. Oracle, for instance has thefollowing provisions;Use of the
 RECOVERY MANAGER (RMAN)
to ensure the database is restored to the stateit was in before the start of the transaction, and therefore a consistent state.The BUFFER MANAGER is responsible for the transfer of data between disk storageand main memory.
Concurrency Control
Refers to the process of managing simultaneous operations on the database withouthaving them interfere with each other.A key objective of developing a database is to enable many users to access shared dataconcurrently.Concurrent access is relatively easy if all users are only reading; as there is no way thatthey can interfere with one another.Alternatively, when two or more transactions are accessing the database simultaneouslyand at least one is updating data, there may be interference that can result ininconsistencies.Although two transactions may be perfectly correct in themselves, the interleaving of operations may produce incorrect results, thus compromising the integrity andconsistency of the database.There are 3 such occurrences;
1.
 Lost update problem
This is whereby an apparently successfully completed update operation by oneuser/application is prevailed/dominated by another user/application.ExampleAssume we have two transactions T
1
and T
2
.T
1
is withdrawing KSh. 1,000 from an account with a balance of Ksh. 10,000 and T
2
isdepositing Ksh. 5000 into the same account.If these transactions were executed serially, one after the other without interleaving of operations, the final balance would be Ksh. 14,000 no matter which transaction is performed first.
2
 
Transaction management & concurrency control
 Problem:
Transaction T
1
and T
2
start at nearly the same time, and both read the balance as Ksh.10,000. T
2
increases the balance by Ksh. 5,000 to have the balance at Ksh. 15,000 andstores the update in the database. Meanwhile transaction T
1
reduces its copy of the balance by Ksh. 1,000 to Ksh. 9,000 and stores the value in the database, overwriting the previous update by T
2
and thereby “losing” the Ksh. 5,000 previously added to the balance.
Illustration (Problem).TimeT
1
T
2
Balance
t
1
Begin transaction10,000t
2
Begin transactionRead (Balance)10,000t
3
Read (Balance)Balance = Balance + 5,00010,000t
4
Balance = Balance - 1,000Write (Balance)15,000t
5
Write (Balance)Commit9,000t
6
Commit9,000The loss of T
2
’s update can be avoided by preventing T
1
from reducing the value of theBalance until T
2
’s update has been completed.
Solution:
T
2
first requests a write_lock on the Balance. It can the proceed to read the value of the balance from the database, increase it by Ksh. 5,000 and write back the new value back tothe database. When T
1
starts, it also requests a write_lock on the Balance. However, sincethe balance is already write locked by T
2
, the request is not immediately granted and T
1
has to
wait
until the lock is released by T
2
. This happens only after T
2
commits.
Illustration - SolutionTimeT
1
T
2
Balance
t
1
Begin transaction10,000t
2
Begin transactionWrite_lock (Balance)10,000t
3
Write_lock (Balance)Read (Balance)10,000t
4
WAITBalance = Balance + 5,00015,000t
5
WAITWrite (Balance)15,000t
6
WAITCommit/unlock (Balance)15,000t
7
Read (Balance)15,000t
8
Balance = Balance - 1,00015,000t
9
Write (Balance)14,000t
10
Commit/unlock )Balance)14,000
2.
The uncommitted dependency problem
This occurs when one transaction is allowed to see the intermediate results of another transaction before it has committed.Assume 2 transactions T
3
and T
4
.
3

Activity (5)

You've already reviewed this. Edit your review.
1 hundred reads
Abey Francis liked this
shaggy0987 liked this
DeepakGupta liked this
hajaryunan liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->