SlideShare a Scribd company logo
1 of 26
Transaction Processing
Concept
UNIT IV
NISHANT KUMAR
Transaction
A transaction can be defined as a group of tasks. A single task is the minimum processing unit
which cannot be divided further.
Let’s take an example of a simple transaction. Suppose a bank employee transfers Rs 500 from
A's account to B's account. This very simple and small transaction involves several low-level
tasks.
Open_Account(A)
Old_Balance = A.balance
New_Balance = Old_Balance - 500
A.balance = New_Balance
Close_Account(A)
Open_Account(B)
Old_Balance = B.balance
New_Balance = Old_Balance + 500
B.balance = New_Balance
Close_Account(B)
ACID Properties
A transaction is a very small unit of a program and it may contain several low level tasks. A
transaction in a database system must maintain Atomicity, Consistency, Isolation, and Durability
− commonly known as ACID properties − in order to ensure accuracy, completeness, and data
integrity.
Atomicity:
◦ This property states that a transaction must be treated as an atomic unit, that is, either all of its
operations are executed or none. There must be no state in a database where a transaction is left
partially completed. States should be defined either before the execution of the transaction or after the
execution/abortion/failure of the transaction.
Consistency:
◦ The database must remain in a consistent state after any transaction. No transaction should have any
adverse effect on the data residing in the database. If the database was in a consistent state before the
execution of a transaction, it must remain consistent after the execution of the transaction as well.
…
Durability:
◦ The database should be durable enough to hold all its latest updates even if the system fails or restarts.
If a transaction updates a chunk of data in a database and commits, then the database will hold the
modified data. If a transaction commits but the system fails before the data could be written on to the
disk, then that data will be updated once the system springs back into action.
Isolation:
◦ In a database system where more than one transaction are being executed simultaneously and in
parallel, the property of isolation states that all the transactions will be carried out and executed as if it
is the only transaction in the system. No transaction will affect the existence of any other transaction.
Serializability
When multiple transactions are being executed by the operating system in a multiprogramming
environment, there are possibilities that instructions of one transactions are interleaved with
some other transaction.
Schedule:
◦ A chronological execution sequence of a transaction is called a schedule. A schedule can have many
transactions in it, each comprising of a number of instructions/tasks.
Serial Schedule:
◦ It is a schedule in which transactions are aligned in such a way that one transaction is executed first.
When the first transaction completes its cycle, then the next transaction is executed. Transactions are
ordered one after the other. This type of schedule is called a serial schedule, as transactions are
executed in a serial manner.
…
In a multi-transaction environment, serial schedules are considered as a benchmark.
The execution sequence of an instruction in a transaction cannot be changed, but two
transactions can have their instructions executed in a random fashion. This execution does no
harm if two transactions are mutually independent and working on different segments of data;
but in case these two transactions are working on the same data, then the results may vary. This
ever-varying result may bring the database to an inconsistent state.
To resolve this problem, we allow parallel execution of a transaction schedule, if its transactions
are either serializable or have some equivalence relation among them.
Equivalence Schedules
An equivalence schedule can be of the following types −
1. Result Equivalence
◦ If the two transactions generate same result after their execution then it is called as result equivalence.
For example, one transaction is updating the marks of Student X and the other transaction is to insert a
new student. Here both the transactions are totally independent and their order of execution does not
matter. Whichever order they are executed; the result is the same. Hence it is called result equivalence
transactions.
2. View Equivalence
3. Conflict Equivalence
View Equivalence
Two schedules are said to be view equivalence, if the transaction in one schedule is same as the one
in other. That means, both the transactions in two schedules perform same tasks.
For example, say schedule1 has transaction to insert new students into STUDENT table and second
schedule has the transaction to maintain the old student records in a new table called OLD_STUDENT.
In both the schedules student details are inserted, but different tables (it does not matter if it is same
table). Such schedules are called as view equivalence schedule.
For example −
◦ If T reads the initial data in S1, then it also reads the initial data in S2.
◦ If T reads the value written by J in S1, then it also reads the value written by J in S2.
◦ If T performs the final write on the data value in S1, then it also performs the final write on the data value in
S2.
Conflict Equivalence
Two schedules would be conflicting if they have the following properties −
◦ Both belong to separate transactions.
◦ Both accesses the same data item.
◦ At least one of them is "write" operation.
In this case both schedules will have different set of transactions, but they would be accessing
same data and one of the schedules will be inserting/updating the records. In this equivalence,
both the schedules will have conflicting set of transactions. Above example of updating the
marks of one student by one transaction and calculating the total marks at the same time is a
conflicting equivalence.
In all these cases if the transaction is serialized, then the issues can be resolved.
States of Transaction
• Active
• Partially Committed − When a transaction executes its final
operation, it is said to be in a partially committed state.
• Failed − A transaction is said to be in a failed state if any of the
checks made by the database recovery system fails. A failed
transaction can no longer proceed further.
• Aborted − If any of the checks fails and the transaction has
reached a failed state, then the recovery manager rolls back all
its write operations on the database to bring the database
back to its original state where it was prior to the execution of
the transaction. Transactions in this state are called aborted.
The database recovery module can select one of the two
operations after a transaction aborts −
• Re-start the transaction
• Kill the transaction
• Committed
Recovery and Atomicity
When the system recovers from a failure, it can restore the latest dump.
When a system crashes, it may have several transactions being executed and various
files opened for them to modify the data items.
Transactions are made of various operations, which are atomic in nature. But according
to ACID properties of DBMS, atomicity of transactions as a whole must be maintained,
that is, either all the operations are executed or none.
When a DBMS recovers from a crash, it should maintain the following −
◦ It should check the states of all the transactions, which were being executed.
◦ A transaction may be in the middle of some operation; the DBMS must ensure the atomicity of the
transaction in this case.
◦ It should check whether the transaction can be completed now or it needs to be rolled back.
◦ No transactions would be allowed to leave the DBMS in an inconsistent state.
…
There are two types of techniques, which can help a DBMS in recovering as well as maintaining
the atomicity of a transaction −
• Maintaining the logs of each transaction, and writing them onto some stable storage before
actually modifying the database.
• Maintaining shadow paging, where the changes are done on a volatile memory, and later, the
actual database is updated
Log-based Recovery
Log is a sequence of records, which maintains the records of actions performed by a transaction.
It is important that the logs are written prior to the actual modification and stored on a stable
storage media, which is failsafe.
The update log record describes a single database write:
1. Transaction Identifier 2. Data-item identifier 3. Old Value 4. New Value
Log-based recovery works as follows −
◦ The log file is kept on a stable storage media.
◦ <Tn, Start>: When a transaction enters the system and starts execution, it writes a log about it
◦ <Tn, X, V1, V2>: When the transaction modifies an item X, it write logs, It reads Tn has changed the
value of X, from V1 to V2.
◦ <Tn, commit>: When the transaction finishes.
…
Database can be modified using two approaches:
Deferred database modification −
The deferred-modification technique ensures transaction atomicity by recording all database
modifications in the log, but deferring all write operations of a transaction until the transaction
partially commits (i.e., once the final action of the transaction has been executed). Then the
information in the logs is used to execute the deferred writes. If the system crashes or if the
transaction aborts, then the information in the logs is ignored.
Immediate database modification −
The immediate-update technique allows database modifications to be output to the database
while the transaction is still in the active state. These modifications are called uncommitted
modifications. In the event of a crash or transaction failure, the system must use the old-value
field of the log records to restore the modified data items.
Recovery with Concurrent Transactions
When more than one transaction are being executed in parallel, the logs are interleaved. At the
time of recovery, it would become hard for the recovery system to backtrack all logs, and then
start recovering. To ease this situation, most modern DBMS use the concept of 'checkpoints'.
Checkpoint
Checkpoint is a mechanism where all the previous logs are removed from the system and stored
permanently in a storage disk.
Checkpoint declares a point before which the DBMS was in consistent state, and all the
transactions were committed.
Transaction Recovery
When a system with concurrent transactions crashes and recovers, it behaves in the following
manner −
• The recovery system reads the logs backwards from the end to the last checkpoint.
• It maintains two lists, an undo-list and a redo-list.
• If the recovery system sees a log with <Tn, Start> and <Tn, Commit> or just <Tn, Commit>, it puts the
transaction in the redo-list.
• If the recovery system sees a log with <Tn, Start> but no commit or abort log found, it puts the
transaction in undo-list.
• All the transactions in the undo-list are then undone and their logs are removed. All the
transactions in the redo-list and their previous logs are removed and then redone before saving
their logs.
Deadlock
A deadlock is a condition wherein two or more tasks are waiting
for each other in order to be finished but none of the task is
willing to give up the resources that other task needs. In this
situation no task ever gets finished and is in waiting state forever.
Deadlocks are not healthy for a system. In case a system is stuck
in a deadlock, the transactions involved in the deadlock are
either rolled back or restarted.
Deadlock Prevention
To prevent any deadlock situation in the system, the DBMS aggressively inspects all the
operations, where transactions are about to execute. The DBMS inspects the operations and
analyzes if they can create a deadlock situation. If it finds that a deadlock situation might occur,
then that transaction is never allowed to be executed.
There are deadlock prevention schemes that use timestamp ordering mechanism of transactions
in order to predetermine a deadlock situation.
• Wait Die Scheme
• Wound Wait Scheme
Wait-Die Scheme
This Deadlock prevention scheme as indicated by its name halts a transaction and terminates
any further transactions occurring after such that there is no deadlock.
Rules:
If a transaction is requesting a lock on the resource and is found to be of an older time stamp
than the transaction which has the resource locked, it is not terminated.
If a transaction is requesting a lock on the resource and is found to be of a younger time stamp
than the transaction which has the resource locked, it is terminated.
…
(1) If TS(Ti) < TS(Tj) − that is Ti, which is requesting a conflicting lock, is older than Tj − then Ti is
allowed to wait until the data-item is available.
(2) If TS(Ti) > TS(tj) − that is Ti is younger than Tj − then Ti dies. Ti is restarted later with a
random delay but with the same timestamp.
For example:
Suppose that transaction T22, T23, T24 have time-stamps 5, 10 and 15 respectively. If
T22requests a data item held by T23 then T22 will wait. If T24 requests a data item held by T23,
then T24 will be rolled back.
Wound-Wait Scheme
This Deadlock prevention scheme as indicated by its name halts any further transaction that
requests the resource.
If an older timestamp transaction is requesting a lock on the resource, it is not terminated and
made to wait for the resource to be available.
If a transaction is requesting a lock on the resource and is found to be of an older time stamp
than the transaction which is in line for the resource, it can terminate the younger transaction
and take over the resource. The time stamp with a younger time stamp is then rebooted.
The one thing that’s common in both the deadlock prevention schemes is that the transaction
that enters the system late and has a younger time stamp is aborted.
…
(1) If TS(Ti) < TS(Tj), then Ti forces Tj to be rolled back − that is Ti wounds Tj. Tj is restarted later
with a random delay but with the same timestamp.
(2) If TS(Ti) > TS(Tj), then Ti is forced to wait until the resource is available.
For example:
Suppose that Transactions T22, T23, T24 have time-stamps 5, 10 and 15 respectively . If
T22requests a data item held by T23, then data item will be pre-empted from T23 and T23 will
be rolled back. If T24 requests a data item held by T23, then T24 will wait.
Deadlock Avoidance
Deadlock avoidance mechanisms can be used to detect any deadlock
situation in advance. Methods like "wait-for graph" are available but they
are suitable for only those systems where transactions are lightweight
having fewer instances of resource.
Wait-for Graph
This is a simple method available to track if any deadlock situation may
arise. For each transaction entering into the system, a node is created.
When a transaction Ti requests for a lock on an item, say X, which is held
by some other transaction Tj, a directed edge is created from Ti to Tj. If Tj
releases item X, the edge between them is dropped and Ti locks the data
item.
The system maintains this wait-for graph for every transaction waiting for
some data items held by others. The system keeps checking if there's any
cycle in the graph.
…
Here, we can use any of the two following approaches −
First, do not allow any request for an item, which is already locked
by another transaction. This is not always feasible and may cause
starvation, where a transaction indefinitely waits for a data item and
can never acquire it.
The second option is to roll back one of the transactions. It is not
always feasible to roll back the younger transaction, as it may be
important than the older one. With the help of some relative
algorithm, a transaction is chosen, which is to be aborted. This
transaction is known as the victim and the process is known as
victim selection.
THANKS

