SlideShare a Scribd company logo
1 of 31
By C.Aruna (DSCASC) 1
Transaction Processing Concepts
Chapter 9
UNIT V
Data Base Management System
[DBMS]
By C.Aruna (DSCASC) 2
Intoduction
Transaction Processing Concepts
The concept of transaction :
 Provides a mechanism for describing logical units of database
processing.
Transaction processing systems :
 Systems with large databases and hundreds of concurrent users
that are executing database transactions.
By C.Aruna (DSCASC) 3
Single user Versus Multiuser Systems
Single-User: At most one user at a time can use the system
 Multi-User: Many users can use the system concurrently.
Multiprogramming: Allows the computer to execute multiple programs
at the same time.
Interleaving : Keeps the CPU busy when a process requires an input
or output operation, the CPU switched to execute another process rather
than remaining idle during I/O time .
Most of the theory concerning concurrency control in databases is
developed in terms of interleaved concurrency.
By C.Aruna (DSCASC) 4
Transactions, Read and Write Operations
A Transaction : is a logical unit of database processing, that includes one
or more database access operation.
All database access operations between Begin Transaction and End
Transaction statements are considered as one logical transaction.
If the database operations in a transaction do not update the database but
only retrieve data , the transaction is called a read-only transaction.
Basic database access operations :
read_item(X) : Reads a database item X into program variable.
write_item(X) : Writes the value of program variable X into the
database item X.
Read and Write Operations of a Transaction
 read_item(X): reads a database item named X into a program variable also
named X.
Execution of the command includes the following steps:
 find the address of the disk block that contains item X
 copy that disk block into a buffer in the main memory
 copy item X from the buffer to the program variable named X
 write_item(X): writes the value of program variable X into the database item
named X.
Execution of the command includes the following steps:
 find the address of the disk block that contains item X
 copy that disk block into a buffer in the main memory
 copy item X from the program variable named X into its current location in the buffer
 store the updated block in the buffer back to disk (this step updates the database on disk)
5By C.Aruna (DSCASC)
By C.Aruna (DSCASC) 6
Two sample transactions
a) Transaction T1
read_item(X);
X:=X-N;
write_item(X);
read_item(Y);
Y:=Y+N;
write_item(Y);
Transfer N reservations from
1st
flight to 2nd
flight
b) Transaction T2
read_item(x);
X:=X+M;
write_item(X);
Reserve M seats on the 1st
flight
X & Y refers to number of reserved seats for specific flight.
Transactions - examples
T1
Read-item(my-account)
my-account := my-account - 2000
Write-item(my-account)
Read-item(other-account)
Other-account := other-account + 2000
Write-item(other-account)
T2
Read-item(my-account)
my-account := my-account +1000
Write-item(my-account)
By C.Aruna (DSCASC) 7
Example T1: Rs.2000 is deducted from
my-account and added into other-account
Example T2: Rs.1000 is added to
my-account
By C.Aruna (DSCASC) 8
Why Concurrency Control is needed
Several problems can occur when concurrent transactions
execute in an uncontrolled manner.
Eg: Airlines reservation database.
Types of problems:
Types of problem occur when the two transaction run concurrently.
1) The Lost Update Problem.
2) The temporary Update (or Dirty read) problem.
3) The Incorrect Summary Problem.
4) Unrepeatable Read problem.
By C.Aruna (DSCASC) 9
Why Concurrency Control is needed
 The Lost Update Problem:
This problem occurs when two transactions access the
same database items concurrently.
T1 T2
Read_item(X);
X=:X-N;
Time
Read_item(X);
X=:X+M;
Write_item(X);
Read_item(Y);
Y=:Y+N; Write_item(X);
Item X has
incorrect
value because its
update by T1 is
“lost”
(overwritten)
Write_item(Y);
Pg:635 Navathe Eg. X=80 at the start, N=5 (T1 transfers 5 seat reservations from flight corresponding to
X to the flight corresponding to Y) & M=4
Ex: Lost update problem
T1
Read-item(my-account)
my-account := my-account – 2000
Write-item(my-account)
Read-item(other-account)
Other-account := other-account + 2000
Write-item(other-account)
T2
Read-item(my-account)
my-account := my-account +1000
Write-item(my-account)
By C.Aruna (DSCASC) 10
Example T1: Rs.2000 is deducted from
my-account
Example T2: Rs.1000 is added to
my-account
Time
By C.Aruna (DSCASC) 11
Why Concurrency Control is needed
 The temporary Update (or Dirty read) problem:
This problem occurs when one transaction updates a database item and
then the transaction fails for some reason. The update item is accessed by
another transaction before it is changed back to its original value.
T1 T2
Read_item(X);
X=:X-N;
write_item(X);
Time
Read_item(X);
X=:X+M;
write_item(X);read_item(Y);
Transaction T1 fails and must change
the value of X back to its old value,
meanwhile T2 has read the temporary
value ie. Incorrect value of X
Writing fails
before
completion.
Ex: Dirty read problem
T1
Read-item(my-account)
My-account := my-account - 2000
Write-item(my-account)
Read-item(other-account)
T2
Read-item(my-account)
My-account := my-account +1000
Write-item(my-account)
By C.Aruna (DSCASC) 12
Writing fails
before
completion.
Time
By C.Aruna (DSCASC) 13
Why Concurrency Control is needed (continued)
 The Incorrect Summary Problem:
If one transaction is calculating an aggregated summary function on
a number of records while other transaction are updating some of
these records, the aggregate function may calculate some values
before they are updated and others after they are updated.
By C.Aruna (DSCASC) 14
Why Concurrency Control is needed (continued)
3. The Incorrect Summary Problem:
T1 T3
Read_item(X);
X=:X-N;
write_item(X);
Time
Read_item(X);
sum:=sum+x;
read_item(Y);
sum:=sum+Y;
read_item(Y);
Y:=Y+N;
write_item(Y);
T3 reads X after N is
subtracted and reads Y
before N is added;
Sum:=0;
Read_item(A);
sum:=sum+A;
.
.
.
Ex: Incorrect Summary Problem
T1
Read-item(my-account1)
My-account1 := my-account1 - 2000
Write-item(my-account1)
Read-item(my-account2)
My-account2 := my-account2 + 2000
Write-item(my-account2)
T2
sum := 0
Read-item(my-account1)
sum := sum + my-account1
Read-item(my-account2)
sum := sum + my-account2
By C.Aruna (DSCASC) 15
Why Concurrency Control is needed (continued)
4. Unrepeatable Read problem: A transaction reads items twice with two
different values because it was changed by another transaction between
the two reads.
By C.Aruna (DSCASC) 16
T1
Read-item(my-account)
Read-item(my-account)
T2
Read-item(my-account)
My-account:= my-account + 1000
Write-item(my-account)
Eg: Bank, Flight Reservation – A customer enquires about seat availability in diff.
flights. When he decides to book, the no. of seats will be different because of T2
updates the no.of seats.
By C.Aruna (DSCASC) 17
Why Recovery Is Needed
There several possible reasons for a transaction to
fail
A computer failure : A hardware, software, or network error occurs in
the computer system during transaction execution.
A transaction or system error : Some operations in the transaction
may cause it to fail.
Local errors or exception conditions detected by the transaction.
By C.Aruna (DSCASC) 18
Why Recovery Is Needed (continued)
Concurrency control enforcement : The concurrency control method
may decide to abort the transaction.
Disk failure : all disk or some disk blocks may lose their data.
Physical problems : Disasters, theft, fire, etc.
The system must keep sufficient information to
recover from the failure.
By C.Aruna (DSCASC) 19
Transaction states and additional operations
A transaction is an atomic unit of work that is either completed
in its entirety or not done at all.
For recovery purposes the system needs to keep track of when
the transaction starts, terminates, and commits or aborts.
The recovery manager keeps track of the following operations :
BEGIN_TRANSACTION
READ OR WRITE
END_TRANSACTION
COMMIT_TRANSACTION
ROLLBACK
By C.Aruna (DSCASC) 20
Transaction states
BEGIN_TRANSACTION: This marks the beginning of transaction
execution.
READ OR WRITE: Specifies READ or WRITE transaction operations on
the database items that are executed as part of a transaction.
END_TRANSACTION: Specifies the READ and WRITE transaction
operations have ended and marks the end of transaction execution.
COMMIT_TRANSACTION: This signals a successful end of the transaction.
ROLLBACK (or ABORT): This signals that the transaction has ended
unsuccessfully, so that any changes or effects that the transaction may
have applied to the database must be undone.
By C.Aruna (DSCASC) 21
ACTIVE PARTIALLY
COMMITTED
FAILED TERMINATED
COMMITTED
BEGIN
TRANSACTION
END
TRANSACTION COMMIT
ABORT
ABORT
Figure 19.4 State transition diagram illustrating the states for transaction execution
READ/
WRITE
Transaction states
By C.Aruna (DSCASC) 22
Transaction states
 A state transition diagram that describes how a transaction moves through its
