0% found this document useful (0 votes)
35 views60 pages

Ddbmsunit 2

The document discusses concurrency control in distributed database management systems (DBMS), emphasizing the importance of ensuring safe transaction execution while adhering to ACID properties. It covers various mechanisms such as locking techniques, two-phase locking, and deadlock detection methods, including the Chandy-Misra-Haas algorithm. Additionally, it highlights the implications of deadlocks and the use of timestamps in managing transaction execution.

Uploaded by

aaradhnavishwas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views60 pages

Ddbmsunit 2

The document discusses concurrency control in distributed database management systems (DBMS), emphasizing the importance of ensuring safe transaction execution while adhering to ACID properties. It covers various mechanisms such as locking techniques, two-phase locking, and deadlock detection methods, including the Chandy-Misra-Haas algorithm. Additionally, it highlights the implications of deadlocks and the use of timestamps in managing transaction execution.

Uploaded by

aaradhnavishwas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 60

Distributed Database

Management System
UNIT-2

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran khan U2.1
Concurrency Control
• Concurrency control is a method used to
ensure that database transactions are executed
in a safe manner (i.e., without data loss).

• Concurrency control is especially applicable to


database management system (DBMS), which
must ensure that transactions are executed
safely and that they follow the ACID rules.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.2 2
Transaction ACID rules
• A transaction = sequence of statements that
either all succeed, or all fail

Transactions have the ACID properties:


A = atomicity
(a transaction should be done or undone
completely )
C = consistency
(a transaction should transform a system
from one consistent state to another
consistent state)
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.3 3
Transaction ACID rules Cont…
I = isolation
(each transaction should happen independently
of other transactions )

D = durability
(completed transactions should remain
permanent)

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.4 4
Distributed Concurrency Control
Objectives:
All concurrency control (CC) mechanisms must
ensure
• consistency of data items is preserved.
• Each atomic action completes in finite time
• Distribution of Processing power.
• Have lowest storage overheads
• Perform in network without communication
delays.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.5 5
Locks
The most common way in which access to items is
controlled is by “locks.” Lock manager is the part of
a DBMS that records, for each item I, whether one or
more transactions are reading or writing any part of I.
If so, the manager will forbid another transaction
from gaining access to I, provided the type of access
(read or write) could cause a conflict, such as the
duplicate selling of an airline seat.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.6 6
Example of locks
Lets consider two transaction T1 and T2. Each
accesses an item A, which we assume has an
integer value, and adds one to A.

Read A; A:=A+1;Write A;
-----------------------------------------------------------
T1: Read A A:=A+1 Write A
T2: Read A A:=A+1 Write A
-----------------------------------------------------------

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.7 7
Example of locks (cont…)
• The most common solution to this problem is to
provide a lock on A.
• Before reading A, a transaction T must lock A,
which prevents another transaction from accessing
A until T is finished with A.
• Furthermore, the need for T to set a lock on A
prevents T from accessing A if some other
transaction is already using A.
• T must wait until the other transaction unlocks A,
which it should do only after finishing with A .

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.8 8
Concurrent access with transaction
Agent A Agent B
… …
begin transaction
read account 754
($314.60)
… Begin transaction
wait
update account 754
($264.60) wait

commit wait
read account 754
($264.60)

update account 754
($214.60)

commit

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.9 9
Transaction Management with SQL

Transaction support is provided by two SQL


statements: COMMIT and ROLLBACK.

A COMMIT statement is reached, in which case all changes


are permanently recorded within the database. The
COMMIT statement automatically ends the SQL
transaction.

A ROLLBACK statement is reached in which case all


changes are aborted and the database is rolled back to its
previous consistent state.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.1010
Two-Phase Locking Techniques

• Two-phase locking, (2PL) is a concurrency


control locking protocol, or mechanism, which
guarantees Serializability.
• It is also the name of the resulting class (set) of
transaction schedules.
• Using locks that block processes, 2PL may be subject
to deadlocks that result from the mutual blocking of
two transactions or more.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.1111
Two-Phase Locking Techniques
Cont…
Check these two condition before granting a lock on
transaction
1. There is no other transaction holding a lock on Q in a mode
that conflict with M.
2. There is no other transaction that is waiting for a lock on Q
and that made its lock request before Ti.

Two Phases: (a) Locking (Growing)


(b) Unlocking (Shrinking)

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.1212
Two-Phase Locking Techniques
Cont…
Locking (Growing) Phase: A transaction
applies locks (read or write) on desired data
items one at a time.
A transaction may obtain locks, but may not
release any lock.
Unlocking (Shrinking) Phase: A transaction
unlocks its locked data items one at a time.
A transaction may release locks, but may not
obtain any new locks.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.1313
Putting Locks on Transaction