More Related Content

What's hot

Log based and Recovery with concurrent transaction
Log based and Recovery with concurrent transactionLog based and Recovery with concurrent transaction
Log based and Recovery with concurrent transactionnikunjandy
 
File organization 1
File organization 1File organization 1
File organization 1Rupali Rana
 
Concurrent transactions
Concurrent transactionsConcurrent transactions
Concurrent transactionsSajan Sahu
 
Transaction Properties in database | ACID Properties
Transaction Properties in database | ACID PropertiesTransaction Properties in database | ACID Properties
Transaction Properties in database | ACID Propertiesnomanbarki
 
database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques Kalhan Liyanage
 
13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMSkoolkampus
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMSkoolkampus
 
Transactions and Concurrency Control
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency ControlDilum Bandara
 
File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating SystemJanki Shah
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSvampugani
 
Transaction Properties(ACID Properties)
Transaction Properties(ACID Properties)Transaction Properties(ACID Properties)
Transaction Properties(ACID Properties)Yaksh Jethva
 
Recovery Techniques and Need of Recovery
Recovery Techniques and   Need of RecoveryRecovery Techniques and   Need of Recovery
Recovery Techniques and Need of RecoveryPooja Dixit
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational modelChirag vasava
 
Operating system Dead lock
Operating system Dead lockOperating system Dead lock
Operating system Dead lockKaram Munir Butt
 

