Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.
-
date post
21-Dec-2015 -
Category
Documents
-
view
215 -
download
0
Transcript of Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.
![Page 1: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/1.jpg)
Chapters 20
Transaction Management
![Page 2: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/2.jpg)
Agenda
• Transaction
• Concurrent Processing
• Backup and Recovery
![Page 3: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/3.jpg)
Transaction - I
• Definition– An action or actions to red or update the
contents of the database
• Types– Committed– Aborted (rolled back or undone)– Compensating
![Page 4: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/4.jpg)
Transaction - II
• Property of Transactions (ACID)– Atomicity (all or nothing)– Consistency (state)– Isolation (independent)– Durability (permanent)
![Page 5: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/5.jpg)
Concurrent Processing
• Definition
• Problems
• Control
![Page 6: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/6.jpg)
Concurrent Processing
• Multiprogramming
• Interleaved between two transactions– CPU– I/O
• Logical unit of work
![Page 7: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/7.jpg)
Concurrent Processing Problem
• No problem– Write different data– Update different data– Read the same data
• Problem– Write the same data– Update the same data
![Page 8: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/8.jpg)
Concurrent Processing Problems
• Lost update– Two transactions simultaneously update the same files
• Uncommitted update– Transaction 2 uses the result updated by transaction 1
– Transaction 1 aborts and rolls back
– Transaction 2 commits
• Inconsistent Analysis– Transaction 1 reads
– Transaction 2 reads and uses for calculation
– Transaction 1 updates and commits
– Transaction 2 updates and commits
![Page 9: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/9.jpg)
SERIALIZABILITY
• Transaction results form concurrent processing are the same as if stand-alone sequential processing was used
• Ensure no anomalies arise from concurrent processing
![Page 10: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/10.jpg)
Concurrency Control
• Locking
• Deadlock
• Two-phase locking
• Timestamping
• Optimistic technique
![Page 11: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/11.jpg)
Locking
• Types– Shared Locks vs. Exclusive Locks– Read Locks vs. Write Locks– Upgrade vs. Downgrade
• Granularity– Database– file– page– record– field
![Page 12: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/12.jpg)
Deadlock
• Definition– Tow or more transactions each wait for locks held by
other transaction
– Livelock
• Control– Wait-Die
– Wound-wait
– Time out
– Conservative 2PL
![Page 13: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/13.jpg)
Two-phase Locking
• Growing phase– Get all locks– Upgrade locks
• Shrinking phase– Downgrade locks– Once starting to release a lock - no more new
locks
![Page 14: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/14.jpg)
Timestamping
• Timestamp– unique identifier as relative starting time of a
transaction– Read-timestamp & write timestamp
• Timestamp protocol– Transactions with smaller timestamps get
priority in the event of conflict– Transaction is only allowed on the item with
smaller read-timestamp or write timestamp
![Page 15: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/15.jpg)
Optimistic Technique
• Read phase
• Validate phase
• Write phase
![Page 16: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/16.jpg)
Database Recovery
• Definition– Restoring the database to its correct state in the event
of a failure
• Reasons– Physical (fire, flood, etc.)– Sabotage– Carelessness– Hardware– Software (application/system)
![Page 17: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/17.jpg)
Database Backup
• Backup– Copy of the database
• Transaction log– Transaction ID, time, operation, object, before
image, after image, prior pointer, next pointer
• Checkpoint– Synchronize transaction log and the database– Write data from buffers to database on the disk– Write checkpoint to log identify current
transaction(s)
![Page 18: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/18.jpg)
Recovery Methods
• Reprocessing– Record all transactions since last backup and
replay those transactions
• Rollforward– Use the transaction log to change any
committed transactions on the database or since last checkpoint
• Rollback– Use transaction log to undo any aborted
transactions
![Page 19: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/19.jpg)
Shadow Paging Method
• Current page table vs. Shadow page table
• Pros & cons– Faster– Less overhead– Data fragmentation– Reclaim inaccessible blocks
![Page 20: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/20.jpg)
Points To Remember
• Properties of Transaction
• Concurrent Processing
• Backup and Recovery
![Page 21: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/21.jpg)
Assignments
• Review chapters 5-6, 11-20, and 25-27• Read chapter• Exam 3
– Date:• Project
– Due date:– Place:
![Page 22: Chapters 20 Transaction Management. Agenda Transaction Concurrent Processing Backup and Recovery.](https://reader030.fdocuments.us/reader030/viewer/2022032801/56649d555503460f94a3269b/html5/thumbnails/22.jpg)
End of MIS150
• Exam date:
• Study! Study! Study!
• Have a happy and safe summer!!