Transaction View in 2 phase locking

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.1414
Types of 2PL
We Can employ one of the following 4 protocols
(based on 2PL) to ensure serializability for
DDBMSs…
Centralized 2PL: single site maintains all locking
information.
Primary Copy 2PL: For data copies, one copy
chosen as primary copy, others are slave
copies, Only need to write-lock primary copy
of data item that is to be updated. Changes can
be propagated to slaves
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.1515
Types of 2PL Cont…

Distributed 2PL:
Lock managers distributed to every site. Each lock
manager responsible for locks for data at that site.
If data is not replicated, equivalent to primary copy
2PL. Otherwise, implements a Read-One-Write-All
(ROWA) replica control protocol.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.1616
Types of 2PL Cont…
Majority Locking:

Extension of distributed 2PL.

To read/write data replicated at n sites, sends


lock request to>1/2n sites Transaction
cannot proceed until majority of locks
obtained. Overly strong in case of read locks.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.1717
Deadlock
• A deadlock is a situation wherein two or
more competing actions are waiting for the
other to finish, and thus neither ever does

• In the computing world deadlock refers to a


specific condition when two or more
processes are each waiting for another to
release a resource.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.1818
Deadlock Situation

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.1919
Necessary conditions
1. Mutual exclusion condition: a resource is either
assigned to one process or it is available

2. Hold and wait condition: processes already


holding resources may request new resources

3. No preemption condition: only a process holding


a resource may release it

4. Circular wait condition: two or more processes


form a circular chain where each process waits for
a resource that the next process in the chain holds
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.2020
Distributed Deadlock Detection

Researchers works on detecting the


occurrence of deadlocks in distributed system.
The presence of atomic transaction in some
distributed systems makes a major conceptual
difference.
• When a deadlock is detected in a conventional
system, we kill one or more processes to break
the deadlock --- one or more unhappy users.
• When deadlock is detected in a system based
on atomic transaction, it is resolved by
aborting one or more transactions.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.2121
Distributed Deadlock Detection Cont…
• But transactions have been designed to with
stand being aborted.
• When a transaction is aborted, the system is
first restored to the state it had before the
transaction began, at which point the
transaction can start again.
• With a bit of luck, it will succeed the second
time.
• Thus the difference is that the consequences
of killing off a process are much less severe
when transactions are used.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.2222
Centralized approach for Deadlock Detection

• Under this approach there is some coordinator


process which is endowed with the responsibility
of collecting the information about the local wait
for graphs constructing a global wait for graph
and to check for the existence of a dead lock.

• The draw back with the centralized approach is


given below:

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.2323
Distributed Deadlock Detection

1. The coordinator process cannot always


construct a consistent global wait for graph
based on the information collected from the
various sites at different times therefore the
probability of detection of phantom or false
Deadlock is always there.

2. Another major draw back is the existence of a


single-point of failure of coordinator process.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.2424
Distributed Deadlock Detection Cont…
The Chandy-Misra-Haas algorithm:
• Processes are allowed to request multiple
resources at once -- the growing phase of a
transaction can be speeded up.
• The consequence of this change is a process
may now wait on two or more resources at the
same time.
• When a process has to wait for some resources,
a problem message is generated and sent to the
process holding the resources.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.2525
Distributed Deadlock Detection Cont…
• The message consists of three numbers:
-> The process being blocked,
-> The process sending the message,
-> and the process receiving the message.

• When message arrived, the recipient checks to


see it it itself is waiting for any processes. If so,
the message is updated, keeping the first
number unchanged, and replaced the second
and third field by the corresponding process
number.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.2626
Distributed Deadlock Detection Cont…
• The message is then send to the process
holding the needed resources.
• If a message goes all the way around and
comes back to the original sender -- the
process that initiate the probe, a cycle
exists and the system is deadlocked.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.2727
Time stamp protocol
Time stamp
=
Assigning time to a transaction
Or
Assigning logical counter to any new
transaction .

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.2828
Time stamp protocol Cont…
Wait-Die and Wound-Wait
• Propose in the context of a distributed
system, but could be used in a centralized
system as well comes in two version
(Wait-die and Wound-wait) work as
follows:

• Every transaction is time stamped with


its start time (which must be unique)

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.2929
Time stamp protocol Cont…
• When transaction A requests a lock on
some item that is already locked by
transaction B, then
• Wait-Die: A waits if it is older than B;
otherwise, it “dies”- that is, A is rolled
back and restarted.
• Wound-Wait: A waits if it is younger
than B; otherwise, it “wounds” B – that is,
B is rolled back and restarted.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.3030
Wait-die