What's hot (20)

Log based and Recovery with concurrent transaction
Log based and Recovery with concurrent transactionLog based and Recovery with concurrent transaction
Log based and Recovery with concurrent transaction
 
File organization 1
File organization 1File organization 1
File organization 1
 
Concurrent transactions
Concurrent transactionsConcurrent transactions
Concurrent transactions
 
Acid properties
Acid propertiesAcid properties
Acid properties
 
Transaction Properties in database | ACID Properties
Transaction Properties in database | ACID PropertiesTransaction Properties in database | ACID Properties
Transaction Properties in database | ACID Properties
 
database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques
 
concurrency-control
concurrency-controlconcurrency-control
concurrency-control
 
Relational model
Relational modelRelational model
Relational model
 
Deadlock dbms
Deadlock dbmsDeadlock dbms
Deadlock dbms
 
13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMS
 
Query processing
Query processingQuery processing
Query processing
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
 
Transactions and Concurrency Control
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency Control
 
File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating System
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Transaction Properties(ACID Properties)
Transaction Properties(ACID Properties)Transaction Properties(ACID Properties)
Transaction Properties(ACID Properties)
 
Recovery Techniques and Need of Recovery
Recovery Techniques and   Need of RecoveryRecovery Techniques and   Need of Recovery
Recovery Techniques and Need of Recovery
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
Dbms acid
Dbms acidDbms acid
Dbms acid
 
