0% found this document useful (0 votes)
6 views7 pages

Transaction MGT 2

Transaction failures can occur due to logical errors, system crashes, or deadlocks, and handling these failures involves aborting transactions and rolling back changes. Recovery techniques like log-based recovery and shadow paging ensure database consistency after failures. Concurrency control is essential for executing multiple transactions simultaneously without issues such as lost updates or dirty reads, with techniques like lock-based protocols ensuring serializability.

Uploaded by

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

Transaction MGT 2

Transaction failures can occur due to logical errors, system crashes, or deadlocks, and handling these failures involves aborting transactions and rolling back changes. Recovery techniques like log-based recovery and shadow paging ensure database consistency after failures. Concurrency control is essential for executing multiple transactions simultaneously without issues such as lost updates or dirty reads, with techniques like lock-based protocols ensuring serializability.

Uploaded by

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

Transaction

management-II
Transaction Failure
Transaction Failure
A transaction failure occurs when a transaction cannot complete
successfully due to errors, system crashes, or conflicts. Types of failures
include:
• Logical Errors: Incorrect data, integrity constraint violations, or
deadlocks.
• System Crashes: Hardware/software failures, power outages.
• Deadlocks: Multiple transactions waiting indefinitely for each other’s
locks.

Handling Transaction Failures


• Abort: Terminate the transaction and undo its changes.
• Rollback: Restore the database to a consistent state before the transaction started.
Recovery Techniques
Recovery ensures database consistency after failures.
Key methods include:
Log-Based Recovery (Write-Ahead Logging - WAL)
• Undo (Rollback): Reverse uncommitted changes using logs.
• Redo (Roll forward): Reapply committed changes after a
crash.
• Checkpointing: Periodically saves the database state to
minimize recovery time.

Shadow Paging
• Maintains two copies of the database (current and shadow).
• Changes are made in the shadow copy; only committed
changes replace the current copy.
Concurrency Control in Databases
Concurrency control ensures correct execution of multiple
transactions simultaneously while maintaining ACID
properties.
Problems Due to Lack of Concurrency Control
• Lost Update: Two transactions overwrite each other’s
changes.
• Dirty Read: A transaction reads uncommitted data from
another transaction.
• Non-Repeatable Read: A transaction reads the same data
twice but gets different values.
• Phantom Read: New rows appear in a re-executed query.
Concurrency Control Techniques
Lock-Based Protocols
• Shared Lock (S-lock): Allows multiple transactions to read
but not write.
• Exclusive Lock (X-lock): Allows only one transaction to
read/write.
• Two-Phase Locking (2PL): Ensures serializability by dividing
transactions into growing (acquire locks) and shrinking
(release locks) phases.
Example (2PL)
Consider two transactions T1​and T2​:
Correct 2PL Execution:
• T1​acquires X-lock on A (Growing Phase).
• T1​writes A.
• T1​acquires X-lock on B (still Growing Phase).
• T1​writes B.
• T1​releases X-lock on A (Shrinking Phase begins).
• T1​releases X-lock on B and commits.

• This follows 2PL and is serializable.

You might also like