Concurrency in dbms
• Concurrency is the ability of a database to allow multiple
users to affect multiple transactions. This is one of the main
properties that separates a database from other forms of data
storage like spreadsheets.
The ability to offer concurrency is unique to databases.
Spreadsheets or other flat file means of storage are often
compared to databases, but they differ in this one important
regard. Spreadsheets cannot offer several users the ability to
view and work on the different data in the same file, because
once the first user opens the file it is locked to other users.
Other users can read the file, but may not edit data.
Concurrent control
• concurrency control ensures that correct results
for concurrent operations are generated, while getting those
results as quickly as possible.
• concurrency control into a system means applying operation
constraints which typically result in some performance
reduction.
• Concurrency control can require significant additional
complexity and overhead in a concurrent algorithm
compared to the simpler sequential algorithm.
• For example, a failure in concurrency control can result in data
corruption from torn read or write operations.
Ways to control concurrency
There are three ways to control the concurrency
problem:-
1. The lost update problem.
2. The dirty read problem.
3. The incorrect summary problem.
LOST UPDATE PROBLEM
The lost update problem:
A second transaction writes a second value of a
data-item (datum) on top of a first value
written by a first concurrent transaction, and
the first value is lost to other transactions
running concurrently which need, by their
precedence, to read the first value. The
transactions that have read the wrong value
end with incorrect results.
Lost update problem solution
There are various method to preventing this
condition :-
1.Time stamping.
2.Read before write .
3. Locking .
4.Ignore it.
The most commonly use is time stamping
In time stamping, changes to a record are saved to the
database, only the timestamp field is retrieved and
compared with the timestamp that was saved when
the record was first retrieved. At this point,
timestamping works just like read before write. If the
timestamp values are different, the application knows
that another user has made changes to the record, so
it cancels the update process and an error message is
displayed to the user.
EXAMPLE FOR LOST UPDATE PROBLEM
Consider the case where two users are about to update the
same row/document in some data store. For example, let
user A retrieve some row first. After that, assume that
user B retrieves the same row; however, B writes his
update immediately, and in particular before A writes his
update. Then, the changes made by user B are silently
overwritten by the update performed by user A. This is
known as the lost update problem.
. It is depicted on the left hand side in the figure
given below:-
Concurrency in database system

Concurrency in database system

  • 1.
    Concurrency in dbms •Concurrency is the ability of a database to allow multiple users to affect multiple transactions. This is one of the main properties that separates a database from other forms of data storage like spreadsheets. The ability to offer concurrency is unique to databases. Spreadsheets or other flat file means of storage are often compared to databases, but they differ in this one important regard. Spreadsheets cannot offer several users the ability to view and work on the different data in the same file, because once the first user opens the file it is locked to other users. Other users can read the file, but may not edit data.
  • 2.
    Concurrent control • concurrencycontrol ensures that correct results for concurrent operations are generated, while getting those results as quickly as possible. • concurrency control into a system means applying operation constraints which typically result in some performance reduction. • Concurrency control can require significant additional complexity and overhead in a concurrent algorithm compared to the simpler sequential algorithm. • For example, a failure in concurrency control can result in data corruption from torn read or write operations.
  • 3.
    Ways to controlconcurrency There are three ways to control the concurrency problem:- 1. The lost update problem. 2. The dirty read problem. 3. The incorrect summary problem.
  • 4.
    LOST UPDATE PROBLEM Thelost update problem: A second transaction writes a second value of a data-item (datum) on top of a first value written by a first concurrent transaction, and the first value is lost to other transactions running concurrently which need, by their precedence, to read the first value. The transactions that have read the wrong value end with incorrect results.
  • 5.
    Lost update problemsolution There are various method to preventing this condition :- 1.Time stamping. 2.Read before write . 3. Locking . 4.Ignore it.
  • 6.
    The most commonlyuse is time stamping In time stamping, changes to a record are saved to the database, only the timestamp field is retrieved and compared with the timestamp that was saved when the record was first retrieved. At this point, timestamping works just like read before write. If the timestamp values are different, the application knows that another user has made changes to the record, so it cancels the update process and an error message is displayed to the user.
  • 7.
    EXAMPLE FOR LOSTUPDATE PROBLEM Consider the case where two users are about to update the same row/document in some data store. For example, let user A retrieve some row first. After that, assume that user B retrieves the same row; however, B writes his update immediately, and in particular before A writes his update. Then, the changes made by user B are silently overwritten by the update performed by user A. This is known as the lost update problem.
  • 8.
    . It isdepicted on the left hand side in the figure given below:-