Search for notes by fellow students, in your own course and all over the country.
Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.
Document Preview
Extracts from the notes are below, to see the PDF you'll receive please use the links above
CONCURRENCY
CONTOL
Copyright @ www
...
com
DEFINITION
Concurrency means allowing more than one transaction
to run simultaneously on the same database
...
To remove this problem Concurrency control is used
...
bcanotes
...
CC techniques are used to ensure that multiple
transactions submitted by various users do not
interfere with one another in a way that produces
incorrect results
...
Copyright @ www
...
com
Advantages of Concurrent Execution of Transactions
Improvement Throughput
Reduced Waiting Time
Copyright @ www
...
com
Problems of Concurrent Execution of
Transactions
For Concurrency problems following control
mechanism is required:
Lost Update Problem
The Temporary Update (Uncommitted Dependency) Problem
The Incorrect Summary (Inconsistent Analysis) Problem
Copyright @ www
...
com
The Lost Update Problem
In this problem, 2 transactions accessing the
same database item have their operations
interleaved in a way that makes the database
item incorrect
...
bcanotes
...
bcanotes
...
Copyright @ www
...
com
Consider the Example - The Temporary Update
(Uncommitted Dependency) Problem
Step
T1
T2
Result
1
Start Transaction
A=200
2
Read (A)
A=200
3
A=A-100
A=200
4
Write (A)
Start Transaction
A=100
5
Read (A)
A=100
6
A=A+150
A=100
Write (A)
A=250
Commit
A=250
7
8
ROLL BACK
Since the transaction is Aborted so the database will be
restored to its originalCopyright @ www
...
com
state Rs 200
...
For e
...
Values of variable A, B, C and Sum
are in column 3,4,5 and 6
...
Copyright @ www
...
com
The Incorrect Summary (Inconsistent Analysis)
Problem
T1
T2
A
B
C
SUM
R(A,a)
R(A,a)
Rs
...
50
Rs
...
100
Rs
...
25
100
Value of Sum is changed due
to T1 operation and content
of local variable ‘a’ is
changed to 90
R(B,b)
W(A,a)
Rs
...
50
Rs
...
90
Rs
...
25
150
Value of Sum is changed due
to T1 Operation
...
90
Rs
...
25
150
Content of local variable ‘c’ is
changed to 35
W(C,c)
Rs
...
50
Rs
...
e
...
90
Rs
...
35
150
Value of C is read out as 35
by T1
R(C,c)
sum=sum+C
Copyright @ www
...
com 185
Rs
...
50 Rs
...
e
...
bcanotes
...
Methods of Pessimistic approach:
Locking Protocol
Time Stamp Based Protocol
Copyright @ www
...
com
Locking for Concurrency Control
Locking
It is a procedure used to control concurrent access to data
...
Lock
It is a variable associated with a data item
...
Copyright @ www
...
com
Types of Lock
Binary Lock-Two States (Lock and Unlock)
Share/Exclusive Lock (Read/Write)
Copyright @ www
...
com
Locking Operations
Read_lock(A)= Lock-S(A)
Write_lock(A)=Lock-X(A)
Unlock(A)
S-Shared Lock
X-Exclusive Lock
Copyright @ www
...
com
Compatibility of Locks
Shared Lock
Exclusive Lock
Shared Lock
Yes
No
Exclusive Lock
No
No
Copyright @ www
...
com
Locking Example
T1
T2
Lock-X (A)
Read (A)
A=A+50
Write (A)
Unlock (A)
Lock-X (A)
Read (A)
A=A-40
Write (A)
Unlock (A)
Lock-X (B)
Read (B)
B=B+100
Write (B)
Unlock (B)
Copyright @ www
...
com
Problems with Locking
Dead Lock:
It happens whenever a transaction waits for a lock to be
unlock (to access the data)
...
Copyright @ www
...
com
Deadlock Example
T1
T2
Lock-X (B)
Read (B)
B=B+50
Write (B)
Lock-S (A)
Read (A)
Lock-S (B)
Wait
...
Lock-X (A)
Wait
...
Copyright @ www
...
com
Starvation Example
T2 holds data item on Shared-mode lock
...
T1 has to wait while T2 release it
...
T1 still waiting
...
Copyright @ www
...
com
T1 still waiting and is said to be Starved
...
bcanotes
...
Read (A)
Write (A)
Shrinking Phase:
Lock-X (B)
Read (B)
Existing Locks can be released but no
new ones can be acquired
...
bcanotes
...
bcanotes
...
It is denoted by TS (T1)
...
bcanotes
...
bcanotes
...
Use a logical counter that is incremented after
a new timestamp has been assigned
...
bcanotes
...
R-timestamp (Q) denotes the largest TS of any
transaction that executed read (Q) successfully
...
bcanotes
...
Based on idea that conflicts are rare
...
bcanotes
...
Phases are:
Read Phase
Validation Phase
Write Phase
Copyright @ www
...
com
Validation Based Protocol Phases
Read Phase:
In
this every transaction reads the values of all
the data elements it needs from the database
and stores them in Local variables
...
Copyright @ www
...
com
Validation Based Protocol Phases…
Validation Phase:
Come after end of Read phase
...
For Read only transactions this phase consist of checking
that the data elements read are ok, no conflict is there
then it is Committed
...
For Updating transactions, it checks whether current
transaction leaves database in a consistent state, if not
then transaction is Aborted
...
bcanotes
...
If the transaction has passed the validation
phase successfully then all the changes made
by the transaction to the Local copy are made
to Final database
...
bcanotes
...
bcanotes