execution states.
 A transaction goes into active state immediately after it starts execution, where it
can issue READ and WRITE operations.
 When the transaction ends it moves to the partially committed state.
 At this point some recovery protocols need to ensure that a system failure will not
result in an inability to record the changes of the transaction permanently.
 Once this check is successful the transaction is said to have reached its commit point
and enters the committed state.
 A transaction can go to failed state if one of the checks fails or if the transaction is
aborted during its active state.
 The transaction may then have to be rolled back to undo the effect of its WRITE
operations on the database.
 The terminated state corresponds to the transaction leaving the system.
Properties of transactions
Properties of transactions:
ACID
 Atomicity
Consistency preservation
Isolation
 Durability
By C.Aruna (DSCASC) 23
By C.Aruna (DSCASC) 24
Properties of transactions
ACID should be enforced by the concurrency control and recovery
methods of the DBMS.
ACID properties of transactions :
Atomicity : a transaction is an atomic unit of processing; it is either
performed entirely or not performed at all.
(It is the responsibility of recovery)
Consistency : transfer the database from one consistent state to another
consistent state
(It is the responsibility of the applications and DBMS to maintain the
constraints)
By C.Aruna (DSCASC) 25
Properties of transactions (continued)
Isolation : the execution of the transaction should be isolated from
other transactions (Locking)
(It is the responsibility of concurrency)
* Isolation level:
- Level 0 (no dirty read) - Level 1 ( no lost update)
- Level 2 (no dirty+ no lost) - Level 3 (level 2+repeatable reads)
Durability : committed transactions must persist in the database ,i.e.
those changes must not be lost because of any failure.
(It is the responsibility of recovery)
• Atomicity
– Recovery system
• Consistency
– Programmer + DBMS
• Isolation
– Concurrency control
• Durability
– Recovery system
By C.Aruna (DSCASC) 26
Serial and serializability of schedules
• A schedule S is serial if in the operations in each
transaction in S are executed directly after each other.
• A schedule S is serializable if there is an equivalent
serial schedule S'.
• Equivalent: conflict equivalence
By C.Aruna (DSCASC) 27
Transactions
T1
Read-item(my-account)
My-account := my-account - 2000
Write-item(my-account)
Read-item(other-account)
Other-account := other-account + 2000
Write-item(other-account)
By C.Aruna (DSCASC) 28
T2
Read-item(my-account)
My-account := my-account +1000
Write-item(my-account)
Example of Serial Schedules
T1
Read-item(my-account)
My-account := my-account - 2000
Write-item(my-account)
Read-item(other-account)
Other-account := other-account + 2000
Write-item(other-account)
By C.Aruna (DSCASC) 29
T2
Read-item(my-account)
My-account := my-account +1000
Write-item(my-account)
Example of Serial Schedules
T1
Read-item(my-account)
My-account := my-account - 2000
Write-item(my-account)
Read-item(other-account)
Other-account := other-account + 2000
Write-item(other-account)
By C.Aruna (DSCASC) 30
T2
Read-item(my-account)
My-account := my-account +1000
Write-item(my-account)
Example of Non-serial Schedules
time
T1: T2:
read_item(X);
X:= X - N;
read_item(X);
X:= X + M;
write_item(X);
read_item(Y);
write_item(X);
Y:=Y + N;
write_item(Y);
Schedule A
31By C.Aruna (DSCASC)

More Related Content

What's hot

Direct memory access (dma)
Direct memory access (dma)Direct memory access (dma)
Direct memory access (dma)Zubair Khalid
 
ATM Networking Concept
ATM Networking ConceptATM Networking Concept
ATM Networking ConceptTushar Ranjan
 
Hardware and Software parallelism
Hardware and Software parallelismHardware and Software parallelism
Hardware and Software parallelismprashantdahake
 
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
 
Instruction codes and computer registers
Instruction codes and computer registersInstruction codes and computer registers
Instruction codes and computer registersSanjeev Patel
 
Io techniques & its types
Io techniques & its typesIo techniques & its types
Io techniques & its typesNehal Naik
 
Data communication and networks by B. Forouzan
Data communication and networks by B. ForouzanData communication and networks by B. Forouzan
Data communication and networks by B. ForouzanPreethi T G
 
Dbms 3: 3 Schema Architecture
Dbms 3: 3 Schema ArchitectureDbms 3: 3 Schema Architecture
Dbms 3: 3 Schema ArchitectureAmiya9439793168
 
