You are on page 1of 5

A New Distributed Deadlock Detection Algorithm For Distributed Database Systems

Chim-fi Yeung, Sheung-lun Hung ,Kam-yiu Lam and Chee-keung Law Department of Computer Science City Polytechnic of Hong Kong 83 Tat Chee Avenue, Kowloon Tong, Hong Kong
Abstract
In this paper, a new distributed deadlock detection algorithm is proposed. Deadlock is detected through passing special messages, called probes, along the f edges o the wait-for graphs in the system. The algorithm is an improved version o Chandy's f algorithm [4] which fails completely in certain cases. The new algorithm has been tested through extensive simulation experiments. Besides being error p e e , it is shown to sufler very little performance degradation j h m the additional deadlock detection overhead in comparison to the original algorithm. The algorithm has olso compared with time-out method. It is found f that for large values o multiprogramming level, the probe-based algorithm can outperform time-out. The performance results indicate that in the modified algorithm, the rate o probe initiation is a dominant f factor in determining system performance.

1 Introduction
The objective of concurrency control is to allow " & concurrent execution of t a 'om without violating the consistency of the database [9]. V r o s aiu concurrency control protocols have been proposed [1,2,3,12]. Among them two phase locking [l] is the one most commonly adopted in the design of commercial products. In two phase locking, the contlicts resulting from sharing of data objects are resolved by setting locks on the data objects. One of the major problem of two phase locking is that the possibility of deadlock resulting from cyclic-wait for locks among different t c 'om. Deadlock is " % undesirable because the transactions involved in deadlock cycle are blocked permanently. The resulting system performance is thus dramatically degraded. In distributed database systems, deadlock detection become very complex as a result of lacking global system state. Although different deadlock detection algorithms in distributed system have been proposed

