Professional Documents
Culture Documents
PRESENTED BY S.HAYAT 1
Concurrency Control Problems
PRESENTED BY S.HAYAT 2
Figure LOST UPDATE
• This problem occurs when one user reads data that have
been partially updated by another user.
PRESENTED BY S.HAYAT 4
Time T3 T4 balx
t1 begin-transaction 100
t2 read(balx) 100
t3 balx = balx +100 100
t4 begin_transaction write(balx) 200
t5 read(balx) : 200
t6 balx = balx -10 rollback 100
t7 write(balx) 190
t8 commit 190
PRESENTED BY S.HAYAT 5
Concurrency Control Techniques
• Serializability –
– Finish one transaction before starting another
• Locking Mechanisms
– The most common way of achieving serialization
– Data that is retrieved for the purpose of updating is
locked for the updater
– No other user can perform update until unlocked
PRESENTED BY S.HAYAT 6
Figure-Updates with locking for concurrency control
• Locking level:
– Database – used during database updates
– Table – used for bulk updates
– Block or page – very commonly used
– Record – only requested row; fairly commonly used
– Field – requires significant overhead; impractical
• Types of locks:
– Shared lock - Read but no update permitted. Used
when just reading to prevent another user from placing
an exclusive lock on the record
– Exclusive lock - No access permitted. Used when
preparing to update
PRESENTED BY S.HAYAT 8
Deadlock
• An impasse that results when two or more transactions
have locked common resources, and each waits for the
other to unlock their resources
Figure:
A deadlock situation
PRESENTED BY S.HAYAT 9
Managing Deadlock
• Deadlock prevention:
– Lock all records required at the beginning of a
transaction
– Two-phase locking protocol
• Growing phase
• Shrinking phase
– May be difficult to determine all needed resources in
advance
• Deadlock Resolution:
– Allow deadlocks to occur
– Mechanisms for detecting and breaking them
• Resource usage matrix
PRESENTED BY S.HAYAT 10
Versioning
PRESENTED BY S.HAYAT 11
use of versioning
Recovery Techniques/facilities:
Backup Facilities
Journalizing Facilities
Checkpoint Facility
Recovery Manager
PRESENTED BY S.HAYAT 13
Database Recovery & Its Techniques
PRESENTED BY S.HAYAT 14
Database Recovery & Its Techniques
• Journalizing facilities: A DBMS must provide Journalizing
facilities to produce an audit trial of transactions and database
changes. In the event of a failure, a consistent database state can
be re-established using the information in the journals together.
PRESENTED BY S.HAYAT 15
Database Recovery & Its Techniques
PRESENTED BY S.HAYAT 16
Database audit trail
PRESENTED BY S.HAYAT 17
Database Recovery & Its Techniques
• Checkpoint Facility:
• DBMS periodically refuses to accept new transactions
• system is in a quiet state
• Database and transaction logs are synchronized
• The DBMS writes a special record( called a checkpoint record) to
the log file, which is like a snapshot of the state of the database.
• Checkpoints should be taken frequently when failures do occur, it
is often possible to resume processing from the most recent
checkpoint.
• Only a few minutes of processing work must be repeated,
compared with several hours for a complete restart of the day’s
processing.
PRESENTED BY S.HAYAT 18
Database Recovery & Its Techniques
PRESENTED BY S.HAYAT 19