Register Transfer Language,Bus and Memory Transfer
Register Transfer Language,Bus and Memory TransferRegister Transfer Language,Bus and Memory Transfer
Register Transfer Language,Bus and Memory Transferlavanya marichamy
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layerNaiyan Noor
 
Design issues for the layers
Design issues for the layersDesign issues for the layers
Design issues for the layersjayaprakash
 
Types of Addressing modes- COA
Types of Addressing modes- COATypes of Addressing modes- COA
Types of Addressing modes- COARuchi Maurya
 
DATA RATE LIMITS
DATA RATE LIMITSDATA RATE LIMITS
DATA RATE LIMITSChAwais15
 
Computer registers
Computer registersComputer registers
Computer registersDeepikaT13
 
Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)Ravinder Kamboj
 

What's hot (20)

Direct memory access (dma)
Direct memory access (dma)Direct memory access (dma)
Direct memory access (dma)
 
Modes of transfer
Modes of transferModes of transfer
Modes of transfer
 
ATM Networking Concept
ATM Networking ConceptATM Networking Concept
ATM Networking Concept
 
Hardware and Software parallelism
Hardware and Software parallelismHardware and Software parallelism
Hardware and Software parallelism
 
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
 
Instruction codes and computer registers
Instruction codes and computer registersInstruction codes and computer registers
Instruction codes and computer registers
 
Io techniques & its types
Io techniques & its typesIo techniques & its types
Io techniques & its types
 
Data communication and networks by B. Forouzan
Data communication and networks by B. ForouzanData communication and networks by B. Forouzan
Data communication and networks by B. Forouzan
 
Dbms 3: 3 Schema Architecture
Dbms 3: 3 Schema ArchitectureDbms 3: 3 Schema Architecture
Dbms 3: 3 Schema Architecture
 
Deductive databases
Deductive databasesDeductive databases
Deductive databases
 
Register Transfer Language,Bus and Memory Transfer
Register Transfer Language,Bus and Memory TransferRegister Transfer Language,Bus and Memory Transfer
Register Transfer Language,Bus and Memory Transfer
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layer
 
Design issues for the layers
Design issues for the layersDesign issues for the layers
Design issues for the layers
 
Types of Addressing modes- COA
Types of Addressing modes- COATypes of Addressing modes- COA
Types of Addressing modes- COA
 
DATA RATE LIMITS
DATA RATE LIMITSDATA RATE LIMITS
DATA RATE LIMITS
 
Instruction codes
Instruction codesInstruction codes
Instruction codes
 
Computer registers
Computer registersComputer registers
Computer registers
 
Network layer logical addressing
Network layer logical addressingNetwork layer logical addressing
Network layer logical addressing
 
design of accumlator
design of accumlatordesign of accumlator
design of accumlator
 
Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)
 

Viewers also liked

1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMSkoolkampus
 
Dbms ii mca-ch11-recovery-2013
Dbms ii mca-ch11-recovery-2013Dbms ii mca-ch11-recovery-2013
Dbms ii mca-ch11-recovery-2013Prosanta Ghosh
 
Dbms ii mca-ch1-ch2-intro-datamodel-2013
Dbms ii mca-ch1-ch2-intro-datamodel-2013Dbms ii mca-ch1-ch2-intro-datamodel-2013
Dbms ii mca-ch1-ch2-intro-datamodel-2013Prosanta Ghosh
 
Transaction management DBMS
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMSMegha Patel
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMSkoolkampus
 
Transactions in dbms
Transactions in dbmsTransactions in dbms
Transactions in dbmsNancy Gulati
 
Temporal Databases: Queries
Temporal Databases: QueriesTemporal Databases: Queries
Temporal Databases: Queriestorp42
 
Dbms ii mca-ch8-db design-2013
Dbms ii mca-ch8-db design-2013Dbms ii mca-ch8-db design-2013
Dbms ii mca-ch8-db design-2013Prosanta Ghosh
 
Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011sumit_study
 
Dbms ii mca-ch7-sql-2013
Dbms ii mca-ch7-sql-2013Dbms ii mca-ch7-sql-2013
Dbms ii mca-ch7-sql-2013Prosanta Ghosh
 
Database ,10 Transactions
Database ,10 TransactionsDatabase ,10 Transactions
Database ,10 TransactionsAli Usman
 
Mobile Database
Mobile DatabaseMobile Database
Mobile DatabaseThanh Le
 
Record storage and primary file organization
Record storage and primary file organizationRecord storage and primary file organization
Record storage and primary file organizationJafar Nesargi
 
