Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
3 views2 pages

Transaction Management Notes Part3

Book for Transaction management

Uploaded by

Laxmi Priya Dash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Transaction Management Notes Part3

Book for Transaction management

Uploaded by

Laxmi Priya Dash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Transaction Management - Detailed Class Notes

(Part 3)
7. Introduction to Crash Recovery
Definition: Crash recovery refers to the process of restoring the database to a correct state after a
system failure such as power outage, hardware error, or software crash. The main goal of recovery
is to ensure that all committed transactions are saved permanently and all uncommitted
transactions are undone.

Types of Failures:
- Transaction Failure: An error in a transaction (like division by zero).
- System Crash: Hardware or software failure causing abrupt stop.
- Disk Failure: Physical damage or corruption of storage media.

Techniques for Recovery:


- Redo: Reapply all changes of committed transactions.
- Undo: Rollback all changes of uncommitted transactions.

Example:
If Transaction T1 deducts money from Account A but before crediting to Account B the system
crashes, recovery ensures that T1 is rolled back so no money is lost.

8. Two-Phase Locking (2PL)


Definition: Two-Phase Locking (2PL) is a concurrency control method that ensures serializability of
transactions. It requires each transaction to obtain locks in two phases:

Phases:
- Growing Phase: A transaction may acquire locks but cannot release any.
- Shrinking Phase: A transaction may release locks but cannot acquire new ones.

Why 2PL is Important: It guarantees that the schedule of transactions will be serializable, meaning
the result will be the same as if the transactions executed one after another.

Example:
Transaction T1 locks Account A and then Account B. Once it releases Account A, it cannot acquire
new locks. This ensures order and prevents conflicts with other transactions.

9. Serializability
Definition: Serializability is the concept that ensures concurrent execution of transactions produces
the same result as if they were executed in some serial order. It is the main correctness criterion for
concurrency control.

Types of Serializability:
- Conflict Serializability: A schedule is conflict serializable if it can be transformed into a serial
schedule by swapping non-conflicting operations.
- View Serializability: A schedule is view serializable if the transactions in it view the same data as
they would in some serial schedule.

Example:
If T1 reads A before T2 writes A, then this order must be maintained in all equivalent schedules to
ensure correctness.
10. Recoverability
Definition: Recoverability ensures that if a transaction Tj depends on another transaction Ti (for
example, Tj reads a value written by Ti), then Tj commits only after Ti commits. This avoids
problems where a committed transaction has used uncommitted data.

Types of Schedules:
- Recoverable Schedule: A schedule where no transaction commits until all transactions from
which it has read also commit.
- Cascadeless Schedule: A stricter form where a transaction can only read committed values,
preventing cascading rollbacks.

Example:
If T2 reads a value written by T1, then T2 must wait for T1 to commit before committing. If T1 rolls
back, then T2 must also roll back to maintain consistency.

11. Introduction to Lock Management


Definition: Lock management is the process by which a database system keeps track of which
transactions hold locks on which data items, and ensures correct granting and releasing of locks.

Lock Manager: A lock manager is a special component in DBMS that records all lock requests,
checks for conflicts, and maintains a lock table.

Lock Table: A table where information is stored about data items, the types of locks held, and the
transactions holding them.

Example:
If T1 requests a shared lock on Account A, the lock manager checks if another transaction holds an
exclusive lock. If yes, T1 must wait; if not, the lock is granted.

12. Dealing with Deadlocks


Definition: A deadlock is a situation in which two or more transactions are waiting indefinitely for
each other to release locks, and as a result, none of them can proceed.

Deadlock Example:
- T1 locks Account A and requests Account B.
- T2 locks Account B and requests Account A.
Both are waiting for each other and the system gets stuck.

Deadlock Handling Methods:


- Deadlock Prevention: Design protocols to ensure deadlocks never occur (e.g., acquire locks in a
predefined order).
- Deadlock Detection: Allow deadlocks to occur but detect them using wait-for graphs and resolve
by aborting one transaction.
- Deadlock Recovery: Abort one or more transactions and release their locks to break the
deadlock.

Conclusion: Deadlocks are common in database systems but can be handled effectively using
detection, prevention, or recovery strategies.

You might also like