Discuss the deadlock avoidance, detection and resolution for database concurrency control?
Solution:
Concurrency control is the procedure in DBMS for managing simultaneous transactions without conflicting with each another. In a database, a deadlock is an unwanted situation in which two or more transactions are waiting indefinitely for one another to give up locks. Deadlock is said to be one of the most feared complications in DBMS as it brings the whole system to a Halt.
Deadlock avoidance for database concurrency control:
Deadlock detection for database concurrency control:
In a database, when a transaction waits indefinitely to obtain a lock, then the DBMS should detect whether the transaction is involved in a deadlock or not. The lock manager maintains a Wait for the graph to detect the deadlock cycle in the database.
Wait-for-graph:
This is a simple method available to track if any deadlock situation may arise. For each transaction entering into the system, a node is created. When a transaction Ti requests for a lock on an item, say X, which is held by some other transaction Tj, a directed edge is created from Ti to Tj. If Tj releases item X, the edge between them is dropped and Ti locks the data item.
The system maintains this wait-for graph for every transaction waiting for some data items held by others. The system keeps checking if there's any cycle in the graph.
Here, we can use any of the two following approaches −
First, do not allow any request for an item, which is already locked by another transaction. This is not always feasible and may cause starvation, where a transaction indefinitely waits for a data item and can never acquire it.
The second option is to roll back one of the transactions. It is not always feasible to roll back the younger transaction, as it may be important than the older one. With the help of some relative algorithm, a transaction is chosen, which is to be aborted. This transaction is known as the victim and the process is known as victim selection.
Deadlock resolution for database concurrency control:
To prevent any deadlock situation in the system, the DBMS aggressively inspects all the operations, where transactions are about to execute. The DBMS inspects the operations and analyzes if they can create a deadlock situation. If it finds that a deadlock situation might occur, then that transaction is never allowed to be executed.
There are deadlock prevention schemes that use timestamp ordering mechanism of transactions in order to predetermine a deadlock situation.
Wait-Die Scheme:
In this scheme, if a transaction requests to lock a resource (data item), which is already held with a conflicting lock by another transaction, then one of the two possibilities may occur −
If TS(Ti) < TS(Tj) − that is Ti, which is requesting a conflicting lock, is older than Tj − then Ti is allowed to wait until the data-item is available.
If TS(Ti) > TS(tj) − that is Ti is younger than Tj − then Ti dies. Ti is restarted later with a random delay but with the same timestamp.
This scheme allows the older transaction to wait but kills the younger one.
Wound-Wait Scheme:
In this scheme, if a transaction requests to lock a resource (data item), which is already held with conflicting lock by some another transaction, one of the two possibilities may occur −
If TS(Ti) < TS(Tj), then Ti forces Tj to be rolled back − that is Ti wounds Tj. Tj is restarted later with a random delay but with the same timestamp.
If TS(Ti) > TS(Tj), then Ti is forced to wait until the resource is available.
This scheme, allows the younger transaction to wait; but when an older transaction requests an item held by a younger one, the older transaction forces the younger one to abort and release the item.
In both the cases, the transaction that enters the system at a later stage is aborted.
Please give thumbsup, if you like it. Thanks.
Discuss the deadlock avoidance, detection and resolution for database concurrency control?
Explain how timestamps are used for concurrency control and deadlock prevention. Also explain how does the Thomas write rule improve concurrency?
database of operating system Purpose: To help you know about the main concepts of concurrency control and recovery. Topic of Discussion: According to the conflicts and failure in transactions processing, the need of concurrency control and recovery appeared. Discuss the differences between concurrency control and recovery in terms of: · The purposes. · The algorithms. · The problems.
Consider the following protocol for concurrency control. The database system assigns each transaction a unique and strictly increasingly id at the start of the transaction. For each dataitem, the database system also keeps the id of the last transaction that has modified the data item, called the transaction-id of the data item. Before a transaction T wants to read or write on a data item A, the database system checks whether the transaction-id of A is greater than the id...
[Q.7] Answer the following questions (a) Explain 2PL in the context of database concurrency control (b) Explain the reason why most DBMS provides isolation level. (c) List and explain 4 different isolation levels of the MySQL DBMS.
[1096] Suppose there is no deadlock prevention and detection implemented in a computer system. How do we make sure there is a deadlock happening? [596] How do we tell the deadlock from a thrashing? [506] [1096] Suppose there is no deadlock prevention and detection implemented in a computer system. How do we make sure there is a deadlock happening? [596] How do we tell the deadlock from a thrashing? [506]
2. What are the advantages of database systems and database management? Discuss based on Data Independence, data modeling, Managing Structured, Semi-Structured, and Unstructured Data, Managing Data Redundancy, Specifying Integrity Rules, concurrency control, Backup and Recovery Facilities, Data Security, Performance Utilities. Use 3 of your own examples in your own words!!!
ATTEMPT ALL QUESTIONS Compare and contrast Pessimistic and Optimistic Concurrency Control techniques. 5 marks Describe quorum-based protocol for distributed concurrency control. 5 marks Discuss how distributed systems are used in organizations 10 marks Discuss the techniques used to facilitate distributed query processing and Optimization. 10 marks
Discuss pros and cons of pessimistic concurrency in relation to optimistic concurrency. Discuss pros and cons of explicit transactions in relation to implicit transactions and vice versa.
- Identify one benefit and one drawback of each concurrency control strategy in an OLTP application. Explain. - Identify one benefit and one drawback of each concurrency control strategy in a data warehouse. Explain. - Suggest a scenario for a hypothetical OLTP business system where optimistic concurrency control is most appropriate and another scenario where pessimistic concurrency control is most appropriate. - How would the type of user, such as a computer program, an internal business user, or a customer...
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) A process declaring its maximum need as maximum possible for each resource. In other words, if a resource A has 5 instances, then each process declares its maximum need as 5. (ii) A process declaring its minimum needs as maximum needs. For example, a process may need 2-5 instances of resource A. But it declares its maximum need as 2