Dbms ii mca-ch10-concurrency-control-2013
Dbms ii mca-ch10-concurrency-control-2013Dbms ii mca-ch10-concurrency-control-2013
Dbms ii mca-ch10-concurrency-control-2013Prosanta Ghosh
 
Mobile database security threats
Mobile database security threatsMobile database security threats
Mobile database security threatsAkhil Kumar
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relationalJafar Nesargi
 

Viewers also liked (20)

1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMS
 
Dbms ii mca-ch11-recovery-2013
Dbms ii mca-ch11-recovery-2013Dbms ii mca-ch11-recovery-2013
Dbms ii mca-ch11-recovery-2013
 
Normalization case
Normalization caseNormalization case
Normalization case
 
Dbms ii mca-ch1-ch2-intro-datamodel-2013
Dbms ii mca-ch1-ch2-intro-datamodel-2013Dbms ii mca-ch1-ch2-intro-datamodel-2013
Dbms ii mca-ch1-ch2-intro-datamodel-2013
 
Transaction management DBMS
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMS
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 
3 transaction
3 transaction3 transaction
3 transaction
 
Transactions in dbms
Transactions in dbmsTransactions in dbms
Transactions in dbms
 
Transaction states PPT
Transaction states PPTTransaction states PPT
Transaction states PPT
 
Temporal Databases: Queries
Temporal Databases: QueriesTemporal Databases: Queries
Temporal Databases: Queries
 
Dbms ii mca-ch8-db design-2013
Dbms ii mca-ch8-db design-2013Dbms ii mca-ch8-db design-2013
Dbms ii mca-ch8-db design-2013
 
Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011
 
Ch16
Ch16Ch16
Ch16
 
Dbms ii mca-ch7-sql-2013
Dbms ii mca-ch7-sql-2013Dbms ii mca-ch7-sql-2013
Dbms ii mca-ch7-sql-2013
 
Database ,10 Transactions
Database ,10 TransactionsDatabase ,10 Transactions
Database ,10 Transactions
 
Mobile Database
Mobile DatabaseMobile Database
Mobile Database
 
Record storage and primary file organization
Record storage and primary file organizationRecord storage and primary file organization
Record storage and primary file organization
 
Dbms ii mca-ch10-concurrency-control-2013
Dbms ii mca-ch10-concurrency-control-2013Dbms ii mca-ch10-concurrency-control-2013
Dbms ii mca-ch10-concurrency-control-2013
 
Mobile database security threats
Mobile database security threatsMobile database security threats
Mobile database security threats
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
 

Similar to Dbms ii mca-ch9-transaction-processing-2013

Introduction to transaction processing
Introduction to transaction processingIntroduction to transaction processing
Introduction to transaction processingJafar Nesargi
 
Chapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processingChapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processingJafar Nesargi
 
Chapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processingChapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processingJafar Nesargi
 
Introduction to transaction processing concepts and theory
Introduction to transaction processing concepts and theoryIntroduction to transaction processing concepts and theory
Introduction to transaction processing concepts and theoryZainab Almugbel
 
UNIT-IV: Transaction Processing Concepts
UNIT-IV: Transaction Processing ConceptsUNIT-IV: Transaction Processing Concepts
UNIT-IV: Transaction Processing ConceptsRaj vardhan
 
Recovery system
Recovery systemRecovery system
Recovery systemRakesh S
 
Transactionsmanagement
TransactionsmanagementTransactionsmanagement
TransactionsmanagementSanjeev Gupta
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMSkoolkampus
 
database1.pptx
database1.pptxdatabase1.pptx
database1.pptxOmarKamil1
 
transaction mgr (7) (1).ppt
transaction mgr (7) (1).ppttransaction mgr (7) (1).ppt
transaction mgr (7) (1).pptPavanKumar980917
 
DBMS Unit III Material
DBMS Unit III MaterialDBMS Unit III Material
DBMS Unit III MaterialArthyR3
 
Transaction Management system.ppt
Transaction Management system.pptTransaction Management system.ppt
Transaction Management system.pptKaranKhurana54
 

Similar to Dbms ii mca-ch9-transaction-processing-2013 (20)

Unit 5
Unit 5Unit 5
Unit 5
 
Introduction to transaction processing
Introduction to transaction processingIntroduction to transaction processing
Introduction to transaction processing
 
Chapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processingChapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processing
 
Chapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processingChapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processing
 
Introduction to transaction processing concepts and theory
Introduction to transaction processing concepts and theoryIntroduction to transaction processing concepts and theory
Introduction to transaction processing concepts and theory
 