Wait-die
If (Ti older than Tj) then
Ti allowed to wait
Else
Abort Ti (rollback and restart later)
End if

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.3131
Wound-wait

Wound-wait
If (Ti older than Tj) then
Abort Tj (Ti wound Tj)
(rollback and restart later)
Else
Ti allowed to wait
End if

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.3232
No waiting algorithm

If transaction is unable to obtain a lock,


it is immediately aborted and then restarted
after a certain time delay without checking
whether a deadlock will actually occur or
not.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.3333
Quorum based protocol
• A quorum is the minimum number of votes that a
distributed transaction has to obtain in order to be
allowed to perform an operation in a distributed
system.
• A quorum-based technique is implemented to
enforce consistent operation in a distributed
system.
• Quorum-based voting can be used as a replica
control method, as well as a commit method to
ensure transaction atomicity in the presence of
network partitioning.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.3434
Quorum based protocol Cont…

• Each site i has associated with it a number of votes


Vi, Vi being a positive integer.
• Let V indicate the sum of the votes of all sites of the
network.
• A transaction must collect a commit quorum Vc
before committing.
• A transaction must collect a abort quorum Va
before aborting. hence the following rules must be
obeyed in the implementation of the commit
protocol:

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.3535
Quorum based protocol Cont…
• Va + Vc > V, where 0 <= Va, Vc <= V.
• Before a transaction commits, it must obtain a
commit quorum Vc.
• Before a transaction aborts, it must obtain an abort
quorum Va.

The first rule ensures that a transaction cannot be


committed and aborted at the same time. The next
two rules indicate the votes that a transaction has
to obtain before it can terminate one way or the
other.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.3636
Quorum based protocol Cont…
• In replicated databases, a data object has
copies present at several sites. To ensure
serializability, no two transactions should be
allowed to read or write a data item
concurrently. In case of replicated databases, a
quorum-based replica control protocol can be
used to ensure that no two copies of a data
item are read or written by two transactions
concurrently.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.3737
Quorum based protocol Cont…

• The quorum-based voting for replica control is


due to [Gifford, 1979]. Each copy of a replicated
data item is assigned a vote.
• Each operation then has to obtain a read
quorum (Vr) or a write quorum (Vw) to read or
write a data item, respectively. If a given data
item has a total of V votes, the quorums have to
obey the following rules:

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.3838
Quorum based protocol Cont…
• Vr + Vw > V
• Vw > V/2

The first rule ensures that a data item is not read


and written by two transactions concurrently.

The second rule ensures that two write operations


from two transactions cannot occur concurrently on
the same data item. The two rules ensure that one-
copy serializability is maintained.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.3939
Commit Protocols

There are two kinds of commit protocols :

• Two-Phase Commit protocol - a blocking


protocol

• Three-Phase Commit protocol - a non-


blocking protocol

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.4040
2 phase commit
Commit-request phase
1. The coordinator sends a query to commit
message to all cohorts.
2. The cohorts execute the transaction up to the
point where they will be asked to commit.
3. Each cohort replies with an agreement
message if the transaction succeeded, or an
abort message if the transaction failed.
4. The coordinator waits until it has a message
from each cohort.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.4141
Commit phase
• If the coordinator received an agreement
message from all cohorts during the commit-
request phase:

• The coordinator writes a commit record into


its log.
• The coordinator sends a commit message to all
the cohorts.

• Each cohort completes the operation, and


releases all the locks and resources held
during the transaction.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.4242
Commit phase Cont…
• Each cohort sends an acknowledgement to
the coordinator.
• The coordinator completes the transaction
when acknowledgements have been
received.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.4343
Commit phase Cont…
• If any cohort sent an abort message during the
commit-request phase:
• The coordinator sends a rollback message to
all the cohorts.
• Each cohort undo the transaction using the
undo log, and releases the resources and
locks held during the transaction.
• Each cohort sends an acknowledgement to the
coordinator.
• The coordinator completes the transaction
when acknowledgements have been received.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.4444
Commit phase Cont…
Disadvantages
• The greatest disadvantage of the two-phase
commit protocol is the fact that it is a blocking
protocol. A node will block while it is waiting
for a message.

Note: A commitment protocol is called


Blocking if the occurrence of some kinds of
failures forces some of the participating sites
to wait until the failure is repaired before
terminating the transaction.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.4545
Non-blocking commitment protocol

Three-phase commit protocol


