Explain the various types of concurrency problem. I.e. Lost or buried updates, uncommitted dependency, inconsistent analysis, phantom read.Types of concurrency problems:
Lost updates: Occurs when 2 or more transactions select the same row/s and then update it on the basis of the original value. The last transaction update overwrites updates made by other transaction resulting in lost data.
Uncommitted dependency: Occurs when a second transaction selects row/s being updated by another transaction. The second transaction is reading the data that has not yet been committed and may be changed by the transaction executing updates on the row.
Inconsistent analysis: Occurs when a second transaction accesses row/s several times and reads different values every time. It involves multiple reads of the same row/s and every time the data is changed by another transaction.
Phantom reads: Occurs when an insert or delete statement is performed on a row/s that belongs to a resultset being read by another transaction.
Explain the various types of concurrency problem. I.e. Lost or buried updates, uncommitted dependency, inconsistent analysis, phantom read.Types of concurrency problem:-
Lost or buried updates: When the same row is selected for updates by two or more transactions and updates the row based on the value originally selected. Here, each transaction is unaware of the other transactions. The last update overwrites updates made by the other transactions, which results in lost data.
Uncommited dependency: here, a transaction reads data of another transaction which has not been committed yet. The value may be changed by the other transaction.
Inconsistent analysis: here, the transaction reads the data inconsistently. This means that every time the data is read; different values are read. This is because another transaction is continuously updating the data.
Phantom Read: Here, an insert or update is done on a row that belongs to some other transaction. Hence the transaction may read a row that may be deleted by some other transaction.
Describe optimistic and pessimistic concurrency.Optimistic concurrency: Assumes that a resource is likely to be available at all times. This means that resource locking is very unlikely. If a conflict occurs, the application must read the data and attempt the change again.
Pessimistic concurrency : this locks the resources as and when required. A transaction can be assured to be completed unless a deadlock occurs
Identify the various types of concurrency problem.Concurrency problem:
Lost updates: this occurs when two or more transactions are trying to update same row without being aware of each other. The last update overwrites updates made by the other transactions, which results in lost data.
Uncommitted dependency (Dirty read): This occurs when a second transaction selects a row that is being updated by another transaction. This second transaction is reading data that may not have been committed.
Inconsistent Analysis (Nonrepeatable Read): This occurs when a second transaction accesses the same row several times and reads different data each time. It is similar to dirty read. However, here it reads committed data, but different data each time.
Phantom Reads: This occurs when a range of rows which is being read by a transaction is deleted or updated. The transaction's first read of the range of rows shows a row that no longer exists in the second or succeeding read, as a result of a deletion by a different transaction.