Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

T w o - P h a s e Deadlock Detection Algorithm in Distributed D a t a b a s e s

S e i i c h i Kawazu

Susumu Minami

Kenji Itoh

Katsumi T e r a n a k a

Data P r o c e s s i n g Application S e c t i o n , Yokosuka E l e c t r i c a l Communication L a b o r a t o r y , NTT 1-2356, TAKE, YOKOSUKA-SHI, JAPAN Abstract T h e r e a r e two deadlock detection methods in a distributed d a t a b a s e . One is c e n t r a l i z e d , and the o t h e r is distributed. In t h i s p a p e r a distributed method is d i s c u s s e d . Sub-Wait-Graphs, which e x p r e s s t h e state of execution of t r a n s a c t i o n s in individual sites, a r e introduced, and a sufficient condition f o r a global deadlock not t o o c c u r is given, b a s e d on the SubWait-Graph. T h i s sufficient condition makes it poss i b l e f o r a deadlock detection t o be s e p a r a t e d into two p h a s e s , local deadlock detection and global deadlock detection. Also, an efficient deadlock detection algorithm, which r e q u i r e s t o be built and maintain only Sub-Wait-Graphs, is p r o p o s e d , by making u s e of t h i s p r o p e r t y . T h e c h a r a c t e r i s t i c s and effects of t h i s algorithm are d i s c u s s e d . detection, s i n c e the number of a global deadlock detection t i m e s is d e c r e a s e d compared with t h e i r algorithm. T h e plan of t h i s p a p e r is as follows. In Section 2 we give the terminologies u s e d throughout t h i s p a p e r In Section 3 and t h e definition of Sub-Wait-Graphs. we show a sufficient condition f o r a global deadlock not t o o c c u r and p r e s e n t o u r algorithm, LOCAL and GLOBAL, in d e t a i l . Finally, w e conclude with a discussion of the c h a r a c t e r i s t i c s and effects of o u r algorithm in Section 4. 2. 2.1 F o r m a l Model

D a t a b a s e and T r a n s a c t i o n