UNIT-IV: Transaction Processing Concepts
UNIT-IV: Transaction Processing ConceptsUNIT-IV: Transaction Processing Concepts
UNIT-IV: Transaction Processing Concepts
 
Recovery system
Recovery systemRecovery system
Recovery system
 
Transactionsmanagement
TransactionsmanagementTransactionsmanagement
Transactionsmanagement
 
17 Recovery system.ppt
17 Recovery system.ppt17 Recovery system.ppt
17 Recovery system.ppt
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMS
 
Recovery system
Recovery systemRecovery system
Recovery system
 
Dbms
DbmsDbms
Dbms
 
database1.pptx
database1.pptxdatabase1.pptx
database1.pptx
 
Ch17
Ch17Ch17
Ch17
 
transaction mgr (7) (1).ppt
transaction mgr (7) (1).ppttransaction mgr (7) (1).ppt
transaction mgr (7) (1).ppt
 
DBMS Unit III Material
DBMS Unit III MaterialDBMS Unit III Material
DBMS Unit III Material
 
Aries
AriesAries
Aries
 
Transaction Management system.ppt
Transaction Management system.pptTransaction Management system.ppt
Transaction Management system.ppt
 
Transaction
TransactionTransaction
Transaction
 
DBMS UNIT 4
DBMS UNIT 4DBMS UNIT 4
DBMS UNIT 4
 

Recently uploaded

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 