In databases the three-phase commit protocol
(3PC) is a distributed algorithm which lets all
nodes in a distributed system agree to commit a
transaction.

Unlike the two-phase commit protocol (2PC)


however, 3PC is non-blocking. Specifically, 3PC
places an upper bound on the amount of time
required before a transaction either commits or
aborts.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.4646
Non-blocking commitment protocol Cont…

This property ensures that if a given


transaction is attempting to commit via 3PC
and holds some resource locks, it will release
the locks after the timeout.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.4747
Coordinator
• The coordinator receives a transaction request.
If there is a failure at this point, the coordinator
aborts the transaction (i.e. upon recovery, it will
consider the transaction aborted). Otherwise,
the coordinator sends a start transaction
message to the cohorts and moves to the
waiting state.

• If there is a failure, timeout, or if the coordinator


receives a will not start transaction message
in the waiting state, the coordinator aborts the
transaction and sends an abort message to all
cohorts. Otherwise the coordinator will receive
will start
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.4848
Coordinator Cont…
• start transaction messages from all cohorts
within the time window, so it sends commit
messages to all cohorts and moves to the
prepared state.

• If the coordinator fails in the prepared state, it


will move to the commit state. However if the
coordinator times out while waiting for an
acknowledgement from a cohort, it will abort the
transaction.
• In the case where all acknowledgements are
received, the coordinator moves to the commit
state as well.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.4949
Cohort
• The cohort receives a start transaction message from
the coordinator. If the cohort agrees it sends a will
start transaction message to the coordinator and
moves to the prepared state. Otherwise it sends a will
not start transaction message and aborts. If there is a
failure, it moves to the abort state.
• In the prepared state, if the cohort receives an abort
message from the coordinator, fails, or times out
waiting for a commit, it aborts. If the cohort receives a
commit message, it sends an ack message back and
commits.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.5050
Partitioned Networks

Partitioned Networks

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.5151
Partitioned Networks Cont…
With modern communication networks, which are
capable of routing messages, the following
assumption about the network is also reasonable:
If site X cannot communicate with site Y but can
communicate with site Z, then site Z cannot
communicate with site Y either.

In this case, when two operating sites X and Y


cannot communicate, this means that no
communication path is available between them, and
the network is partitioned into two or more
completely disconnected sub networks, one
including X, and the other one including Y.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.5252
Partitioned Networks Cont…

All the operational sites which belong to the


same sub network can communicate with
each other however, they cannot
communicate with the sites belong to a
different sub network until the partition is
repaired.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.5353
Check Points & Cold Starts/Restarts

Check points and Cold starts/restarts

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.5454
Check Points
Check Point- A previous consistent state is
marked by a check point. Check points are
very useful during the recovery procedure.
Performing a check point requires the
following operations:
• Writing to stable storage all log records and
all database updates which are still volatile
storage.
• Writing to the stable storage a check point
record.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.5555
Check Points Cont…

Check point is achieved in three steps:

1. write a begin checkpoint record into log.


2. Collect the checkpoint data into the log.
3. write a end checkpoint record into log.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.5656
Cold starts/restarts
• Cold restarts should be extremely rare in a data
base system, this is required if the log information
is lost at a site of the network.

• In this case, the affected site is not capable of


reconstructing its most recent state, thus a
previous state is reconstructed, and

• The effect of some local sub transaction is lost,


the whole distributed database must be reset to a
globally consistent previous state.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.5757
Short Questions
• What are checkpoints. How it is differ from save
points.
• What is 2 phase locking technique?
• What is concurrency control in DDBMS?
• Explain quorum based protocol?
• What is distributed deadlock. How it occur in a
DDBMS.
• How locks can be applied in transactions.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.5858
Long Questions
• What is the difference between 2 phase and 3
phase locking technique.

• What is check point explain in detail and where we


require cold restart.

• Why deadlock arise in DDBMS and how they can


be recover ?

• Explain the time based protocol in detail and write


some advantages with example.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.5959
References
1. S. Ceri, G. Pelagatti, “Distributed Database: Principles
and Systems”, McGraw Hill, New York, 1985.
2. M. Tamer Ozsu, Patrick Valduriez, “Principles of
Distributed Databases System”, Pearson, 2nd Ed.,
2009.
3. Mario Piattini, “Advanced Database Technology and
Design”, Artech House, UK, 2000.
4. Shivendra Goel, Divya Goel, “ Distributed Database
Management System”, Sun India Publications, 2009.
5. Chhanda Ray, “Distributed Database System”,
Pearson, 2009.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,By Imran Khan
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 U2.6060

You might also like