The Wayback Machine - https://web.archive.org/web/20240811093140/https://www.geeksforgeeks.org/starvation-in-dbms/
Open In App

Starvation in DBMS

Last Updated : 24 Apr, 2023
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Starvation or Livelock is the situation when a transaction has to wait for an indefinite period of time to acquire a lock. 

Reasons for Starvation:

  • If the waiting scheme for locked items is unfair. ( priority queue )
  • Victim selection (the same transaction is selected as a victim repeatedly )
  • Resource leak.
  • Via denial-of-service attack.

Starvation can be best explained with the help of an example – 

Suppose there are 3 transactions namely T1, T2, and T3 in a database that is trying to acquire a lock on data item ‘ I ‘. Now, suppose the scheduler grants the lock to T1(maybe due to some priority), and the other two transactions are waiting for the lock. As soon as the execution of T1 is over, another transaction T4 also comes over and requests a lock on data item I. Now, this time the scheduler grants lock to T4, and T2, T3 has to wait again. In this way, if new transactions keep on requesting the lock, T2 and T3 may have to wait for an indefinite period of time, which leads to Starvation. 

Solutions to starvation:

  1. Increasing Priority: Starvation occurs when a transaction has to wait for an indefinite time, In this situation, we can increase the priority of that particular transaction/s. But the drawback with this solution is that it may happen that the other transaction may have to wait longer until the highest priority transaction comes and proceeds.
  2. Modification in Victim Selection algorithm: If a transaction has been a victim of repeated selections, then the algorithm can be modified by lowering its priority over other transactions.
  3. First Come First Serve approach: A fair scheduling approach i.e FCFS can be adopted, In which the transaction can acquire a lock on an item in the order, in which the requested lock.
  4. Wait-die and wound wait scheme: These are the schemes that use the timestamp ordering mechanism of transactions. 
  5. Timeout Mechanism: A timeout mechanism can be implemented in which a transaction is only allowed to wait for a certain amount of time before it is aborted or restarted. This ensures that no transaction waits indefinitely, and prevents the possibility of starvation.
  6. Resource Reservation: A resource reservation scheme can be used to allocate resources to a transaction before it starts execution. This ensures that the transaction has access to the necessary resources and reduces the chances of waiting for a resource indefinitely.
  7. Preemption: Preemption involves the forcible removal of a lock from a transaction that has been waiting for a long time, in favor of another transaction that has a higher priority or has been waiting for a shorter time. Preemption ensures that no transaction waits indefinitely, and prevents the possibility of starvation.
  8. Dynamic Lock Allocation: In this approach, locks are allocated dynamically based on the current state of the system. The system may analyze the current lock requests and allocate locks in such a way that prevents deadlocks and reduces the chances of starvation.
  9. Parallelism: By allowing multiple transactions to execute in parallel, the system can ensure that no transaction waits indefinitely, and reduces the chances of starvation. This approach requires careful consideration of the potential for conflicts and race conditions between transactions.
For detailed study refer: Wait die and Wound wait scheme

In a database management system (DBMS), starvation occurs when a transaction or process is not able to get the resources it needs to proceed and is continuously delayed or blocked. This can happen when other transactions or processes are given priority over the one that is experiencing starvation.

In DBMSs, resources such as locks, memory, and CPU time are typically shared among multiple transactions or processes. If some transactions or processes are given priority over others, it is possible for one or more transactions or processes to experience starvation.

For example, if a transaction is waiting for a lock that is held by another transaction, it may be blocked indefinitely if the other transaction never releases the lock. This can lead to the first transaction experiencing starvation if it is continuously blocked and unable to proceed.

DBMSs typically use various techniques to prevent or mitigate starvation, such as:

Resource allocation policies: DBMSs can use policies to allocate resources in a fair manner, ensuring that no transaction or process is consistently given priority over others.

Priority-based scheduling: DBMSs can use scheduling algorithms that take into account the priority of transactions or processes, ensuring that high-priority transactions or processes are executed before low-priority ones.

Timeout mechanisms: DBMSs can use timeout mechanisms to prevent transactions or processes from being blocked indefinitely, by releasing resources if a transaction or process waits for too long.