Recently uploaded (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 

Dbms ii mca-ch9-transaction-processing-2013

  • 1. By C.Aruna (DSCASC) 1 Transaction Processing Concepts Chapter 9 UNIT V Data Base Management System [DBMS]
  • 2. By C.Aruna (DSCASC) 2 Intoduction Transaction Processing Concepts The concept of transaction :  Provides a mechanism for describing logical units of database processing. Transaction processing systems :  Systems with large databases and hundreds of concurrent users that are executing database transactions.
  • 3. By C.Aruna (DSCASC) 3 Single user Versus Multiuser Systems Single-User: At most one user at a time can use the system  Multi-User: Many users can use the system concurrently. Multiprogramming: Allows the computer to execute multiple programs at the same time. Interleaving : Keeps the CPU busy when a process requires an input or output operation, the CPU switched to execute another process rather than remaining idle during I/O time . Most of the theory concerning concurrency control in databases is developed in terms of interleaved concurrency.
  • 4. By C.Aruna (DSCASC) 4 Transactions, Read and Write Operations A Transaction : is a logical unit of database processing, that includes one or more database access operation. All database access operations between Begin Transaction and End Transaction statements are considered as one logical transaction. If the database operations in a transaction do not update the database but only retrieve data , the transaction is called a read-only transaction. Basic database access operations : read_item(X) : Reads a database item X into program variable. write_item(X) : Writes the value of program variable X into the database item X.
  • 5. Read and Write Operations of a Transaction  read_item(X): reads a database item named X into a program variable also named X. Execution of the command includes the following steps:  find the address of the disk block that contains item X  copy that disk block into a buffer in the main memory  copy item X from the buffer to the program variable named X  write_item(X): writes the value of program variable X into the database item named X. Execution of the command includes the following steps:  find the address of the disk block that contains item X  copy that disk block into a buffer in the main memory  copy item X from the program variable named X into its current location in the buffer  store the updated block in the buffer back to disk (this step updates the database on disk) 5By C.Aruna (DSCASC)
  • 6. By C.Aruna (DSCASC) 6 Two sample transactions a) Transaction T1 read_item(X); X:=X-N; write_item(X); read_item(Y); Y:=Y+N; write_item(Y); Transfer N reservations from 1st flight to 2nd flight b) Transaction T2 read_item(x); X:=X+M; write_item(X); Reserve M seats on the 1st flight X & Y refers to number of reserved seats for specific flight.
  • 7. Transactions - examples T1 Read-item(my-account) my-account := my-account - 2000 Write-item(my-account) Read-item(other-account) Other-account := other-account + 2000 Write-item(other-account) T2 Read-item(my-account) my-account := my-account +1000 Write-item(my-account) By C.Aruna (DSCASC) 7 Example T1: Rs.2000 is deducted from my-account and added into other-account Example T2: Rs.1000 is added to my-account
  • 8. By C.Aruna (DSCASC) 8 Why Concurrency Control is needed Several problems can occur when concurrent transactions execute in an uncontrolled manner. Eg: Airlines reservation database. Types of problems: Types of problem occur when the two transaction run concurrently. 1) The Lost Update Problem. 2) The temporary Update (or Dirty read) problem. 3) The Incorrect Summary Problem. 4) Unrepeatable Read problem.
  • 9. By C.Aruna (DSCASC) 9 Why Concurrency Control is needed  The Lost Update Problem: This problem occurs when two transactions access the same database items concurrently. T1 T2 Read_item(X); X=:X-N; Time Read_item(X); X=:X+M; Write_item(X); Read_item(Y); Y=:Y+N; Write_item(X); Item X has incorrect value because its update by T1 is “lost” (overwritten) Write_item(Y); Pg:635 Navathe Eg. X=80 at the start, N=5 (T1 transfers 5 seat reservations from flight corresponding to X to the flight corresponding to Y) & M=4
  • 10. Ex: Lost update problem T1 Read-item(my-account) my-account := my-account – 2000 Write-item(my-account) Read-item(other-account) Other-account := other-account + 2000 Write-item(other-account) T2 Read-item(my-account) my-account := my-account +1000 Write-item(my-account) By C.Aruna (DSCASC) 10 Example T1: Rs.2000 is deducted from my-account Example T2: Rs.1000 is added to my-account Time
  • 11. By C.Aruna (DSCASC) 11 Why Concurrency Control is needed  The temporary Update (or Dirty read) problem: This problem occurs when one transaction updates a database item and then the transaction fails for some reason. The update item is accessed by another transaction before it is changed back to its original value. T1 T2 Read_item(X); X=:X-N; write_item(X); Time Read_item(X); X=:X+M; write_item(X);read_item(Y); Transaction T1 fails and must change the value of X back to its old value, meanwhile T2 has read the temporary value ie. Incorrect value of X Writing fails before completion.
  • 12. Ex: Dirty read problem T1 Read-item(my-account) My-account := my-account - 2000 Write-item(my-account) Read-item(other-account) T2 Read-item(my-account) My-account := my-account +1000 Write-item(my-account) By C.Aruna (DSCASC) 12 Writing fails before completion. Time
  • 13. By C.Aruna (DSCASC) 13 Why Concurrency Control is needed (continued)  The Incorrect Summary Problem: If one transaction is calculating an aggregated summary function on a number of records while other transaction are updating some of these records, the aggregate function may calculate some values before they are updated and others after they are updated.
  • 14. By C.Aruna (DSCASC) 14 Why Concurrency Control is needed (continued) 3. The Incorrect Summary Problem: T1 T3 Read_item(X); X=:X-N; write_item(X); Time Read_item(X); sum:=sum+x; read_item(Y); sum:=sum+Y; read_item(Y); Y:=Y+N; write_item(Y); T3 reads X after N is subtracted and reads Y before N is added; Sum:=0; Read_item(A); sum:=sum+A; . . .
  • 15. Ex: Incorrect Summary Problem T1 Read-item(my-account1) My-account1 := my-account1 - 2000 Write-item(my-account1) Read-item(my-account2) My-account2 := my-account2 + 2000 Write-item(my-account2) T2 sum := 0 Read-item(my-account1) sum := sum + my-account1 Read-item(my-account2) sum := sum + my-account2 By C.Aruna (DSCASC) 15
  • 16. Why Concurrency Control is needed (continued) 4. Unrepeatable Read problem: A transaction reads items twice with two different values because it was changed by another transaction between the two reads. By C.Aruna (DSCASC) 16 T1 Read-item(my-account) Read-item(my-account) T2 Read-item(my-account) My-account:= my-account + 1000 Write-item(my-account) Eg: Bank, Flight Reservation – A customer enquires about seat availability in diff. flights. When he decides to book, the no. of seats will be different because of T2 updates the no.of seats.
  • 17. By C.Aruna (DSCASC) 17 Why Recovery Is Needed There several possible reasons for a transaction to fail A computer failure : A hardware, software, or network error occurs in the computer system during transaction execution. A transaction or system error : Some operations in the transaction may cause it to fail. Local errors or exception conditions detected by the transaction.
  • 18. By C.Aruna (DSCASC) 18 Why Recovery Is Needed (continued) Concurrency control enforcement : The concurrency control method may decide to abort the transaction. Disk failure : all disk or some disk blocks may lose their data. Physical problems : Disasters, theft, fire, etc. The system must keep sufficient information to recover from the failure.
  • 19. By C.Aruna (DSCASC) 19 Transaction states and additional operations A transaction is an atomic unit of work that is either completed in its entirety or not done at all. For recovery purposes the system needs to keep track of when the transaction starts, terminates, and commits or aborts. The recovery manager keeps track of the following operations : BEGIN_TRANSACTION READ OR WRITE END_TRANSACTION COMMIT_TRANSACTION ROLLBACK
  • 20. By C.Aruna (DSCASC) 20 Transaction states BEGIN_TRANSACTION: This marks the beginning of transaction execution. READ OR WRITE: Specifies READ or WRITE transaction operations on the database items that are executed as part of a transaction. END_TRANSACTION: Specifies the READ and WRITE transaction operations have ended and marks the end of transaction execution. COMMIT_TRANSACTION: This signals a successful end of the transaction. ROLLBACK (or ABORT): This signals that the transaction has ended unsuccessfully, so that any changes or effects that the transaction may have applied to the database must be undone.
  • 21. By C.Aruna (DSCASC) 21 ACTIVE PARTIALLY COMMITTED FAILED TERMINATED COMMITTED BEGIN TRANSACTION END TRANSACTION COMMIT ABORT ABORT Figure 19.4 State transition diagram illustrating the states for transaction execution READ/ WRITE Transaction states
  • 22. By C.Aruna (DSCASC) 22 Transaction states  A state transition diagram that describes how a transaction moves through its execution states.  A transaction goes into active state immediately after it starts execution, where it can issue READ and WRITE operations.  When the transaction ends it moves to the partially committed state.  At this point some recovery protocols need to ensure that a system failure will not result in an inability to record the changes of the transaction permanently.  Once this check is successful the transaction is said to have reached its commit point and enters the committed state.  A transaction can go to failed state if one of the checks fails or if the transaction is aborted during its active state.  The transaction may then have to be rolled back to undo the effect of its WRITE operations on the database.  The terminated state corresponds to the transaction leaving the system.
  • 23. Properties of transactions Properties of transactions: ACID  Atomicity Consistency preservation Isolation  Durability By C.Aruna (DSCASC) 23
  • 24. By C.Aruna (DSCASC) 24 Properties of transactions ACID should be enforced by the concurrency control and recovery methods of the DBMS. ACID properties of transactions : Atomicity : a transaction is an atomic unit of processing; it is either performed entirely or not performed at all. (It is the responsibility of recovery) Consistency : transfer the database from one consistent state to another consistent state (It is the responsibility of the applications and DBMS to maintain the constraints)
  • 25. By C.Aruna (DSCASC) 25 Properties of transactions (continued) Isolation : the execution of the transaction should be isolated from other transactions (Locking) (It is the responsibility of concurrency) * Isolation level: - Level 0 (no dirty read) - Level 1 ( no lost update) - Level 2 (no dirty+ no lost) - Level 3 (level 2+repeatable reads) Durability : committed transactions must persist in the database ,i.e. those changes must not be lost because of any failure. (It is the responsibility of recovery)
  • 26. • Atomicity – Recovery system • Consistency – Programmer + DBMS • Isolation – Concurrency control • Durability – Recovery system By C.Aruna (DSCASC) 26
  • 27. Serial and serializability of schedules • A schedule S is serial if in the operations in each transaction in S are executed directly after each other. • A schedule S is serializable if there is an equivalent serial schedule S'. • Equivalent: conflict equivalence By C.Aruna (DSCASC) 27
  • 28. Transactions T1 Read-item(my-account) My-account := my-account - 2000 Write-item(my-account) Read-item(other-account) Other-account := other-account + 2000 Write-item(other-account) By C.Aruna (DSCASC) 28 T2 Read-item(my-account) My-account := my-account +1000 Write-item(my-account)
  • 29. Example of Serial Schedules T1 Read-item(my-account) My-account := my-account - 2000 Write-item(my-account) Read-item(other-account) Other-account := other-account + 2000 Write-item(other-account) By C.Aruna (DSCASC) 29 T2 Read-item(my-account) My-account := my-account +1000 Write-item(my-account)
  • 30. Example of Serial Schedules T1 Read-item(my-account) My-account := my-account - 2000 Write-item(my-account) Read-item(other-account) Other-account := other-account + 2000 Write-item(other-account) By C.Aruna (DSCASC) 30 T2 Read-item(my-account) My-account := my-account +1000 Write-item(my-account)
  • 31. Example of Non-serial Schedules time T1: T2: read_item(X); X:= X - N; read_item(X); X:= X + M; write_item(X); read_item(Y); write_item(X); Y:=Y + N; write_item(Y); Schedule A 31By C.Aruna (DSCASC)