Lec 7
Lec 7
Lec 7
MANAGEMENT
SYSTEM
LECTURE#7
Transaction process
Example:
If in the above transaction, the debit transaction fails
after executing operation 2 then X’s value will remain
4000 in the database that is not acceptable by bank.
To solve this, we have two important functions:
Commit: It is used to save the work done permanently.
Rollback: It is used to undo the work done.
Transaction properties
Atomicity Consistency
• Before the transaction start
Either all
• After the transaction end
success or none
• Sum of all money should
equal
Durability
Isolation
Transaction is
Ensure that transaction is commited and store
isolated from other it permanent
transaction
Atomicity
Abort: If a transaction aborts then all the changes made are not
visible.
Commit: If a transaction commits then all the changes made are
visible
Read(a)=600 Read(B)=400
A=A-100 A=B+100
W(A)=500 W(B)=500
Consistency
Active state:
The active state is the first state of every transaction. In
this state, the transaction is being executed.
For example: Insertion or deletion or updating a record is
done here. But all the records are still not saved to the
database.
Partially committed:
In the partially committed state, a transaction
executes its final operation, but the data is still not
saved to the database.
In the total mark calculation
Example: A final display of the total marks step is
executed in this state.
States of transaction
Committed:
A transaction is said to be in a committed state if it
executes all its operations successfully. In this state, all
the effects are now permanently saved on the
database system.
Failed state:
If any of the checks made by the database recovery
system fails, then the transaction is said to be in the
failed state.
In the example of total mark calculation, if the
database is not able to fire a query to fetch the marks,
then the transaction will fail to execute.
States of transaction
Aborted:
If any of the checks fail and the transaction has reached
a fail state then the database recovery system will make
sure that the database is in its previous consistent state. If
not then it will abort or roll back the transaction to bring
the database into a consistent state.
If the transaction fails in the middle of the transaction then
before executing the transaction, all the executed
transactions are rolled back to its consistent state.
After aborting the transaction, the database recovery
module will select one of the two operations:
• Re-start the transaction
• Kill the transaction
Schedule
(A)
T1 T2
Read (A);
A:=A-N;
Write(A);
Time Read (B);
B:=B+N;
Write(B);
Read (A);
A:=A+M;
Write(A);
Schedule A
Serial Schedule
(B)
T1 T2
Read (A);
A:=A+M;
Write(A);
Time Read (A);
A:=A-N;
Write(A);
Read (B);
B:=B+N;
Write(B);
Schedule B
Non-serial schedule
(C)
T1 T2
Read (A);
A:=A-N;
Read (A);
Time Write(A); A:=A+M;
Read (B);
Write(A);
B:=B+N;
Write(B);
Schedule C
Thank You