Resource management: DBMSs can also use techniques such as resource quotas and limits to prevent any single transaction or process from monopolizing resources, thus reducing the likelihood of starvation.

Disadvantages of Starvation:

Decreased performance: Starvation can cause decreased performance in a DBMS by preventing transactions from making progress and causing a bottleneck.

Increased response time: Starvation can increase response time for transactions that are waiting for resources, leading to poor user experience and decreased productivity.

Inconsistent data: If a transaction is unable to complete due to starvation, it may leave the database in an inconsistent state, which can lead to data corruption and other problems.

Difficulty in troubleshooting: Starvation can be difficult to troubleshoot because it may not be immediately apparent which transaction is causing the problem.

Potential for deadlock: If multiple transactions are competing for the same resources, starvation can lead to deadlock, where none of the transactions can proceed, causing a complete system failure.


Previous Article
Next Article

Similar Reads

Difference between Deadlock and Starvation in OS
Deadlock: Deadlock occurs when each process holds a resource and wait for other resource held by any other process. Necessary conditions for deadlock to occur are Mutual Exclusion, Hold and Wait, No Preemption and Circular Wait. In this no process holding one resource and waiting for another get executed. For example, in the below diagram, Process
2 min read
Starvation and Aging in Operating Systems
Starvation occurs when a process in the OS runs out of resources because other processes are using it. This is a problem with resource management while Operating systems employ aging as a scheduling approach to keep them from starving. It is one of the most common scheduling algorithms in batch systems. Each process is assigned a priority. The proc
6 min read
Need for DBMS
A Data Base Management System is a system software for easy, efficient and reliable data processing and management. It can be used for: Creation of a database.Retrieval of information from the database.Updating the database.Managing a database.Multiple User InterfaceData scalability, expandability and flexibility: We can change schema of the databa
4 min read
Introduction of Relational Model and Codd Rules in DBMS
Pre-Requisite: Relational Model in DBMS It was proposed by Dr. E.F. Codd. It uses the concept of relations to represent each and every file. Relations are Two-Dimensional Tables. It is easy to implement and easy to simplification in the operations to manipulate the data. This is the most popular data model. It is simple to implement. It uses the pr
12 min read
Thomas Write Rule in DBMS
The "write rule" in database management systems (DBMS) refers to a principle that governs how changes to the database are handled. Specifically, the write rule states that any modification to a database must be written to disk before control is returned to the user. In other words, when a user executes a command that modifies the database (such as
5 min read
Armstrong's Axioms in Functional Dependency in DBMS
Prerequisite - Functional Dependencies This article contains Armstrong's Axioms and how Armstrong's Axioms are used to decide about the functional dependency on the database. We will be also learning about the Secondary Rules and Armstrong Relations. We will learn each thing in detail. Before moving ahead, you must have a knowledge of Functional De
4 min read
Transaction Isolation Levels in DBMS
Prerequisite - Concurrency control in DBMS, ACID Properties in DBMS As we know, in order to maintain consistency in a database, it follows ACID properties. Among these four properties (Atomicity, Consistency, Isolation, and Durability) Isolation determines how transaction integrity is visible to other users and systems. It means that a transaction
5 min read
Database Objects in DBMS
A database object is any defined object in a database that is used to store or reference data.Anything which we make from create command is known as Database Object.It can be used to hold and manipulate the data.Some of the examples of database objects are : view, sequence, indexes, etc. Table - Basic unit of storage; composed rows and columns View
4 min read
Graph Based Concurrency Control Protocol in DBMS
Graph-based concurrency control protocols are used in database management systems (DBMS) to ensure that concurrent transactions do not interfere with each other and maintain the consistency of the database. In graph-based concurrency control, transactions are represented as nodes in a graph, and the conflicts between transactions are represented as
4 min read
Introduction to TimeStamp and Deadlock Prevention Schemes in DBMS
Deadlock occurs when each transaction T in a schedule of two or more transactions waiting for some item locked by some other transaction T' in the set. Thus, both end up in a deadlock situation, waiting for the other to release the lock on the item. Deadlocks are a common problem and we have introduced the problem while solving the Concurrency Cont
7 min read
Article Tags :
three90RightbarBannerImg