[4, 5, 6, 131, it has been found that some algorithms fail to detect deadlock under certain cases and some detect false deadlocks [6,7]. Different approaches have been adopted in distributed deadlock detection. Some of them try to construct a global system state [13] and the other try to pass a special message through blocked transactions in order to find out a deadlock cycle [4, 5, 61. Such approach is called probe-based distributed deadlock detection as proposed by Chandy, Misra and Haas [4,5]. The main feature of this approach is that no global system state is needed. Although many literatures refer and m m [2,4,6] Chandy's algorithm but most of them has neglect its performance issues and not its correctness. In our study, it has been found that in cases where deadlock cycles are repeatly formed among different transactions, Chandy's alorithm fails completely. In this paper, a new probe-based distributed deadlock detection algorithm is proposed to address the weakness of Chandy's algorithm. The performance of the algorithm has been examined and compared with time-out method through extensive simulation experiments. The remainder of this paper is organized as followed. Section 2 presents Chandy's algorithm and its deficiency. Section 3 is the modified deadlock detection algorithm. Section 4 is the results and their interpretation. Lastly, the conclusions and future research work are presented in section 5.

Chandy's Algorithm and Its Deficiency

Chandy's deadlock detection algorithm [4,5] is based on passing probes through different sites. In each site, there is a controller which maintains a Boolean array Dependk, known as dependency table k, for each constituent process Pk,where Dependk(i) is true only if controller knows that Pi is dependent on pk. If Dependi(i) is true, then Pi is dependent on itself and hence is deadlocked. The probe computation will be initiated periodically by the controller whenever the constituent process is idle. The algorithm has been

w s

found that for some cases when the degree of data contention is high, some deadlocks may not be detected.The following example illusrates the problem. Assume the initial system state at To is defined as in figure (1). Initially, there is a deadlock cycle, involving procases Pi, P2, P3, P4, P5, Pg and p7 in t e system. The deadlock is detected when P6 receives h the probe(6,4,6). Pg is selected as victim and is aborted. All data objects being held by Pg will be Rl&.

"

Figure 1 System state at To Suppose at time Ti, P7 is granted the data object which is waiting by P4 and later it is depended on P5. The new system state can be represented by figure (2). Although there is a deadlock (with processes Pi, P2, P3, P4, p7 and P5) in the system as depicted in figure (2), this deadlock will not be detected by the algorithm. Based on Cbandy's algorithm, only the processes that situating at the site boundary and receiving probes will be declared deadlocked. Therefore, in this example, only processes Pi, P3 and P7 are the possible victim. However, all the probes from these three processes will not be able to detect the deadlock. probe(l,2,3) will be initiated by controller C1 on behalf of Pi. Controller C2 will eventually discard this probe when P3 is receiving it because P i is a positive entry in the dependency table of P3 @epend3(l)==e). probe(3,4,7) and Probe(7,5,1) will also be discarded by controller C1 with the same reason. No probe can be propagated along the wait-for path, and so this deadlock cycle exists permanently and will not be detected.

The cause of the problem in Chandy's algorithm is that when a deadlock is resolved the information in the dependency table is not cleared and such information is used for detecting another deadlock. Therefore, the problem found in Chandy's algorithm can be rectified by clearing the dependency table periodically. So that the probes has to be re-transmitted and will not be discarded. As in the last example, suppose the dependency table of processes P i and P3 are cleared at some time after time Ti. Then the deadlock cycle in figure (2) can be detected subsequently. Suppose P i initiates Probe(1,2,3). P3 receives the probe and propagates to P7 by Probe(1,4,7). P7 will propagate Probe(l,S,l) to P i which will eventually be declared deadlock. However, when the dependency tables should be cleared. If the dependency tables are being cleared frequently, the number of probe messages will be great as many probes needed to be re-transmitted. If the dependency tables are being cleared sparsely, the syskm may be frozen at the deadlock state for a long time before the deadlock is detected. As the controller initiates probes periodically, the number of probe initiations can then be use to estimate the blocking period of a process. Therefore, the problem of determiningwhen to clear the dependency table may be quantified to the number of probe initiations.

Performance Results and Interpretation

Four sets of simulation experiments are designed to study the impacts of following factors on the system performance : (1) Data contention on system throughput (2) Rate of probe computation (3) Timing on dependency table clearance (4) Compare the probe-based algorithm with time-out
4.1 Effect of Data Contention on System Performance As the parameter setting makes the lock coflict probability high, it is expected that the performance is getting worse as the MF'L increases. The degradation in system performance as shown in figures (3) can be explained by high blocking time and communication link contention. Increasing MPL increases both the probability of blocking and deadlock. Thus the blocking time of a transaction will be greater. High blocking time decreases the concurrency of system and results in poor system performance. The CPU overhead, which is the workload for searching local dependency and forwarding probes, for deadlock detection per committed transaction also increases with MF'L as shown in figure (4). However, comparing this result with the number of aborted

II

=3

Figure 2 - System state at T i

II

3 The New Algorithm

507
~

transaction as shown in figure (3), it can be seen that although the amount of overhead increases with MPL, thenumberofabortedt"a& 'ons or in other words the number of deadlock detected, remains fairly constant. Table (1) depicts the amount of probe initiations for each detected deadlock.

92.85 38.42

data contention is low (i.e. MPL=5). However, for high degree of data contention, if the dependency table is cleared frequently, the performance is degraded. This canbe explainedby the defect ofchaodys algorithm. For large Clear-depend, the detection algorithm is equivalent to Chandy's algorithm. Therefore, some deadlocks may exist for a long time without being detected and those t c I " t 'Ons involved in these deadlocks will remain in idle state and tie up system
resourcles.

Table 1 Number of Initiations per deadlock detected Ideally, only one probe initiation is required to detect a deadlock cycle. However, from the table, it can ht be obsuved t a very large portion of deadlock detection overhead is unnecessary. The reason is that the deadlock detection algorithm does not know exactly (or approximately) when a t c I is deadlocked. " t 'on Deadlock detection should be initiated whenever the site controllers suspect that there exists a deadlock.

4.4 Compare Probe-based Algorithm with Tmeout


The performance of the modified probe-based and t i m e a t algorithms 1141 in a distributed database system are compared in figures (8). The probability of deadlock is varied by changing the t a 'on size as " & the probability of deadlock increases sharply with transaction size. In figure (8), it can be seen that with small deadlock probability, the time-out algorithm performs better than the probe-based algorithm for high MPL. It is due to the higher deadlock detection overhead in the probe-based algorithm which initiates deadlock detection whenever a deadlock cycle is seems to be formed. However, as the deadlock probability increases by increasing the t c I size, the " t 'on modified probe-based algorithm perform much better than the time-out algorithm. The cost of high deadlock detection overhead in the probebased algorithm is justified when the probability of deadlock is high. On the other hand, when there are large amoung of deadlocks, cyclic restarts will be resulted. More transactionswill be rest;uted by the time-out algorithm than the probe-based algorithm as shown in figure (9). The cost of aborting the false deadlocks by time-out far out-weight its benefit.

4.2 Rate of Probe Initiation

The effect of the rate of probe initiation is signiscant when the probability of conflict is high. Figure (5) depicts the throughput under different rate of probe. initiation. The result indicates that under high degree of data contention (i.e. MPL=25), throughput decreases gradually after reaching its maximum value as the time to initiate a probe computation increases. This can be explained by large number of probe messages and long blocking time. For small value of Initjrobe (Initqrobeco.5 sec), number of probe initiated per committed transaction is high. This high velum of probe messages causes communication link contention and delays the propagation of messages and results in longer blocking time of t a 'ons At the " & same time, CPU t m is needed for probe initiation. ie High rate of probe initiaion will use up huge amount of CPU t m . Figures ( ) shows the amount of CPU ie 6 overhead for deadlock detection. If the time for probe initiation is large (Init~robe=1.5 sec for MPL=20), deadlock cycle will exist for a longer period before it is detected. This will increases the blocking time and tie up the system resources for a longer time.
4.3 Timing on Dependency Table Clearance

5 Conclusions

In the modified algorithm, timing on dependency table clearance (Clear-depend) is a factor that aFects the system performance. Figures (7) shows the throughput of the system under different Clear-d-nd values. The result indicates that the impact of Clear-depend is not signiscant when the degrce of

In this paper, a new probe-based distributed deadlock detection algorithm is introduced to reaify some of the shortfalls of the algorithm proposed by Chandy, Misra, and Haas. The new algorithm has been subjected to extensive simulation experiments and has shown to be error free and suffer to very little performance degradation. From the performance results obtained, the following conclusions have been reached : (1) The system performance is highly degraded as the number of probe initiations increase. (2) Very large portion of deadlock d e m o n overhead is wasted because the site controller does not know exactly when a deadlock is formed. Rules should be developed to determine the best time to initiate deadlock detection.

(3) The rate of probe initiaitions has significant effect hs on the system performance for t o e high data contention systems. This parameter should be CareNly selectedtoachieveopti"pelf0~. (4) System suffers w y little performance degradation from the additional overhead for the clearance of dependency table i t o u e in the modified algorithm nrdcd in comparison with the original algorithm. However, rate of clearing dependency tables should be carefully chosen in order to achieve optimum pedormance. It has shown that the rate of probe initiations has significant effect on the system performance. Different initiation procedures, other than the implemented periodic method, should be further examined. More extensive study on enhancing the deadlock detection efliciency should be carried out. The simulation results also indicate that for large MPL., probe-based approach such as the proposed algorithm can outperform the simple time-out approach. Another observation shows that large portion of deadlock detection overhead is wasted due to the d i t r a r y initiation of deadlock detection. Deadlock detection is initiated whenever the site controllers suspect that there exists a deadlock. There is no rule today to determine the best time to initiate deadlock detection and finding rule@) to minimize deadlock detection overheads is important if system perfonnance is to be maximized.

[7]A. K.Elmagarmid, "A survey of distributed deadlock detection algorithms,"ACMSZGMODRec. Vol. 15, No. 3, Sep. 1986.
[8] H. Enslow, "Whatis a "Distributed"Data Processing System?" Computer, Vol. 11, pp. 16-23, Jan. 1978. [9] P. Eswaran,J. N. Gray, R.A. Lorie, andI. L. Traiger, "The Notiom of Consistencyand Predicate Locks in a htabaseSy&m,"ACMC~. Vol. 19,No. 1 1 , ~623~. 633, Nov. 1976. [lo] N. Gray, "Notes on Database Operating System," in Opaating Systems: An Advanced Course @ ae Notes in . r & Computer Science 60), Berlin, Germany, Springer-Verlag, pp. 398481,1978. [l 11 E. Knapp, "DeadlockDetestion in Distributed Database," ACM, Comp. Sur., Vol. 19, No. 4, pp. 302-328, Dec. 1987. [12] H. T. Kung and J. T. Robinson, "Optimistic Methods for ConcurrencyControl," ACMTmns. Dorobose Syst., Vol. 6, p ~212-226, J u ~1981. . . [13] R.Obermarck, "DistributedDeadlock Detection Algorithm," ACM Tmns. DafubuseSyst., Vol. 7, NO.2, pp. 202-223, Jun. 1982.
[14] Y. Parker and J.P. Verjus,Distributed Computing Systems (Synchronization.Control and Communication). Academic Press, 1983.

References VI A. B " N. Goodman, "ConcurrencyControl in e and


'

DiSaibutedDatabaseSystems," A W C o m p Sur., Vol. 13, NO.2, pp. 185-221, Jun. 1981.


[2] A. Banstein, V. Hadzilacos, and N. Goodman, Concurrency Control and Recovey in Dotobare Systenu, Reading,Massechusetts, Addi~on-WeSley, 1987. [3] S. Ceri and G. Pelagatti, Disrributed Databases PrinciprcS and Systems, New Y r , McGraw-Hill Book ok company, 1984.
1 -

+connnmed Tx . +Abated Tx

[4] M. Chandy and J. Misra, "A distributed algorithm for

dete&ngresource deadlocks in distributed systems", Pnxeedings ofthe A C M S p p i u m on Principres of LXstributedComputing @t&mu, Canada,Aug.), ACM, New Y r , 157-164,1982. o k pp.
[SI M. Chendy, J. Misra, and L. M. Haas, "Distributed Deadlock Detection," ACMTmns. Comput. Syst., Vol. 1, pp. 143-156, May 1983.

+<-,

---..--..-I
I

12

15

20

25

Figure 3 Throughput vs MPL

Multip&"ing

Lcvcl

[6] N. Choudhary, W. Kohler, I. A. Stankovic, and D. H. Towsley, "A Modified Priority Based Probe Algorithm for DistributedDeadlock Detection and Resolution," IEEE Tmns. SopMreEng., Vol. 15,No. 1,pp. 10-17, Jan. 1989.

509

4
I

3-

2-

(
1 -

-.
2

Figure 4 CPU overhead per committed transaction vs MPL

MultiprigntmningL m l

10

30

Figure 7 - Throughput vs Time to clear dependency table

Clepr_depad

: 7I WJ
+RobSbased(Ts=lO) *T-ut (TS=lO) Sprobe-based(Ts40) -Timc-oUt (TS=20)
1.5
0.6
0.7

0.8

0.8

1.1

1.3

1.

Figure 5 Throughput vs Time to initiate probe

lllasma(=4

10

15

20

25

Multiprogrumnhg Level

Figure 8 Throughput vs MPL

CPU ovemad (om)

+MPL=ZO

0.5

0.6

0.7

0.8

0.8

1.1

1.3

Figure 6 CPU overhead per committed transaction vs Time to initiate probe

Inilsrobe (=)

Figure 9 Mean number of restart vs MPL

MultiprogrammingLevel

510

You might also like