490 likes | 996 Views
Long-duration transactions. Long-duration transactions. Long-duration transactions = Long transactions = Long-lived transactions = Design transactions =. Long-duration transactions. Long-duration transaction ? What is it ?. Long-duration transactions.
E N D
Long-duration transactions Long-duration transactions = Long transactions = Long-lived transactions = Design transactions = ...
Long-duration transactions • Long-duration transaction ? What is it ?
Long-duration transactions • Long-duration transaction ? What is it ? Long duration transaction is a transaction that accesses a large number of data items and whose execution takes minutes or even hours
Long-duration transactions • Properties of LD transactions
Long-duration transactions • Properties of LD transactions • long duration • access to many database objects • direct input from users
Long-duration transactions • Properties of LD transactions • long duration • access to many database objects • direct input from users Examples • schedule generation • processing purchase orders, or insurance claims • printing monthly account statement in a bank • restructuring a complex data structure in CAD
Long-duration transactions • Problems with LD transactions
Long-duration transactions • Problems with LD transactions • performance • locks should be retained for long periods • expensive rollbacks
Long-duration transactions • Solutions
Long-duration transactions • Solutions • Decomposition of LDT into series of shorter transactions
Long-duration transactions • Solutions • Decomposition of LDT into series of shorter transactions • Use of multiversion data
Long-duration transactions • Solutions • Decomposition of LDT into series of shorter transactions • Use of multiversion data • Restriction of transaction access patterns
Long-duration transactions • Solutions • Decomposition of LDT into series of shorter transactions • Use of multiversion data • Restriction of transaction access patterns • Protocols based on constrained shared locks
Long-duration transactions • Solutions • Decomposition of LDT into series of shorter transactions • Use of multiversion data • Restriction of transaction access patterns • Protocols is based on constrained shared locks • Non-locking protocols
Long-duration transactions • Sagas Garcia-Molina H., Salem K. Sagas, SIGMOD Record, vol. 16, no. 3, 1987
Long-duration transactions • Principles • Saga is a LD transaction which is broken into a collection of subtransactions T1, ..., Tn in such a way that each one of subtransactions can be interleaved in any way with any other transactions
Long-duration transactions • Principles • Saga is a LD transaction which is broken into a collection of subtransactions T1, ..., Tn in such a way that each one of subtransactions can be interleaved in any way with any other transactions • Saga is a two-level nested transaction where each subtransaction must preserve a local database consistency, i.e. its concurrent execution must be conflict serializable
Long-duration transactions • Principles • Every saga is either completed or it is compensated
Long-duration transactions • Principles • Every saga is either completed or it is compensated • Instead of rollback and cascading abort the user supplied compensation functions are executed to compensate for each transaction that failed or was aborted
Long-duration transactions • Principles • Every saga is either completed or it is compensated • Instead of rollback and cascading abort the user supplied compensation functions are executed to compensate for each transaction that failed or was aborted • Compensation function reverses the actions performed by a transaction from a semantic point of view, e.g. reservation of a seat may be cancelled by a compensation function
Long-duration transactions • Principles • Subtransactions in a saga are related one to each other and should be executed as non-atomic unit
Long-duration transactions • Principles • Subtransactions in a saga are related one to each other and should be executed as non-atomic unit • Any partial execution of a saga is undesirable
Long-duration transactions • Principles • Subtransactions in a saga are related one to each other and should be executed as non-atomic unit • Any partial execution of a saga is undesirable • Each subtransaction T1, ..., Tn as an associated compensating transaction C1, ..., Cn
Long-duration transactions • Principles • Compensating transaction C is a transaction that semantically undos the effects of transaction T after T has been committed or aborted
Long-duration transactions • Principles • Compensating transaction C is a transaction that semantically undos the effects of transaction T after T has been committed or aborted • To execute a saga, the system must guarantee that either a sequence T1, ..., Tn (success) or a sequence T1, ..., Tk, Ck, ..., C1 will be executed (failure)
Long-duration transactions • Structure of saga
Long-duration transactions • Structure of saga begin saga begin transaction T1 ... end transaction T1 begin transaction T2 ... end transaction T2 ... begin transaction Tn ... end transaction Tn end saga
Long-duration transactions • Elementary operations of sagas
Long-duration transactions • Elementary operations of sagas • begin saga - starts execution of a saga
Long-duration transactions • Elementary operations of sagas • begin saga - starts execution of a saga • begin transaction - starts execution of any subtransaction and provides an address of respective compensating transaction
Long-duration transactions • Elementary operations of sagas • begin saga - starts execution of a saga • begin transaction - starts execution of any subtransaction and provides an address of respective compensating transaction • end transaction - ends execution of any subtransaction
Long-duration transactions • Elementary operations of sagas • begin saga - starts execution of a saga • begin transaction - starts execution of any subtransaction and provides an address of respective compensating transaction • end transaction - ends execution of any subtransaction • end saga - ends execution of a saga
Long-duration transactions • Elementary operations of sagas • abort transaction - aborts current transaction and initiates execution of its compensating transaction
Long-duration transactions • Elementary operations of sagas • abort transaction - aborts current transaction and initiates execution of its compensating transaction • abort saga - aborts current subtransaction, runs a sequence of compensating transactions in reverse order of transaction execution
Long-duration transactions • Elementary operations of sagas • abort transaction - aborts current transaction and initiates execution of its compensating transaction • abort saga - aborts current subtransaction, runs a sequence of compensating transactions in reverse order of transaction execution • save point - forces a system to save the current status of a running saga and returns a save point identifier for future references
Long-duration transactions • Recovery protocols
Long-duration transactions • Recovery protocols • Backward recovery when aborted transaction is compensated to its start point and saga is continued from the aborted transaction
Long-duration transactions • Recovery protocols • Backward recovery when aborted transaction is compensated to its start point and saga is continued from the aborted transaction • Forward recovery when aborted transaction is compensated to a save point different that its start point and saga is continued from the next transaction
Long-duration transactions • Properties
Long-duration transactions • Properties • Sagas relax the property of isolation by allowing its subtransactions to reveal their partial results one to each other
Long-duration transactions • Properties • Sagas relax the property of isolation by allowing its subtransactions to reveal their partial results one to each other • Sagas preserve the properties of atomicity, consistency and durability
Long-duration transactions • Properties • Sagas relax the property of isolation by allowing its subtransactions to reveal their partial results one to each other • Sagas preserve the properties of atomicity, consistency and durability • Sagas solve the problem of LD transactions by allowing its subtransactions to release the partial results before completion of a whole task
Long-duration transactions • Properties • Sagas are useful only when subtransactions are relatively independent, and each transaction may be compensated
Long-duration transactions • Properties • Sagas are useful only when subtransactions are relatively independent, and each transaction may be compensated • Sagas are useless in the environments where LLTs are not compensable, e.g. a transaction that fires a missile or transaction that dispenses cash from ATM are hardly compensable