Operating system Dead lock
Operating system Dead lockOperating system Dead lock
Operating system Dead lock
 

Similar to Transaction Processing Concept

TRANSACTION MANAGEMENT AND TIME STAMP PROTOCOLS AND BACKUP RECOVERY
TRANSACTION MANAGEMENT AND TIME STAMP PROTOCOLS AND BACKUP RECOVERYTRANSACTION MANAGEMENT AND TIME STAMP PROTOCOLS AND BACKUP RECOVERY
TRANSACTION MANAGEMENT AND TIME STAMP PROTOCOLS AND BACKUP RECOVERYRohit Kumar
 
Acid Properties In Database Management System
Acid Properties In Database Management SystemAcid Properties In Database Management System
Acid Properties In Database Management SystemAshish Kumar
 
Distributed Database Design and Relational Query Language
Distributed Database Design and Relational Query LanguageDistributed Database Design and Relational Query Language
Distributed Database Design and Relational Query LanguageAAKANKSHA JAIN
 
Transaction management
Transaction managementTransaction management
Transaction managementArchanaMani2
 
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptxUnit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptxKoteswari Kasireddy
 
UNIT-IV: Transaction Processing Concepts
UNIT-IV: Transaction Processing ConceptsUNIT-IV: Transaction Processing Concepts
UNIT-IV: Transaction Processing ConceptsRaj vardhan
 
Presentation on Transaction
Presentation on TransactionPresentation on Transaction
Presentation on TransactionRahul Prajapati
 
DBMS-chap 2-Concurrency Control
DBMS-chap 2-Concurrency ControlDBMS-chap 2-Concurrency Control
DBMS-chap 2-Concurrency ControlMukesh Tekwani
 
Chapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error RecoveryChapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error RecoveryKunal Anand
 
Transactions in dbms
Transactions in dbmsTransactions in dbms
Transactions in dbmsNancy Gulati
 

Similar to Transaction Processing Concept (20)

