The present invention is directed to an improvement in computing systems and in particular to computer systems for managing deadlocks in demultiplexed connection database management system environments.
In database management systems (DBMSs) it is possible to provide concurrent connections to a database by using demultiplexed connection environments. In such DBMSs, worker agents carry out processes in response to requests made by applications (or clients). Often agents are associated with applications by an application scheduler or manager for the life of a transaction. To handle the potentially large number of inbound connections being demultiplexed across a smaller number of worker agents, DBMSs use schedulers and wait queues.
In DBMSs such as relational DBMSs, applications are able to obtain locks on portions of a database. A row, a page or a table, for example, may be locked by an application, depending on the operation that the application is carrying out on the database in an RDBMS. Typically such locks are held on data representations in the DBMS but more generally are considered to be locks on database resources. Where locks are held and other applications seek to obtain locks, deadlocks may occur. In the prior art, such deadlocks may be detected by a deadlock detector in the DBMS. The deadlock detector may identify an application that will be required to release a held lock to break the deadlock.
Prior art systems have been developed to detect and recover from deadlocks as described above. For example, deadlock detectors are described in each of the following U.S. Pat. No. 5,095,421 (Freund, Mar. 10, 1992), U.S. Pat. No. 5,845,117 (Fujita, Dec. 1, 1998), U.S. Pat. No. 5,459,871 (Van Den Berg, Oct. 17, 1995), U.S. Pat. No. 5,440,743 (Yokota, Aug. 8, 1995), and U.S. Pat. No. 5,682,537 (Davies et al., Oct. 28, 1997). In U.S. Pat. No. 5,832,484 (Sankaran et al., Nov. 3, 1998), a deadlock detector and a method to avoid potential deadlock detection by deferring the deadlock detection steps is described. These prior art methods are generally concerned with systems that do not include a demultiplexing component for the processes which seek to acquire locks on resources.
In a demultiplexed connection DBMS, where there are worker agents assigned to applications, it is possible for an application to become inactive but to retain locks on portions of the database. In this case, the application will be disassociated from a worker agent and yet the application may retain locks on data in the DBMS. Where this occurs, and where both the inactive application is unable to acquire a worker agent and other applications are waiting for the inactive application to relinquish its lock, it is possible to have deadlocks in the DBMS.
In the prior art it is known that such deadlocks may occur in a DBMS and users of such systems must restart the system and make modifications to the number of worker agents available to permit processing in the database to continue. Such a disruption to the database system is undesirable where the database is required to be continually available.
It is therefore desirable to provide a computer system for the detection and management of deadlocks in a demultiplexed connection environment DBMS.
A system and method for managing deadlocks in a database management system (DBMS) for a demultiplexed database system having worker agents and applications associated with, and disassociated from, the worker agents is disclosed. The DBMS of the present invention supports applications that are capable of holding and retaining locks on database resources while disassociated from worker agents. The system and method of the present invention includes an application scheduler for managing requests for access to the database, and a deadlock detector for identifying a deadlock According to one embodiment of the present invention, the application scheduler assigns one worker agent to an application requesting access to a database resource, assigns a flag to an application holding a lock on the database resource while disassociated from a worker agent, and in cooperation with the deadlock detector, resolves the deadlock between the application requesting access and the flagged application holding the lock.
According to another aspect of the present invention, there is provided a deadlock management system for a database system, the database system including a set of applications selectively requesting and holding locks on database resources, a pool of worker agents including normal worker agents and overflow worker agents, an application scheduler, a wait queue, a priority queue, and a deadlock detector, the database system supporting an application holding a lock while disassociated from a worker agent, the deadlock management system including:
means for marking an application with a flag value based on the existing application flag value and on the state of applications requesting and holding locks on database resources, including,
means for marking an application with a flag value W where the application becomes disassociated from a worker agent,
means for marking an application with a flag value H where the application has a flag value W and where the application holds a lock on a database resource requested by another application,
means for marking an application with a flag value D where the application requests a worker agent, has a flag value H and there is no normal worker agent or overflow worker agent available for the application,
means for marking an application with the flag value Q where the application has a flag value W and a worker agent is not available, wherein the application is placed on the wait queue, and
means for marking an application with the flag value D where the application has the flag value Q and a worker agent associated with another application requests a lock held by the application having the flag value Q,
means for the application scheduler to respond to an application request for a worker agent and to selectively provide a normal worker agent, an overflow worker agent, or place the application on the wait queue or on the priority queue, based on the application flag value, including
means for responding to a request for a worker agent from an application with flag value H by obtaining a normal worker agent if available and alternatively providing an overflow worker agent, further including means for placing the application on the priority queue where no overflow worker agent is available, and
means for responding to a request for a worker agent from an application with flag value W by obtaining a normal worker agent if available and alternatively by placing the application on the wait queue,
means for clearing the application flag value when an application is provided with a worker agent,
means for the deadlock detector to poll an application and means for the deadlock detector to declare a deadlock where the application has a specified flag value and the application holds a lock on a database resource requested by another application, including,
means for declaring a deadlock where an application has a flag value D and the application holds a lock on a database resource that is requested by another application, the deadlock detector further including a lock wait deadlock graph and a resource representation, the lock wait deadlock graph including means to represent applications requesting and holding locks on database resources whereby the deadlock detector determines if an application holds a lock requested by another application, and
means for selecting an application holding a lock and for requiring the application to release the lock, following detection of a deadlock on the lock.
According to another aspect of the present invention, there is provided a method of deadlock management for a database system, the database system including a set of applications selectively requesting and holding locks on database resources, a pool of worker agents including normal worker agents and overflow worker agents, a wait queue, and a priority queue, the database system supporting an application holding a lock while disassociated from a worker agent, the method of deadlock management including the steps of:
1. marking an application with a flag value based on the existing application flag value and on the state of applications requesting and holding locks on database resources, including the steps of:
i) marking an application with a flag value W where the application becomes disassociated from a worker agent,
ii) marking an application with a flag value H where the application has a flag value W and where the application holds a lock on a database resource requested by another application,
iii) marking an application with a flag value D where the application requests a worker agent, has a flag value H and there is no normal worker agent or overflow worker agent available for the application,
iv) marking an application with the flag value Q where the application has a flag value W and a worker agent is not available, wherein the application is placed on the wait queue, and
v) marking an application with the flag value D where the application has the flag value Q and a worker agent associated with another application requests a lock held by the application having the flag value Q,
2. responding to an application request for a worker agent from the pool and selectively providing a normal worker agent, an overflow worker agent, or placing the application on the wait queue or on the priority queue, based on the application flag value, including the steps of:
i) responding to a request for a worker agent from an application with flag value H by obtaining a normal worker agent if available and alternatively by providing an overflow worker agent, further including the step of placing the application on the priority queue where no overflow worker agent is available, and
ii) responding to a request for a worker agent from an application with flag value W by obtaining a normal worker agent if available and alternatively by placing the application on the wait queue,
3. clearing the application flag value when an application is provided with a worker agent,
4. polling an application and declaring a deadlock where the application has a specified flag value and the application holds a lock on a database resource requested by another application, including the step of declaring a deadlock where an application has a flag value D and the application holds a lock on a database resource that is requested by another application, the database system further including a lock wait deadlock graph and a resource representation, the lock wait deadlock graph including means to represent applications requesting and holding locks on database resources whereby the step of declaring a deadlock comprises the step of determining if an application holds a lock requested by another application by accessing the lock wait graph, and
5. selecting an application holding a lock and requiring the application to release the lock, following detection of a deadlock on the lock.
According to another aspect of the present invention, there is provided a computer program product for deadlock management in a database system, the computer program product including a computer usable medium having computer readable code means embodied in the medium, including computer readable program code means for carrying out the above method.
Advantages of the present invention include the improved detection and management of deadlocks in DBMSs and include detection and elimination of a deadlock without requiring the DBMS to become unavailable to users.