1 . Introduction
T h e r e are two deadlock detection methods in a distributed d a t a b a s e * One is c e n t r a l i z e d , and the o t h e r is d i s t r i b u t e d . However most deadlock detection algorithms, which have been p r o p o s e d until now, are centralized methods (i.e. [ Z ] ,[31 ) Recently, a distributed method h a s been p r e s e n t e d by Menasce and Muntz [4] In t h i s p a p e r we will d i s c u s s a distributed method. Sub-Wait-Graphs, which e x p r e s s t h e s t a t e of execution of t r a n s a c t i o n s in individual sites, are introduced, and a sufficient condition f o r a global deadlock+ not t o o c c u r is given. This sufficient condition makes it possible f o r a deadlock detection t o be s e p a r a t e d into two p h a s e s , a local deadlock+ detection and a global deadlock detection. O u r deadlock detection algorithm, named twop h a s e deadlock detection algorihtm, makes u s e of t h i s p r o p e r t y . T h i s algorithm contains two subalgorithms, LOCAL, and GLOBAL, and r e q u i r e s t o Algorithm built and maintain only Sub-Wait-Graphs LOCAL d e t e c t s a local deadlock and determines w h e t h e r o r not a global deadlock detection p r o c e s s is needed, by making u s e of the above sufficient condition. Algorithm GLOBAL d e t e c t s a global deadlock, when algorithm LOCAL judges that a global deadlock detection p r o c e s s is needed. As a r e s u l t , o u r algorithm is m o r e efficient than Menasce s and Muntz s algorithm in r e s p e c t t o t h e number of communication times needed by a deadlock

We a s s u m e that a d a t a b a s e , DB, is partitioned into a set of s u b d a t a b a s e s DBi' s, i = 1 , 2 , n, which satisfy the following conditions,

. ..

n (1)

U
i=l

DBi=DB,

(2) DBi A DBj

=cp

fori

+j,

w h e r e n is t h e number of sites in t h e network, q5 denotes a n empty set and DBi is t h e s u b d a t a b a s e which r e s i d e s in site i. T h e basic unit of u s e r computation is the t r a n s a c t i o n . A transaction is a sequency of operations which c a n b e e i t h e r READ, WRITE, LOCK o r UNLOCK operation. A LOCK operation is used t o hold a r e s o u r c e and a UNLOCK operation is used to release a s e s o u r c e which h a s held. Generally, t h e r e are two t y p e s in t h e u s a g e mode of a LOCK operation. One is the exclusive mode. T h e other is the s h a r e mode. For a r e s o u r c e locked with the exclusive mode, the t r a n s a c t i o n , which invokes the LOCK operation, c a n a c c e s s t h e r e s o u r c e exclusively and no o t h e r t r a n s a c t i o n c a n a c c e s s t h e r e s o u r c e . F o r a r e s o u r e locked with the s h a r e mode, the r e s o u r c e c a n be a c c e s s e d by the transactions which have invoked a LOCK operation with the s h a r e mode. Next, we define t h e terminologies which r e p r e s e n t the attribute and the state of t r a n s a c t i o n s Definition 1 At some point of the execution of a t r a n s a c t i o n , t h e a t t r i b u t e of t h e t r a n s a c t i o n at t h i s point is local, if t h e resoures which the t r a n s a c t i o n h a s held, o r attempts to hold, r e s i d e in one site, O t h e r w i s e , the a t t r i b u t e of t h e t r a n s a c t i o n at t h i s point is global.

Definitions of local and global d e a d l o c k s are given in Section 2.3.

CH1406-8/79/0000-0360$00.75 @ 1979 IEEE

360

Definition 2 T h e state of a transaction is blocked i f its execution can not proceed b e c a u s e a needed r e s o u r c e is being held by a n o t h e r t r a n s a c t i o n . Otherwise, the state of a t r a n s a c t i o n is active. F r o m t h e above definitions, both t r a n s a c t i o n a t t r i b u t e and state may change e v e r y time t h a t a L O C K or a UNLOCK operation is invoked 2 . 2 Wait-Graph

=1

'*2

A d i r e c t e d graph G = ( V , E) with v e r t e x s e t V and edge set E , called Wait-Graph, is introduced in t h i s section in p r e p a r a t i o n f o r the subsequent d i s c u s s i o n . Wait-Graph is used t o r e p r e s e n t the s t a t e of execution of all t r a n s a c t i o n s in the system.
Definition 3 Wait-Graph is a d i r e c t e d graph G = ( V , E), which satisfies the following p r o p e r t i e s . Property 1 T h e v e r t e x e s of G are a s s o c i a t e d with t r a n s a c t i o n s and are labeled by t r a n s a c t i o n name. Property 2 T h e d i r e c t e d e d g e s of G are labeled by t h e t r i p l e (transaction name, t r a n s a c t i o n name, r e s o u r c e name). A d i r e c t e d edge (Ti, T j , R) e x i s t s in E i f and only i f t h e t r a n s a c t i o n T i is blocked and waiting f o r the t r a n s a c t i o n T . t o release the r e s o u r c e J R needed by the t r a n s a c t i o n Ti. Property 3 If t h e r e are no less than two d i r e c t e d e d g e s from some v e r t e x , then t h e r e s o u r c e name a s s o c i a t e d with e a c h edge is t h e same for each. In the above definition, P r o p e r t y 3 means that t h e blocked transaction can not proceed until the r e s o u r c e which it attempts t o hold h a s been r e l e a s e d by a n o t h e r t r a n s a c t i o n . In o t h e r w o r d s , t h e r e a r e m ( 22) d i r e c t ed e d g e s from some v e r t e x T i i f and only i f t h e t r a n s a c t i o n T . attempts t o hold t h e r e s o u r e with t h e exclusive mode which h a s been held by m t r a n s a c t i o n s with t h e s h a r e mode. F r o m Definition 3 , t h e following proposition is held. Proposition 1 T h e e x i s t e c c e of a cycle+ in Wait-Graph is a n e c e s s a r y and sifficient condition f o r a deadlock t o occur. Wait-Graph h a s to be updated e v e r y time t h a t a t r a n s a c t i o n changes state, e i t h e r from active t o blocked or v i c e v e r s a . F i g u r e 1 shows a n example of Wait-Graph G =

2,

... n , by partitioning G = (V , E) with the criteCriterion 1 A d i r e c t e d edge ( T k , TI

L e t u s c o n s t r u c t subgraphs G. = (Vi, Ei), i = 1 ,

r i o n s given below.

, R ) e x i s t s in Ei i f

and only i f the r e s o u r c e R r e s i d e s in site i. Criterion 2 A v e r t e x T k e x i s t s in V . i f and only i f t h e t r a n s a c t i o n T k h a s been held o r attempts t o hold

a r e s o u r c e which r e s i d e s in site i. F r o m C r i t e r i o n 1 , it can be e a s i l y s e e n that


(1)

6
i=l

Ei=E,

(2) E i A E . = @ for i f j, J and a subgraph Gi = (Vi, Ei) r e p r e s e n t s the s t a t e of execution of all t r a n s a c t i o n s in site i . T h e r e f o r e , we call t h i s subgraph Sub-Wait-Graph. Note that a SubWait-Graph satisfies P r o p e r t i e s 1 3 by substituting "G." f o r "Gr' and "site i" f o r "system". O u r algorithm

In r e q u i r e s only information of Sub-Wait-Graphs o r d e r t o detect a deadlock efficiently, we add the attribute of t r a n s a c t i o n s as information of the G. bes i d e s t h e t r a n s a c t i o n name+. Sub-Wait-Graph h a s to b e updated e v e r y time that a t r a n s a c t i o n changes state, e i t h e r from a c t i v e t o blocked or v i c e v e r s a , or that t h e a t t r i b u t e of a t r a n s a c t i o n is changed, e i t h e r from l o c a l t o global or vice v e r s a . Note t h a t , in t h e latter case, SubWait-Graph d o e s not change topologically.

(v, E).
+
A path in a d i r e c t e d graph is a sequency of e d g e s (TPof t h e form ( T , , T 2 , -), ( T 2 , T3, -)

TI, -)

.. . . .

,,

A cycle is a path which begins a n d e n d s

F o r t h e simplicity of notations, t h e v e r t e x e s of Gi are denoted by transaction-name as well as t h e

at the same v e r t e x .

v e r t e x e s of G .

361

F i g u r e 2 shows a n example of Sub-Wait-Graph Gi = (Vi, Ei) f o r a network with two s i t e s , w h e r e resources R1, R

3 . 1 Algorithm LOCAL
W e will give some r e l a t i o n s h i p between SubWait-Graphs and a global deadlock b e f o r e algorithm LOCAL is d e s c r i b e d in detail. L e t u s consider the c a s e where the transaction Ti is blocked. Then p directed edges ( T I 0 T 1 R), ( T l o , T2, R), ( T i o , Tp, R) are added t o

4 5 noted t h a t t h e v e r t e x T4 e x i s t s i n both V 2.3 Deadlock

reside i n site 1 and r e s o u r c e s 3 and R reside i n site 2 . In F i g u r e 2 , it should be


2

and R

and V 2 .

. . . ..

T h e r e are two deadlock c a t e g o r i e s , l o c a l deadlock and global deadlock. Definition 4 A deadlock is a l o c a l deadlock i f it involves only t r a n s a c t i o n s a t one site. Otherwise a deadlock is a global deadlock. F r o m Definition 4 , t h e following proposition is held. Proposition 2 T h e e x i s t e n c e of a c y c l e i n Sub-Wait-Graph

T2, T have A held t h e r e s o u r c e R with t h e s h a r e mode. Now G = A A B E 3 (V , E ) and G B = (V , E ) denote Wait-Graphs, after o r b e f o r e adding t h e d i r e c t e d e d g e s , r e s p e c -

G , where the transactions T

.....

tively. Between C A and GB, t h e following r e l a t i o n s h i p is held.


(1)

u~{ ( T ~ ~~ ,R,I , T
T ~ }

..... ,

( T I o ? Tp RI}

G.

(2)

is a n e c e s s a r y and sufficient condition f o r a local deadlock to o c c u r in site i .

Site 2

Next p a r t i t i o n CA and GB into a s e t of s u b g r a p h s with t h e c r i t e r i o n s d e s c r i b e d in S e c t i o n 2 . Then A t h e s e s u b g r a p h s are denoted by G.A = (ViA, Ei ) and
G.

vA = vB U { v A = vB

i f a LOCK operation f o r t h e r e s o u r c e R is t h e first LOCK operation of t h e t r a n s a c t i o n TI o .

otherwise.

= (V.

, Ei B),

i = 1 , 2,

... n ,

corresponding to

and G B , r e s p e c t i v e l y . A Gi and C.B

T h e r e l a t i o n s h i p between

vkA= vkB U

~f a LOCK operation i ~
f o r t h e r e s o u r c e R is t h e first LOCK operation of t h e t r a n s a c t i o n TI for site k,

Figure 2.

Sub-Wait-Graphs G1 = (V,

, El)

VkA = Vk B

otherwise,

a n d G2 = (V2, E*).

3.

Deadlock Detection Algorithm

a r e h e l d , w h e r e t h e r e s o u r c e R r e s i d e s in s i t e k . A Also we give t h e t r i v i a l r e l a t i o n s h i p between G A B (GB) and G1 (G1 ).

O u r deadlock detection algorithm proposed in t h i s p a p e r c o n s i s t s of two sub-algorithms, LOCAL and GLOBAL. Algorithm LOCAL d e t e c t s a l o c a l deadlock and d e t e r m i n e s w h e t h e r o r not a global deadlock detection p r o c e s s is needed. Algorithm LOCAL r e q u i r e s only t h e information of a Sub-WaitG r a p h , Algorithm GLOBAL d e t e c t s a global deadlock when algorithm LOCAL judges t h a t a global deadlock detection p r o c e s s is needed.

Proposition 3 If a n y c y c l e d o e s not e x i s t in CA (CB), then no A c y c l e e x i s t s i n e a c h G1 (GIB), and i f some c y c l e

B A e x i s t s in some GIA (G1 ), then a c y c l e e x i s t s in G

GB).
When a c y c l e e x i s t s in C k A , a local deadlock

ccurs in s i t e k by P r o p o s i t i o n 2. T h e r e f o r e i n t h e

362

subsequent d i s c u s s i o n we assume that GkA d o e s not involve any cycle. Then a path, ( T l o , T Q , R ) ,
( T j rn-l
7

Proposition 4 A sufficient condition f o r any path i n CA which begins a t t h e v e r t e x T I not t o form a cycle is t o s a t i s f y at least one of t h e following two conditions. (A) N o directed edge from a n y v e r t e x i n V (TP ) m A e x i s t s in E (B) N o d i r e c t e d e d g e t o a n y v e r t e x i n V ( T i ) e x i s t s A A i n E -Ek

( T i 1 , T12r RI)

. * * * .

T l m l Rm-l)t e x i s t s

i n C k A , which s a t i s f i e s

(2) T f ,

..... T i ,

cVkAandTli+Tp for i

+ j,

( 3 ) GkA involves no d i r e c t e d edge from t h e v e r t e x


Tim.
L e t u s define two sets of t h e v e r t e x e s of Gk A

F i g u r e 3 shows a n example of a global deadlock (thick l i n e ) , i n s a t i s f y i n g n e i t h e r of t h e two conditions i n P r o p o s i t i o n 4. Condition A i n P r o p o s i t i o n 4 shows that directed e d g e 1 i n F i g . 3 d o e s not e x i s t . Condition B in P r o p o s i t i o n 4 shows that d i r e c t e d edge 2 i n F i g . 3 d o e s not e x i s t . P r o p o s i t i o n 4 is r e s t a t e d below, i t h e view n point of t h e state of t r a n s a c t i o n s . Proposition 4' When t r a n s a c t i o n T p is blocked by t r a n s a c t i o n s

v (Tim) and V
V (TI

r n

(Tto) ) : t h e set of t h e v e r t e x e s of GkA c o r r e s ponding to t h e endpoints of t h e p a t h s which satisfy the above conditions,

TI

. . . T P'

a sufficient condition f o r a deadlock not

V (TI o ) : t h e set of the v e r t e x e s of GkA f r o m which t o t h e v e r t e x T i e x i s t s in G k ' A s a s p e c i a l case, t h e v e r t e x T f o given in F i g u r e 3 . some path

t o o c c u r in system is t o satisfy at least one of the following two conditions. ( A ' ) All t r a n s a c t i o n s c o r r e s p o n d i n g t o v e r t e x s i n V ( T a m ) are a c t i v e .

V ( T i o).

An example of t h e s e t s V (Ta ) and V (Ta ) is r n

( B ' ) No t r a n s a c t i o n c o r r e s p o n d i n g t o a n y v e r t e x i n V ( T i o ) makes o t h e r t r a n s a c t i o n s blocked, exc e p t a t site k .


Corollary 1 When t r a n s a c t i o n T p
is blocked by t r a n s a c t i o n s

TI
Site i

t o o c c u r in t h e system is t o s a t i s f y a t least one of t h e following two conditions. (A' I ) N o t r a n s a c t i o n c o r r e s p o n d i n g t o a n y v e r t e x i n V (TI,) h a s global a t t r i b u t e .

... TP'

a sufficient condition f o r a deadlock not

I z D i r e c t e d edge 1
I
I

(B'

I)

No t r a n s a c t i o n c o r r e s p o n d i n g t o a n y v e r t e x i n V (Ta o) h a s global a t t r i b u t e .

:
I I

It is obvious that t h e sufficient condition of C o r o l l a r y 1 is more l o o s e than t h a t of Proposition 4 . Algorithm LOCAL first detects a local deadlock. T h i s is, it c h e c k s t h e e x i s t e n c e of a c y c l e in SubWait-Graph CkA. When no l o c a l deadlock o c c u r s , algorithm LOCAL d e t e r m i n e s whether o r not a global deadlock detection is needed, by making u s e of t h e sufficient condition of C o r o l l a r y 1 .+ L e t u s d e s c r i b e algorithm LOCAL in detail, i n t h e case w h e r e t h e t r a n s a c t i o n T i is blocked a t site

L-Directed
1.

edge 2

k.
Algorithm LOCAL STEP 1 A Check f o r t h e e x i s t e n c e of a c y c l e i n Gk

If a c y c l e e x i s t s , then go t o S T E P 8, else go to S T E P 2 .

+
F i g u r e 3 . Example of a global deadlock Then we give a sufficient condition f o r a global deadlock not t o o c c u r .

Though t h e r e is a n algorithm using t h e sufficient condition of proposition 4', h e r e we adopt a n algorithm using t h e sufficient condition of Coro l l a r y 1 . T h e r e a s o n is t h a i t h e numbers of update t i m e s f o r Sub-Wait-Graph are g e n e r a l l y fewer.

363

STEP 2 STEP 3

If t h e t r a n s a c t i o n T i

has local attribute

(1)

iyl n

E iA = E A , a n d

STEP 4

STEP 5

then go t o S T E P 4, else go t o S T E P 3 . If all t r a n s a c t i o n s c o r r e s p o n d i n g t o v e r t e x e s in V (TI ) have l o c a l a t t r i b u t e , m then go t o STEP 6 , else go t o STEP 7. If all t r a n s a c t i o n s c o r r e s p o n d i n g t o v e r t e x e s in V (TI ) have l o c a l a t t r i b u t e , m then go t o S T E P 6 , else go to S T E P 5 . If all t r a n s a c t i o n s c o r r e s p o n d i n g t o v e r t e x e s in V (TI o ) have l o c a l a t t r i b u t e ,

(2) Ei A A E . A = @ f o r i * j .

J
If new c y c l e s , which are not c l o s e d a t one site,

a r e g e n e r a t e d i n C A , then t h e s e c y c l e s a r e formed by p a t h s beginning at t h e v e r t e x T f

New c y c l e s g e n e r a t e d , when t r a n s a c t i o n TI

is

then go t o S T E P 6 , else go t o S T E P 7. Stop. Inform that it is n e c e s s a r y t o execute algorithm GLOBAL, then S t o p . S T E P 8 Stop. F r o m P r o p o s i t i o n 2 and C o r o l l a r y 1 of P r o p o s i tion 4', i t is s e e n t h a t a deadlock d o e s not o c c u r when stopping a t S T E P 6 . When stopping a t S T E P 8 , a l o c a l deadlock o c c u r s .

STEP 6 STEP 7

blocked, have been remaining i Wait-Graph CA forn e v e r as long as they a r e d e l e t e d . F r o m t h e d i s c u s s i o n a b o v e , it c a n be e a s i l y shown t h a t t h e r e a r e t h e s e c y c l e s in G*. A s a r e s u l t , proposition 5 is followed. Proposition 5 L e t G* be t h e Pseudo-Wait-Graph. If all c y c l e that are formed by p a t h s beginning at t h e v e r t e x T p i n G* c a n be d e t e c t e d , all c y c l e s i n CA, which are g e n e r a t e d at t h e time t h e t r a n s a c t i o n T i is blocked c a n be d e t e c t e d . F o r s t a t i n g algorithm GLOBAL, we give some notations. T h e set p ( i l ) is defined ; p (il)
=

3 .2 Algorithm GLOBAL
A global deadlock is a deadlock which involves t r a n s a c t i o n s i n more than one site. T h e r e f o r e all Sub-Wait-Graphs must be g a t h e r e d in o r d e r t o d e t e c t a global deadlock. In t h i s s e c t i o n , we will d e s c r i b e a global deadlock detection algorithm GLOBAL which d o e s not need t o l o c k a n y Sub-Wait-Graph when g a t h e r i n g it. C o n s i d e r t h e case w h e r e t r a n s a c t i o n T g is blocked and a global deadlock detection p r o c e s s is needed. F i r s t , we will define Pseudo-Wait-Graph G* i n p r e p a r a t i o n f o r t h e subsequent d i s c u s s i o n . Definition 5 Pseudo-Wait-Graph G* is a g r a p h which is composed of all of Sub-Wait-Graphs g a t h e r e d at a n y time a f t e r one t r a n s a c t i o n h a s been blocked. Note t h a t it is not n e c e s s a r y t o lock when SubWait-Graph is g a t h e r e d . In g e n e r a l , all Sub-WaltG r a p h s cannot be gathered at t h e s a m e time. A g r a p h which is composed of g a t h e r e d Sub-Wait-Graphs may b e different from Wait-Graph G at a n y point. T h i s is t h e r e a s o n t h a t we call t h i s g r a p h Pseudo-Wait-Graph. F i g u r e 4 shows a n example of a Pseudo-WaitG r a p h G* f o r a system with t w o sites. In F i g u r e 4, t is t h e time when a Sub-Wait-Graph in site 1 is 1 g a t h e r e d , and t2 is t h e time when a Sub-Wait-Graph i n site 2 is g a t h e r e d . G* is composed of a Sub-WaitG r a p h i n site 1 , which is g a t h e r e d a t t l and a SubWait-Graph in site 2 , which is g a t h e r e d at t 2 . Note t h a t G* is different from e a c h Wait-Graph a t t l and t2'

{ p l , p2,

. . . . . , pJ. , . . . . . , P q )

t h e s e t of all p a t h s i n G*, which begin at t h e v e r t e x T i o , where

E a c h Sub-Wait-Graph, which is a n element of t h e Pseudo-Wait-Graph, c a n be g a t h e r e d at a n y time after a d i r e c t e d edge (TI o , T 5 , , R I ) is added. S o , . algorithm GLOBAL g a t h e r s only Sub-Wait-Graphs i n which t h e e d g e s involved i n c y c l e s e x i s t at t h e time t h a t Sub-Wait-Graphs a r e n e c e s s a r y . T h e n , algorithm GLOBAL t h a t d e t e r m i n e s whether o r not path p . f o r m s a c y c l e , h a s t h r e e t a b l e s . T a b l e s , T-SITE a n d T - S T A T U S , are u s e d s o t h a t algorithm GLOBAL may g a t h e r Sub-WaitG r a p h s , which are n e c e s s a r y t o check a c y c l e involving a d i r e c t e d e d g e (Ta o, Tjl , R I ) . T a b l e STACK is u s e d s o t h a t algorithm GLOBAL may determine whether or not a path p . f o r m s a c y c l e . J T h e s e t h r e e t a b l e s are d e s c r i b e d below i n d e t a i l . T-SITE T - S I T E is u s e d s o t h a t algorithm GLOBAL may know t h e name of site, w h e r e a t r a n s a c t i o n c o r r e s p o n d ing to the vertex in a path p . is initiated. W h e n a J t r a n s a c t i o n invokes a LOCK operation in one site, T S I T E i n its site is s t o r e d with t r a n s a c t i o n name and site name f o r t h i s t r a n s a c t i o n . T-STATUS T-STATUS is u s e d so t h a t algorithm GLOBAL may know all n a m e s of sites, w h e r e t r a n s a c t i o n s e c u r e s database resources. This table exists in a site w h e r e t r a n s a c t i o n is i n i t i a t e d , and is s t o r e d with t r a n s a c t i o n name and all site n a m e s w h e r e its t r a n s a c -

W e will d i s c u s s t h e r e l a t i o n s h i p between G* and


G

from a viewpoint of t h e e x i s t e n c e of a c y c l e .

As

d e s c r i b e d i n S e c t i o n 2 . 2 , Sub-Wait-Graph GiA rep r e s e n t s t h e state of execution of all t r a n s a c t i o n s i n A site i at t h e time t r a n s a c t i o n T p is blocked. G and Gi

satisfy

364

(a-1) Sub-Wait-Graph

in site 1

at t 1

(b-1)

Sub-Wait-Graph in site 1 at t2
m

Tj3 J 2 0

(a-2)

Sub-Wait-Graph in site 2 at tl

(b-2)

Sub-Wait-Graph in site 2 at t2

(a-3) Wait-Graph at t,

(b-3) Wait-Graph at t2

T.
J4\

pTjb
T

(c)

Pseudo-Wait-Graph G* (G* is composed of a Sub-Wait-Graph i n site S1, which is gathered at tl , and a Sub-Wait-Graph in

site S 2 , which is gathered at


Figure 4 .

tz)

Pseudo-Wait-Graph G* for a system with two sites

365

tion r e q u i r e s r e s o u r c e s . STACK S T A C K is c r e a t e d i n a site w h e r e a global deadlock detection is executed. STACK is s t o r e d with v e r t e x names a l r e a d y t r a c e d in a path p . .

Algorithm GLOBAL STEP 1 (Initialization) STACK--(T~ o) G*-{Gk STEP 2 A

,
0

and s , t - I ,

If Tst d o e s not e x i s t i n S T A C K , then go

Theorem 1 O u r deadlock d e t e c t i o n algorithm, LOCAL a n d GLOBAL d e t e c t s all p o s s i b l e d e a d l o c k s i n t h e s y s t e m . Proof : Whenever a t r a n s a c t i o n is blocked i n t h e s y s t e m , algorithm LOCAL is u s e d . F r o m S T E P 1 of algorithm LOCAL and P r o p o s i t i o n 6 , i f a local deadlock o c c u r r e d , algorithm LOCAL could d e t e c t t h i s local deadlock. If a global deadlock o c c u r r e d , algorithm GLOBAL should be a l w a y s e x e c u t e d . F r o m P r o p o s i t i o n 5 , algorithm GLOBAL could d e t e c t all global deadlocks which o c c u r when t h i s t r a n s a c t i o n is blocked. T h i s theorem is p r o v e d .

STEP 3

STEP 3 . If T s = T p then go t o S T E I t 0 1 2 , else go t o S T E P 9 . If a v e r t e x TSt is t h e endpoint of a path p


i n G*, then go t o STEP 4 , else go to S T E P

4.

Conclusion

8.
STEP 4
Get t h e site name i from T - S I T E w h e r e a t r a n s a c t i o n Tst initiated. If i = k , then go to S T E P 6, elsego to STEP 5. Transmit t h e s i t e names i n T - S T A T U S , w h e r e r e s o u r c e s held by a t r a n s a c t i o n Ts

STEP 5

STEP 6

t r e s i d e s , from s i t e i t o site k. Go t o S T E P 6. Add all Sub-Wait-Graphs t o G* which a r e c o r r e s p o n d i n g t o t h e sites, w h e r e r e s o u r c e s held by a t r a n s a c t i o n Tst r e s i d e s , a n d d o e s not e x i s t i n G*. Go t o S T E P 7. If a v e r t e x Tst is t h e endpoint of a path p i n G* then go t o S T E P 9 , else go t o S T E P

STEP 7

8.
STEP 8 STEP 9 S t o r e Tst i n S T A C K , t

-+
t

1 and go t o

S T E P 2. If t h e r e is a path which is not examined, then go t o STEP I O , else go t o STEP 11 STEP 1 0 s c + 1 , t-1 and go t o S T E P 2 . S T E P 11 Stop. S T E P 12 S t o p . F r o m P r o p o s i t i o n 1 and P r o p o s i t i o n 5 , it is s e e n t h a t a global deadlock o c c u r s when stopping a t S T E P 1 2 a n d a global deadlock d o e s not o c c u r when stopping at S T E P 1 1 . If a global deadlock o c c u r s , t h e t r a n s a c t i o n c o r r e s p o n d i n g to v e r t e x e s i n V (TI o ) o r V (Tam)

d o e s not s a t i s f y a sufficient conditions of C o r o l l a r y 1 In t h i s c a s e , algorithm GLOBAL is a l w a y s executed. A s a r e s u l t , we give t h e following proposition.

T h i s p a p e r p r o p o s e s a n efficient deadlock d e t e c tion algorithm in a d i s t r i b u t e d d a t a b a s e . A d i s t r i b u t e d d a t a b a s e system b a s e d on t h i s algorithm h a s t h e following characteristics. (i) It is only n e c e s s a r y f o r e a c h s i t e t o build and maintain a Sub-Wait-Graph which r e l a t e s t o d a t a b a s e r e s o u r c e r e s i d i n g in t h e s i t e i t s e l f . A l s o , algorithm GLOBAL g a t h e r s only SubWait-Graphs, i n which t h e e d g e s involved in t h e cycle exist. (ii) Algorithm GLOBAL is executed only a t t h e time t h a t t r a n s a c t i o n s in l o c a l s i t e d o not s a t i s f y a sufficient condition f o r a global deadlock not t o o c c u r . At t h i s r e s u l t , algorithm GLOBAL is not always e x e c u t e d , whenever a t r a n s a c t i o n is blocked and waiting. (iii) Algorithm GLOBAL d o e s not need t o lock a n y Sub-Wait-Graph while algorithm GLOBAL is executed. At t h i s r e s u l t , c o n c u r r e n t global deadlock detection is possible in t h e n e t w o r k , F a c t o r s (i)and (ii)above r e d u c e t h e number of communication t i m e s . At t h i s r e s u l t , t h e d i s t r i b u t e d method p r o p o s e d (algorithm LOCAL & algorithm GLOBAL) d r a s t i c a l l y r e d u c e communication c o s t compared with t h e cent r a l i z e d method i n t h e d i s t r i b u t e d d a t a b a s e s y s t e m , which h a s high d a t a locality c h a r a c t e r i s t i c s . c h a r a c t e r i s t i c (i) e s t a b l i s h e s a high reliability s y s t e m , c h a r a c t e r i s t i c s (i) a n d (iii)advance t h e o v e r a l l network throughput b e c a u s e of independent action a s s u r a n c e f o r e a c h site. T h e p e r f o r m a n c e evaluation on t h e p r o p o s a l is a f u t u r e theme. T r a f f i c p a t t e r n to d a t a b a s e , d a t a locality and number of sites may be main f a c t o r s in t h e evaluation. Acknowledgement T h e a u t h o r s are greteful f o r the useful a d v i c e t o M r . S a i t o and members of d i s t r i b u t e d d a t a b a s e management system p r o j e c t i n D a t a P r o c e s s i n g Application S y s t e m S e c t i o n , Data P r o c e s s i n g Development Div. Yokosuka E C L of N T T .

Proposition 6 If global deadlocks o c c u r a t t h e time t h a t a t r a n s a c t i o n is blocked, algorithm GLOBAL is a l w a y s

executed. F r o m P r o p o s i t i o n s 5 and 6 , i t c a n be e a s i l y
shown that all global deadlocks in t h e system c a n be d e t e c t e d . Note t h a t a c y c l e may be detected more t h a n one t i m e , or false c y c l e s may be d e t e c t e d by o u r algorithm. F r o m t h e d i s c u s s i o n a b o v e , T h e o r e m 1 is followed.

Site k is t h e site w h e r e t h e t r a n s a c t i o n T1 blocked.

is

366

REFERENCES

[ 11 Aho, A.V., J.E.Hopcroft and J . D . Ullman, "The Design and Analysis of Computer Algorithms", Addison Wesley, Reading, Mass. (1 974) E21 G r a y , J . N . , "Notes on Data B a s e Operating Systems", L e c t u r e Notes in Computer S c i e n c e , No. 60, (1978), 393-481. [ 3 ] King, P F and A . J. Collmeyer , "Database S h a r i n g An Efficient Mechanism for Supporting C o n c u r r e n t P r o c e s s e s " , National Computer Conference, (1 973), 271 -275. 141 Menasce, D.A. and R.R.Muntz, "Locking and Deadlock Detection in Distributed Databases", P r o c . of t h e 3rd Berkeley Workshop, (1 978), 21 5-232.

. . -

367

You might also like