TRANSACTION MANAGEMENT AND TIME STAMP PROTOCOLS AND BACKUP RECOVERY
TRANSACTION MANAGEMENT AND TIME STAMP PROTOCOLS AND BACKUP RECOVERYTRANSACTION MANAGEMENT AND TIME STAMP PROTOCOLS AND BACKUP RECOVERY
TRANSACTION MANAGEMENT AND TIME STAMP PROTOCOLS AND BACKUP RECOVERY
 
Acid Properties In Database Management System
Acid Properties In Database Management SystemAcid Properties In Database Management System
Acid Properties In Database Management System
 
DBMS UNIT 4
DBMS UNIT 4DBMS UNIT 4
DBMS UNIT 4
 
DBMS 4.pdf
DBMS 4.pdfDBMS 4.pdf
DBMS 4.pdf
 
Distributed Database Design and Relational Query Language
Distributed Database Design and Relational Query LanguageDistributed Database Design and Relational Query Language
Distributed Database Design and Relational Query Language
 
Transaction management
Transaction managementTransaction management
Transaction management
 
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptxUnit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
 
transaction_processing.ppt
transaction_processing.ppttransaction_processing.ppt
transaction_processing.ppt
 
Dbms voc 5 unit
Dbms voc 5 unitDbms voc 5 unit
Dbms voc 5 unit
 
Hema rdbms
Hema rdbmsHema rdbms
Hema rdbms
 
Hema rdbms
Hema rdbmsHema rdbms
Hema rdbms
 
Transaction processing
Transaction processingTransaction processing
Transaction processing
 
Dbms
DbmsDbms
Dbms
 
Unit 4 dbms
Unit 4 dbmsUnit 4 dbms
Unit 4 dbms
 
UNIT-IV: Transaction Processing Concepts
UNIT-IV: Transaction Processing ConceptsUNIT-IV: Transaction Processing Concepts
UNIT-IV: Transaction Processing Concepts
 
Presentation on Transaction
Presentation on TransactionPresentation on Transaction
Presentation on Transaction
 
dbms sanat ppt.pdf
dbms sanat ppt.pdfdbms sanat ppt.pdf
dbms sanat ppt.pdf
 
DBMS-chap 2-Concurrency Control
DBMS-chap 2-Concurrency ControlDBMS-chap 2-Concurrency Control
DBMS-chap 2-Concurrency Control
 
Chapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error RecoveryChapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error Recovery
 
Transactions in dbms
Transactions in dbmsTransactions in dbms
Transactions in dbms
 

More from Nishant Munjal

Database Management System
Database Management SystemDatabase Management System
Database Management SystemNishant Munjal
 
Array, string and pointer
Array, string and pointerArray, string and pointer
Array, string and pointerNishant Munjal
 
Introduction to computers
Introduction to computersIntroduction to computers
Introduction to computersNishant Munjal
 
Shell Programming Concept
Shell Programming ConceptShell Programming Concept
Shell Programming ConceptNishant Munjal
 
Asynchronous Transfer Mode
Asynchronous Transfer ModeAsynchronous Transfer Mode
Asynchronous Transfer ModeNishant Munjal
 
Overview of Cloud Computing
Overview of Cloud ComputingOverview of Cloud Computing
Overview of Cloud ComputingNishant Munjal
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries InformationNishant Munjal
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization TechniquesNishant Munjal
 
Database Management System
Database Management SystemDatabase Management System
Database Management SystemNishant Munjal
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model IntroductionNishant Munjal
 
Virtualization, A Concept Implementation of Cloud
Virtualization, A Concept Implementation of CloudVirtualization, A Concept Implementation of Cloud
Virtualization, A Concept Implementation of CloudNishant Munjal
 
Technical education benchmarks
Technical education benchmarksTechnical education benchmarks
Technical education benchmarksNishant Munjal
 

More from Nishant Munjal (20)

Database Management System
Database Management SystemDatabase Management System
Database Management System
 
Functions & Recursion
Functions & RecursionFunctions & Recursion
Functions & Recursion
 
Array, string and pointer
Array, string and pointerArray, string and pointer
Array, string and pointer
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Introduction to computers
Introduction to computersIntroduction to computers
Introduction to computers
 
Unix Administration
Unix AdministrationUnix Administration
Unix Administration
 
Shell Programming Concept
Shell Programming ConceptShell Programming Concept
Shell Programming Concept
 
VI Editor
VI EditorVI Editor
VI Editor
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
Routing Techniques
Routing TechniquesRouting Techniques
Routing Techniques
 
