310 likes | 462 Views
Transactions. Definition . Transaction is a set of instructions or operations that perform a logical function. Transa ction model. Satu State konsisten. Satu State konsisten. Satu State inkonsisten. Eksekusi Transaksi Ti. Mulai Transaksi Ti. Akhir Transaksi Ti.
E N D
Definition • Transaction is a set of instructions or operations that perform a logical function.
Transaction model Satu State konsisten Satu State konsisten Satu State inkonsisten EksekusiTransaksi Ti MulaiTransaksi Ti AkhirTransaksi Ti • When transaction system can be in an inconsistent state, but in the end systems in a consistent state again. Transactions never left the state in an inconsistent state
Transaction goal • concurrent • Failure handling
Feature Transaction • A tomicity • C onsistent • I solated • D urable • (ACID)
Atomicity • ach transaction can not be in for • "All or nothing deal" • If the transaction fails, the system responsible for the failure recovery
Atomicity • Examples in the case of money transfers between accounts. will be conducted at least two operations, namely • debit on the sender's account • credit on the recipient's account. • Each of these operations must be executed to keep the overall data on the recipient and sender of money consistently.
Consistency • Consistency is the truth of the system transactions. • A transaction that actually change the system from one consistent state into another consistent state
Isolation • A separate transaction with each other. • Unfinished transactions can not show the results to other transactions before the transaction commit.
Durability • When a transaction commits, the system will guarantee the results of operations will continue.
With the nature of atomicity, a transaction can be executed as a whole certainly • if there is system crash all data that has been modified by the transaction is returned to the initial state. • Consistent initial state will be changed into another state which is also consistent after a transaction has executed successfully. • With the nature of isolation can also be said of each scheduleisSerializable, which will be discussed in the serialization. Every time a transaction has been successfully implemented will be guaranteed that the result of data updates will be maintained.
Concurrent handling • Transaction is a unit of consistency (feature) • Transactions can walk one by one in sequence.But less efficient. • Full competition aims to optimize the system while maintaining the consistency of the system with a high degree of competition
Serializability • Criteria truth competition control algorithm. • Results Parallel = serial
Full lock-based concurrence • One way of ensuring serializability is a data access mutex = locking. • Mode lock • Shared lock • Exclusive lock
Shared lock / read lock • If a transaction Ti is doing shared-mode lock on the data Q, the transaction will be able to read operations on the Q but can not perform write operations on the Q
Exclusive Lock • If a transaction Ti is doing exclusive-mode lock on the data Q, then the transaction can read and write on the Q. • Other transactions can not lock any of the objects that have been in the exclusive lock
Q data access of a transaction Ti • Q Check if the data is locked by another transaction. If not, Ti can directly access the Q, if yes, Ti must wait (wait). • If the desired lock mode is exclusive-lock mode, then Ti must wait until the Q data was released. • If the desired lock mode is shared-lock mode, then Ti must wait until the data is not in Q-mode exclusive lock by other data. In this case Q data can be accessed when in idle mode or shared-lock.
Two-phase LockingProtocol • Growing phase • Phase in which a transaction may only do locking on the data. In this phase, the transaction may not release the other data. • Shrinking phase • Phase in which a transaction to release the data. In this phase, the transaction may not lock on other data.
Two-phase LockingProtocol • Two-phase locking protocol widely used to maintain the properties of a schedulingSerializable, but this protocol can not guarantee that deadlock will not occur because there are still transactions in the state of waiting (wait ()).
Full competition with ordering time (timestamp) • Not manage to serializabiltymutex but with the time line. • Property timestamp • Uniquness • Unique, different from one another • Monotonicity • Timestamp value increases monotonically
TimeStamp Rules O ij is executed before O kl if and only if Timestamp (Ti) < Timestamp(Tk), T i is a transaction older than T k.
Memory • Memory is divided into three: • The main memory (volatile memory) • Secondary storage (memory nonVolatile) • Storage stability (stable storage)
Memory • Main Memory • Information on the main memory can not survive when the crashoccurred on the system. Quick access • Secondary Storage • Information can survive in the event of system crashes.
Memory • Storage Stable (Stable storage) • Information on these storage small chance to lose. • Implementation is done by replication of information on some secondary storage (mirroring)
Recovery • Recovery of the event cancellation of the transaction (abort recovery) • Recovery of menglami system crash (crash recovery) • Terhadapa recovery storage media failure(media recovery)
Abort recovery • Update = read and modify the system • Read = just read the system • Commit = makes all modifications to the system to be permanent • Abort = cancel action has been done • Approachupdate-in-place • Defferred-update approach
Update-in-Place • Update -rekord undo record in the log file • Read - read the value of objects in the system • Commit - ignoring the log file undo • Abort -rekord use undo to restore the system to its original state.
Deffered-Update • Update - recording a redo record in redo log file • Read - combining redo log files and system for determining the value of the object • Commit - update the system by applying the redo log files • Abort - ignore the redo log files