Your SlideShare is downloading. ×
0321210255 Ch20 Transaction C
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

0321210255 Ch20 Transaction C


Published on

Published in: Technology, Business

1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Granularity of Data Items
    • Size of data items chosen as unit of protection by concurrency control protocol.
    • Ranging from coarse to fine:
      • The entire database.
      • A file.
      • A page (or area or database spaced).
      • A record.
      • A field value of a record.
    © Pearson Education Limited 1995, 2005
  • 2. Granularity of Data Items
    • Tradeoff:
      • coarser, the lower the degree of concurrency;
      • finer, more locking information that is needed to be stored.
    • Best item size depends on the types of transactions.
    © Pearson Education Limited 1995, 2005
  • 3. Hierarchy of Granularity
    • Could represent granularity of locks in a hierarchical structure.
    • Root node represents entire database, level 1s represent files, etc.
    • When node is locked, all its descendants are also locked.
    • DBMS should check hierarchical path before granting lock.
    © Pearson Education Limited 1995, 2005
  • 4. Hierarchy of Granularity
    • Intention lock could be used to lock all ancestors of a locked node.
    • Intention locks can be read or write. Applied top-down, released bottom-up.
    © Pearson Education Limited 1995, 2005
  • 5. Levels of Locking © Pearson Education Limited 1995, 2005
  • 6. Database Recovery
    • Process of restoring database to a correct state in the event of a failure.
    • Need for Recovery Control
      • Two types of storage: volatile (main memory) and nonvolatile.
      • Volatile storage does not survive system crashes.
      • Stable storage represents information that has been replicated in several nonvolatile storage media with independent failure modes.
    © Pearson Education Limited 1995, 2005
  • 7. Types of Failures
    • System crashes, resulting in loss of main memory.
    • Media failures, resulting in loss of parts of secondary storage.
    • Application software errors.
    • Natural physical disasters.
    • Carelessness or unintentional destruction of data or facilities.
    • Sabotage.
    © Pearson Education Limited 1995, 2005
  • 8. Transactions and Recovery
    • Transactions represent basic unit of recovery.
    • Recovery manager responsible for atomicity and durability.
    • If failure occurs between commit and database buffers being flushed to secondary storage then, to ensure durability, recovery manager has to redo ( rollforward ) transaction’s updates.
    © Pearson Education Limited 1995, 2005
  • 9. Transactions and Recovery
    • If transaction had not committed at failure time, recovery manager has to undo ( rollback ) any effects of that transaction for atomicity.
    • Partial undo - only one transaction has to be undone.
    • Global undo - all transactions have to be undone.
    © Pearson Education Limited 1995, 2005
  • 10. Example
    • DBMS starts at time t 0 , but fails at time t f . Assume data for transactions T 2 and T 3 have been written to secondary storage.
    • T 1 and T 6 have to be undone. In absence of any other information, recovery manager has to redo T 2 , T 3 , T 4 , and T 5 .
    © Pearson Education Limited 1995, 2005
  • 11. Recovery Facilities
    • DBMS should provide following facilities to assist with recovery:
      • Backup mechanism, which makes periodic backup copies of database.
      • Logging facilities, which keep track of current state of transactions and database changes.
      • Checkpoint facility, which enables updates to database in progress to be made permanent.
      • Recovery manager, which allows DBMS to restore database to consistent state following a failure.
    © Pearson Education Limited 1995, 2005
  • 12. Log File
    • Contains information about all updates to database:
      • Transaction records.
      • Checkpoint records.
    • Often used for other purposes (for example, auditing).
    © Pearson Education Limited 1995, 2005
  • 13. Log File
    • Transaction records contain:
      • Transaction identifier.
      • Type of log record, (transaction start, insert, update, delete, abort, commit).
      • Identifier of data item affected by database action (insert, delete, and update operations).
      • Before-image of data item.
      • After-image of data item.
      • Log management information.
    © Pearson Education Limited 1995, 2005
  • 14. Sample Log File © Pearson Education Limited 1995, 2005
  • 15. Log File
    • Log file may be duplexed or triplexed.
    • Log file sometimes split into two separate random-access files.
    • Potential bottleneck; critical in determining overall performance.
    © Pearson Education Limited 1995, 2005
  • 16. Checkpointing
      • Checkpoint
      • Point of synchronization between database and log file. All buffers are force-written to secondary storage.
    • Checkpoint record is created containing identifiers of all active transactions.
    • When failure occurs, redo all transactions that committed since the checkpoint and undo all transactions active at time of crash.
    © Pearson Education Limited 1995, 2005
  • 17. Checkpointing
    • In previous example, with checkpoint at time t c , changes made by T 2 and T 3 have been written to secondary storage.
    • Thus:
      • only redo T 4 and T 5 ,
      • undo transactions T 1 and T6.
    © Pearson Education Limited 1995, 2005
  • 18. Recovery Techniques
    • If database has been damaged:
      • Need to restore last backup copy of database and reapply updates of committed transactions using log file.
    • If database is only inconsistent:
      • Need to undo changes that caused inconsistency. May also need to redo some transactions to ensure updates reach secondary storage.
      • Do not need backup, but can restore database using before- and after-images in the log file.
    © Pearson Education Limited 1995, 2005
  • 19. Main Recovery Techniques
    • Three main recovery techniques:
      • Deferred Update
      • Immediate Update
      • Shadow Paging
    © Pearson Education Limited 1995, 2005
  • 20. Deferred Update
    • Updates are not written to the database until after a transaction has reached its commit point.
    • If transaction fails before commit, it will not have modified database and so no undoing of changes required.
    • May be necessary to redo updates of committed transactions as their effect may not have reached database.
    © Pearson Education Limited 1995, 2005
  • 21. Immediate Update
    • Updates are applied to database as they occur.
    • Need to redo updates of committed transactions following a failure.
    • May need to undo effects of transactions that had not committed at time of failure.
    • Essential that log records are written before write to database. Write-ahead log protocol .
    © Pearson Education Limited 1995, 2005
  • 22. Immediate Update
    • If no “ transaction commit ” record in log, then that transaction was active at failure and must be undone.
    • Undo operations are performed in reverse order in which they were written to log .
    © Pearson Education Limited 1995, 2005
  • 23. Shadow Paging
    • Maintain two page tables during life of a transaction: current page and shadow page table.
    • When transaction starts, two pages are the same.
    • Shadow page table is never changed thereafter and is used to restore database in event of failure.
    • During transaction, current page table records all updates to database.
    • When transaction completes, current page table becomes shadow page table.
    © Pearson Education Limited 1995, 2005
  • 24. Advanced Transaction Models
    • Protocols considered so far are suitable for types of transactions that arise in traditional business applications, characterized by:
      • Data has many types, each with small number of instances.
      • Designs may be very large.
      • Design is not static but evolves through time.
      • Updates are far-reaching.
      • Cooperative engineering.
    © Pearson Education Limited 1995, 2005
  • 25. Advanced Transaction Models
    • May result in transactions of long duration, giving rise to following problems:
      • More susceptible to failure - need to minimize amount of work lost.
      • May access large number of data items - concurrency limited if data inaccessible for long periods.
      • Deadlock more likely.
      • Cooperation through use of shared data items restricted by traditional concurrency protocols.
    © Pearson Education Limited 1995, 2005
  • 26. Advanced Transaction Models
    • Look at five advanced transaction models:
      • Nested Transaction Model
      • Sagas
      • Multi-level Transaction Model
      • Dynamic Restructuring
      • Workflow Models
    © Pearson Education Limited 1995, 2005
  • 27. Nested Transaction Model
    • Transaction viewed as hierarchy of subtransactions.
    • Top-level transaction can have number of child transactions.
    • Each child can also have nested transactions.
    • In Moss’s proposal, only leaf-level subtransactions allowed to perform database operations.
    • Transactions have to commit from bottom upwards.
    • However, transaction abort at one level does not have to affect transaction in progress at higher level.
    © Pearson Education Limited 1995, 2005
  • 28. Nested Transaction Model
    • Parent allowed to perform its own recovery:
      • Retry subtransaction.
      • Ignore failure, in which case subtransaction non-vital.
      • Run contingency subtransaction.
      • Abort.
    • Updates of committed subtransactions at intermediate levels are visible only within scope of their immediate parents.
    © Pearson Education Limited 1995, 2005
  • 29. Nested Transaction Model
    • Further, commit of subtransaction is conditionally subject to commit or abort of its superiors.
    • Using this model, top-level transactions conform to traditional ACID properties of flat transaction.
    © Pearson Education Limited 1995, 2005
  • 30. Example of Nested Transactions © Pearson Education Limited 1995, 2005
  • 31. Nested Transaction Model - Advantages
    • Modularity - transaction can be decomposed into number of subtransactions for purposes of concurrency and recovery.
    • Finer level of granularity for concurrency control and recovery.
    • Intra-transaction parallelism.
    • Intra-transaction recovery control.
    © Pearson Education Limited 1995, 2005
  • 32. Emulating Nested Transactions using Savepoints
    • An identifiable point in flat transaction representing some partially consistent state.
    • Can be used as restart point for transaction if subsequent problem detected.
    • During execution of transaction, user can establish savepoint, which user can use to roll transaction back to.
    • Unlike nested transactions, savepoints do not support any form of intra-transaction parallelism.
    © Pearson Education Limited 1995, 2005
  • 33. Sagas
    • “ A sequence of (flat) transactions that can be interleaved with other transactions”.
    • DBMS guarantees that either all transactions in saga are successfully completed or compensating transactions are run to undo partial execution.
    • Saga has only one level of nesting.
    • For every subtransaction defined, there is corresponding compensating transaction that will semantically undo subtransaction’s effect.
    © Pearson Education Limited 1995, 2005
  • 34. Sagas
    • Relax property of isolation by allowing saga to reveal its partial results to other concurrently executing transactions before it completes.
    • Useful when subtransactions are relatively independent and compensating transactions can be produced.
    • May be difficult sometimes to define compensating transaction in advance, and DBMS may need to interact with user to determine compensation.
    © Pearson Education Limited 1995, 2005
  • 35. Multi-level Transaction Model
    • Closed nested transaction - atomicity enforced at the top-level.
    • Open nested transactions - allow partial results of subtransactions to be seen outside transaction.
    • Saga model is example of open nested transaction.
    • So is multi-level transaction model where tree of subtransactions is balanced.
    • Nodes at same depth of tree correspond to operations of same level of abstraction in DBMS.
    © Pearson Education Limited 1995, 2005
  • 36. Multi-level Transaction Model
    • Edges represent implementation of an operation by sequence of operations at next lower level.
    • Traditional flat transaction ensures no conflicts at lowest level (L0).
    • In multi-level model two operations at level L i may not conflict even though their implementations at next lower level L i-1 do.
    © Pearson Education Limited 1995, 2005
  • 37. Example - Multi-level Transaction Model © Pearson Education Limited 1995, 2005
  • 38. Example - Multi-level Transaction Model
      • T 7 : T 71 , which increases bal x by 5
      • T 72 , which subtracts 5 from bal y
      • T 8 : T 81 , which increases bal y by 10
      • T 82 , which subtracts 2 from bal x
    • As addition and subtraction commute, can execute these subtransactions in any order, and correct result will always be generated.
    © Pearson Education Limited 1995, 2005
  • 39. Dynamic Restructuring
    • To address constraints imposed by ACID properties of flat transactions, two new operations proposed: split_transaction and join_transaction.
    • split-transaction - splits transaction into two serializable transactions and divides its actions and resources (for example, locked data items) between new transactions.
    • Resulting transactions proceed independently.
    © Pearson Education Limited 1995, 2005
  • 40. Dynamic Restructuring
    • Allows partial results of transaction to be shared, while still preserving its semantics.
    • Can be applied only when it is possible to generate two transactions that are serializable with each other and with all other concurrently executing transactions.
    © Pearson Education Limited 1995, 2005
  • 41. Dynamic Restructuring
    • Conditions that permit transaction to be split into A and B are:
      • . AWriteSet  BWriteSet  BWriteLast.
      • If both A and B write to same object, B’s write operations must follow A’s write operations.
      • . AReadSet  BWriteSet =  .
      • A cannot see any results from B.
      • . BReadSet  AWriteSet = ShareSet.
      • B may see results of A.
    © Pearson Education Limited 1995, 2005
  • 42. Dynamic Restructuring
    • These guarantee that A is serialized before B.
    • However, if A aborts, B must also abort.
    • If both BWriteLast and ShareSet are empty, then A and B can be serialized in any order and both can be committed independently.
    © Pearson Education Limited 1995, 2005
  • 43. Dynamic Restructuring
    • join-transaction - performs reverse operation, merging ongoing work of two or more independent transactions, as though they had always been single transaction.
    © Pearson Education Limited 1995, 2005
  • 44. Dynamic Restructuring
    • Main advantages of dynamic restructuring are:
      • Adaptive recovery.
      • Reducing isolation.
    © Pearson Education Limited 1995, 2005
  • 45. Workflow Models
    • Has been argued that above models are still not powerful to model some business activities.
    • More complex models have been proposed that are combinations of open and nested transactions.
    • However, as they hardly conform to any of ACID properties, called workflow model used instead.
    • Workflow is activity involving coordinated execution of multiple tasks performed by different processing entities (people or software systems).
    © Pearson Education Limited 1995, 2005
  • 46. Workflow Models
    • Two general problems involved in workflow systems:
      • specification of the workflow,
      • execution of the workflow.
    • Both problems complicated by fact that many organizations use multiple, independently managed systems to automate different parts of the process.
    © Pearson Education Limited 1995, 2005