Asynchronous Transfer Mode
Asynchronous Transfer ModeAsynchronous Transfer Mode
Asynchronous Transfer Mode
 
Overview of Cloud Computing
Overview of Cloud ComputingOverview of Cloud Computing
Overview of Cloud Computing
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
 
Concurrency Control
Concurrency ControlConcurrency Control
Concurrency Control
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
Virtualization, A Concept Implementation of Cloud
Virtualization, A Concept Implementation of CloudVirtualization, A Concept Implementation of Cloud
Virtualization, A Concept Implementation of Cloud
 
Technical education benchmarks
Technical education benchmarksTechnical education benchmarks
Technical education benchmarks
 
Bluemix Introduction
Bluemix IntroductionBluemix Introduction
Bluemix Introduction
 

Recently uploaded

Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 

Recently uploaded (20)

Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 

Transaction Processing Concept

  • 2. Transaction A transaction can be defined as a group of tasks. A single task is the minimum processing unit which cannot be divided further. Let’s take an example of a simple transaction. Suppose a bank employee transfers Rs 500 from A's account to B's account. This very simple and small transaction involves several low-level tasks. Open_Account(A) Old_Balance = A.balance New_Balance = Old_Balance - 500 A.balance = New_Balance Close_Account(A) Open_Account(B) Old_Balance = B.balance New_Balance = Old_Balance + 500 B.balance = New_Balance Close_Account(B)
  • 3. ACID Properties A transaction is a very small unit of a program and it may contain several low level tasks. A transaction in a database system must maintain Atomicity, Consistency, Isolation, and Durability − commonly known as ACID properties − in order to ensure accuracy, completeness, and data integrity. Atomicity: ◦ This property states that a transaction must be treated as an atomic unit, that is, either all of its operations are executed or none. There must be no state in a database where a transaction is left partially completed. States should be defined either before the execution of the transaction or after the execution/abortion/failure of the transaction. Consistency: ◦ The database must remain in a consistent state after any transaction. No transaction should have any adverse effect on the data residing in the database. If the database was in a consistent state before the execution of a transaction, it must remain consistent after the execution of the transaction as well.
  • 4. … Durability: ◦ The database should be durable enough to hold all its latest updates even if the system fails or restarts. If a transaction updates a chunk of data in a database and commits, then the database will hold the modified data. If a transaction commits but the system fails before the data could be written on to the disk, then that data will be updated once the system springs back into action. Isolation: ◦ In a database system where more than one transaction are being executed simultaneously and in parallel, the property of isolation states that all the transactions will be carried out and executed as if it is the only transaction in the system. No transaction will affect the existence of any other transaction.
  • 5. Serializability When multiple transactions are being executed by the operating system in a multiprogramming environment, there are possibilities that instructions of one transactions are interleaved with some other transaction. Schedule: ◦ A chronological execution sequence of a transaction is called a schedule. A schedule can have many transactions in it, each comprising of a number of instructions/tasks. Serial Schedule: ◦ It is a schedule in which transactions are aligned in such a way that one transaction is executed first. When the first transaction completes its cycle, then the next transaction is executed. Transactions are ordered one after the other. This type of schedule is called a serial schedule, as transactions are executed in a serial manner.
  • 6. … In a multi-transaction environment, serial schedules are considered as a benchmark. The execution sequence of an instruction in a transaction cannot be changed, but two transactions can have their instructions executed in a random fashion. This execution does no harm if two transactions are mutually independent and working on different segments of data; but in case these two transactions are working on the same data, then the results may vary. This ever-varying result may bring the database to an inconsistent state. To resolve this problem, we allow parallel execution of a transaction schedule, if its transactions are either serializable or have some equivalence relation among them.
  • 7. Equivalence Schedules An equivalence schedule can be of the following types − 1. Result Equivalence ◦ If the two transactions generate same result after their execution then it is called as result equivalence. For example, one transaction is updating the marks of Student X and the other transaction is to insert a new student. Here both the transactions are totally independent and their order of execution does not matter. Whichever order they are executed; the result is the same. Hence it is called result equivalence transactions. 2. View Equivalence 3. Conflict Equivalence
  • 8. View Equivalence Two schedules are said to be view equivalence, if the transaction in one schedule is same as the one in other. That means, both the transactions in two schedules perform same tasks. For example, say schedule1 has transaction to insert new students into STUDENT table and second schedule has the transaction to maintain the old student records in a new table called OLD_STUDENT. In both the schedules student details are inserted, but different tables (it does not matter if it is same table). Such schedules are called as view equivalence schedule. For example − ◦ If T reads the initial data in S1, then it also reads the initial data in S2. ◦ If T reads the value written by J in S1, then it also reads the value written by J in S2. ◦ If T performs the final write on the data value in S1, then it also performs the final write on the data value in S2.
  • 9. Conflict Equivalence Two schedules would be conflicting if they have the following properties − ◦ Both belong to separate transactions. ◦ Both accesses the same data item. ◦ At least one of them is "write" operation. In this case both schedules will have different set of transactions, but they would be accessing same data and one of the schedules will be inserting/updating the records. In this equivalence, both the schedules will have conflicting set of transactions. Above example of updating the marks of one student by one transaction and calculating the total marks at the same time is a conflicting equivalence. In all these cases if the transaction is serialized, then the issues can be resolved.
  • 10. States of Transaction • Active • Partially Committed − When a transaction executes its final operation, it is said to be in a partially committed state. • Failed − A transaction is said to be in a failed state if any of the checks made by the database recovery system fails. A failed transaction can no longer proceed further. • Aborted − If any of the checks fails and the transaction has reached a failed state, then the recovery manager rolls back all its write operations on the database to bring the database back to its original state where it was prior to the execution of the transaction. Transactions in this state are called aborted. The database recovery module can select one of the two operations after a transaction aborts − • Re-start the transaction • Kill the transaction • Committed
  • 11. Recovery and Atomicity When the system recovers from a failure, it can restore the latest dump. When a system crashes, it may have several transactions being executed and various files opened for them to modify the data items. Transactions are made of various operations, which are atomic in nature. But according to ACID properties of DBMS, atomicity of transactions as a whole must be maintained, that is, either all the operations are executed or none. When a DBMS recovers from a crash, it should maintain the following − ◦ It should check the states of all the transactions, which were being executed. ◦ A transaction may be in the middle of some operation; the DBMS must ensure the atomicity of the transaction in this case. ◦ It should check whether the transaction can be completed now or it needs to be rolled back. ◦ No transactions would be allowed to leave the DBMS in an inconsistent state.
  • 12. … There are two types of techniques, which can help a DBMS in recovering as well as maintaining the atomicity of a transaction − • Maintaining the logs of each transaction, and writing them onto some stable storage before actually modifying the database. • Maintaining shadow paging, where the changes are done on a volatile memory, and later, the actual database is updated
  • 13. Log-based Recovery Log is a sequence of records, which maintains the records of actions performed by a transaction. It is important that the logs are written prior to the actual modification and stored on a stable storage media, which is failsafe. The update log record describes a single database write: 1. Transaction Identifier 2. Data-item identifier 3. Old Value 4. New Value Log-based recovery works as follows − ◦ The log file is kept on a stable storage media. ◦ <Tn, Start>: When a transaction enters the system and starts execution, it writes a log about it ◦ <Tn, X, V1, V2>: When the transaction modifies an item X, it write logs, It reads Tn has changed the value of X, from V1 to V2. ◦ <Tn, commit>: When the transaction finishes.
  • 14. … Database can be modified using two approaches: Deferred database modification − The deferred-modification technique ensures transaction atomicity by recording all database modifications in the log, but deferring all write operations of a transaction until the transaction partially commits (i.e., once the final action of the transaction has been executed). Then the information in the logs is used to execute the deferred writes. If the system crashes or if the transaction aborts, then the information in the logs is ignored. Immediate database modification − The immediate-update technique allows database modifications to be output to the database while the transaction is still in the active state. These modifications are called uncommitted modifications. In the event of a crash or transaction failure, the system must use the old-value field of the log records to restore the modified data items.
  • 15.
  • 16. Recovery with Concurrent Transactions When more than one transaction are being executed in parallel, the logs are interleaved. At the time of recovery, it would become hard for the recovery system to backtrack all logs, and then start recovering. To ease this situation, most modern DBMS use the concept of 'checkpoints'. Checkpoint Checkpoint is a mechanism where all the previous logs are removed from the system and stored permanently in a storage disk. Checkpoint declares a point before which the DBMS was in consistent state, and all the transactions were committed.
  • 17. Transaction Recovery When a system with concurrent transactions crashes and recovers, it behaves in the following manner − • The recovery system reads the logs backwards from the end to the last checkpoint. • It maintains two lists, an undo-list and a redo-list. • If the recovery system sees a log with <Tn, Start> and <Tn, Commit> or just <Tn, Commit>, it puts the transaction in the redo-list. • If the recovery system sees a log with <Tn, Start> but no commit or abort log found, it puts the transaction in undo-list. • All the transactions in the undo-list are then undone and their logs are removed. All the transactions in the redo-list and their previous logs are removed and then redone before saving their logs.
  • 18. Deadlock A deadlock is a condition wherein two or more tasks are waiting for each other in order to be finished but none of the task is willing to give up the resources that other task needs. In this situation no task ever gets finished and is in waiting state forever. Deadlocks are not healthy for a system. In case a system is stuck in a deadlock, the transactions involved in the deadlock are either rolled back or restarted.
  • 19. Deadlock Prevention To prevent any deadlock situation in the system, the DBMS aggressively inspects all the operations, where transactions are about to execute. The DBMS inspects the operations and analyzes if they can create a deadlock situation. If it finds that a deadlock situation might occur, then that transaction is never allowed to be executed. There are deadlock prevention schemes that use timestamp ordering mechanism of transactions in order to predetermine a deadlock situation. • Wait Die Scheme • Wound Wait Scheme
  • 20. Wait-Die Scheme This Deadlock prevention scheme as indicated by its name halts a transaction and terminates any further transactions occurring after such that there is no deadlock. Rules: If a transaction is requesting a lock on the resource and is found to be of an older time stamp than the transaction which has the resource locked, it is not terminated. If a transaction is requesting a lock on the resource and is found to be of a younger time stamp than the transaction which has the resource locked, it is terminated.
  • 21. … (1) If TS(Ti) < TS(Tj) − that is Ti, which is requesting a conflicting lock, is older than Tj − then Ti is allowed to wait until the data-item is available. (2) If TS(Ti) > TS(tj) − that is Ti is younger than Tj − then Ti dies. Ti is restarted later with a random delay but with the same timestamp. For example: Suppose that transaction T22, T23, T24 have time-stamps 5, 10 and 15 respectively. If T22requests a data item held by T23 then T22 will wait. If T24 requests a data item held by T23, then T24 will be rolled back.
  • 22. Wound-Wait Scheme This Deadlock prevention scheme as indicated by its name halts any further transaction that requests the resource. If an older timestamp transaction is requesting a lock on the resource, it is not terminated and made to wait for the resource to be available. If a transaction is requesting a lock on the resource and is found to be of an older time stamp than the transaction which is in line for the resource, it can terminate the younger transaction and take over the resource. The time stamp with a younger time stamp is then rebooted. The one thing that’s common in both the deadlock prevention schemes is that the transaction that enters the system late and has a younger time stamp is aborted.
  • 23. … (1) If TS(Ti) < TS(Tj), then Ti forces Tj to be rolled back − that is Ti wounds Tj. Tj is restarted later with a random delay but with the same timestamp. (2) If TS(Ti) > TS(Tj), then Ti is forced to wait until the resource is available. For example: Suppose that Transactions T22, T23, T24 have time-stamps 5, 10 and 15 respectively . If T22requests a data item held by T23, then data item will be pre-empted from T23 and T23 will be rolled back. If T24 requests a data item held by T23, then T24 will wait.
  • 24. Deadlock Avoidance Deadlock avoidance mechanisms can be used to detect any deadlock situation in advance. Methods like "wait-for graph" are available but they are suitable for only those systems where transactions are lightweight having fewer instances of resource. Wait-for Graph This is a simple method available to track if any deadlock situation may arise. For each transaction entering into the system, a node is created. When a transaction Ti requests for a lock on an item, say X, which is held by some other transaction Tj, a directed edge is created from Ti to Tj. If Tj releases item X, the edge between them is dropped and Ti locks the data item. The system maintains this wait-for graph for every transaction waiting for some data items held by others. The system keeps checking if there's any cycle in the graph.
  • 25. … Here, we can use any of the two following approaches − First, do not allow any request for an item, which is already locked by another transaction. This is not always feasible and may cause starvation, where a transaction indefinitely waits for a data item and can never acquire it. The second option is to roll back one of the transactions. It is not always feasible to roll back the younger transaction, as it may be important than the older one. With the help of some relative algorithm, a transaction is chosen, which is to be aborted. This transaction is known as the victim and the process is known as victim selection.