Learn something new every day More Info... by email
A deadlock victim is a computer user, acting as a client connected to a server, whose connection the server host has chosen to terminate to resolve a deadlock. This type of deadlock often arises when two different processes are attempting to utilize the same resources, which causes both processes to lock up. In order to resolve this issue, many server database systems can detect when a deadlock occurs and then choose to terminate the connection of one of the two processes. A deadlock victim can be chosen arbitrarily by the program, though the user is typically chosen as the one who can most easily reconnect to the system.
The term “deadlock victim” is typically used in the error or exception message displayed by the system to the user when his or her connection is terminated. This error occurs in a situation commonly referred to as a deadlock. In general, a deadlock occurs when two users connected to a server are attempting to access the same resources in a way that creates a lock on the system. For example, if User A is using resource 1 and needs to also use resource 2, while User B is using resource 2 and needs to use resource 1 as well, a deadlock occurs since neither user can finish his or her process.
In this example, one of the two users would be chosen by the system as the deadlock victim and his or her connection to the server would be terminated. Once this occurs, the other user can finish his or her process, ending the deadlock and the deadlock victim can reconnect to the server. Most server database programs are designed with deadlock detection, which typically detects a deadlock after a certain amount of time. Even though a deadlock is not necessarily a major problem, it can be a nuisance for users, especially those chosen as the deadlock victim, and indicates one or more mistakes in server database programming.
The way in which a server chooses a deadlock victim can vary. Some programs choose the victim on a purely random basis. While this can be fairly effective, since any choice leads to a solution and the end of the deadlock, this is not always an ideal method. A server is typically programmed to evaluate the two users to choose the one who could most easily reconnect or who will lose the least amount of data due to disconnection.