SlideShare une entreprise Scribd logo
1  sur  12
3. Acid Property of Transactions
Transactions should possess several properties. These are often
called the acid properties, and they should be enforced by the
concurrency control and recovery methods of the DBMS.
♦ Acid properties:
▪ Atomicity:
Transaction is an atomic unit of processing; Performed entirety or not.

▪ Consistency preservation:
▪ Isolation:
Execution of a transaction should not be interfered with other transactions.

▪ Durability or permanency:
The changes applied to the database by a committed transaction must persist
in the database.
3. Acid Property of Transactions
▪ Atomicity:
Consider the case of funds transfer from account a to account b.
A.bal -= amount;
B.bal += amount;
A.bal -= amount;
Crash
…
…
Recovery
A.bal += amount;
 rollback

Within the scope of a transaction
- all changes occur together or no changes occur
- atomicity is the responsibility of the transaction manager
Ex) a money transfer, debit removes funds, credit add funds, no funds are lost!
3. Acid Property of Transactions
▪ Consistency preservation:
• Consider the case of funds transfer from account a to account b.
A.bal -= amount;
B.bal += amount;
A.bal -= amount;
B.bal += amount(fails!! A’s balance is 0)
A.bal += amount;
 rollback
• Transactions scope a set of operations
- consistency can be violated within a transaction
- transaction must be correct according to application rules
- begin and commit are points of consistency
- consistency preservation is a property of a transaction, not of the tp system.
3. Acid Property of Transactions
▪ Isolation :
• Consider the case of funds transfer from account a to account b.
Transaction t1:
A.bal -= amount; (let a’s balance become 0 after this…)
B.bal += amount;
Transaction t2:
A.bal -= amount2;
Net effect should be either t1,t2 (in which case t2 fails) or
t2,t1 (in which case t1 fails).
3. Acid Property of Transactions
▪ Durability :
• Consider the case of funds transfer from account a to account b.
Account a should have a balance of amount
Transaction t1:
A.bal -= amount;
B.bal += amount;
Commit
Account a should have a balance of 0.
• When a transaction commits, its results must survive failures
– must be durably recorded prior to commit
– system waits for disk ask before asking to user
• If a transaction rolls back, changes must be undone
– before images recorded
– undo processing after failure
4. Transaction States
◆ Transaction States
Active: initial state; when the transaction is executing
Partially committed: when the last statement has finished execution
Failed: on discovery that normal execution can no longer proceed
Aborted: after the rollback is performed from a failed transaction
Committed: after successful completion
Terminated: either committed or aborted
4. Transaction States
◆ Transaction Execution
A transaction reaches its commit point when all operations accessing the
database are completed and the result has been recorded in the log. It
then writes a [commit, transaction-id].

If a system failure occurs, searching the log and rollback the transactions
that have written into the log a
[start_transaction, transaction-id]
[write_item, transaction-id, x, old_value, new_value]
But have not recorded into the log a [commit, transaction-id]
4. Transaction States
◆ Transaction states and additional operations
For recovery purposes, the system needs to keep track of when the transaction
starts, terminates, and commits or aborts (see below).
Hence, the recovery manager keeps track of the following operations:
Begin transaction:
End transaction:
Commit transaction:
Rollback (or abort):
4. Transaction States
◆ Acid using shadow copy
• Assume that only one transaction is active at a time.
• db pointer always points to the current consistent copy of
the database.
• All updates are made on a shadow copy of the database, and
db pointer is made to point to the updated shadow copy only
after the transaction reaches partial commit and all updated
pages have been flushed to disk.
• In case transaction fails, old consistent copy pointed to by
db pointer can be used, and the shadow copy can be deleted.
• Simple but extremely inefficient implementation
• Assumes database to be a file.
4. Transaction States
◆ The shadow-database scheme

This assumes disks do not fail. It is useful for text editors, but extremely
inefficient for large databases and does not handle concurrent
transactions.
4. Transaction States
◆ Transaction as a Concurrency Unit
Transactions must be synchronized for database consistency.
4. Transaction States
◆ Concurrent executions
Multiple transactions are allowed to run concurrently.

Advantages are:
Increased processor and disk utilization
Reduced average response time for transactions
Concurrency control schemes

Contenu connexe

En vedette

Dbms ii mca-ch9-transaction-processing-2013
Dbms ii mca-ch9-transaction-processing-2013Dbms ii mca-ch9-transaction-processing-2013
Dbms ii mca-ch9-transaction-processing-2013Prosanta Ghosh
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitorssgpraju
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating SystemsRitu Ranjan Shrivastwa
 
deadlock prevention
deadlock preventiondeadlock prevention
deadlock preventionNilu Desai
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactionsNilu Desai
 
Distributed databases,types of database
Distributed databases,types of databaseDistributed databases,types of database
Distributed databases,types of databaseBoomadevi Shanmugam
 
Transaction Management
Transaction Management Transaction Management
Transaction Management Visakh V
 
Transaction management DBMS
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMSMegha Patel
 
Chapter 5 Database Transaction Management
Chapter 5 Database Transaction ManagementChapter 5 Database Transaction Management
Chapter 5 Database Transaction ManagementEddyzulham Mahluzydde
 
Transaction management
Transaction managementTransaction management
Transaction managementrenuka_a
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMSkoolkampus
 

En vedette (16)

Dbms ii mca-ch9-transaction-processing-2013
Dbms ii mca-ch9-transaction-processing-2013Dbms ii mca-ch9-transaction-processing-2013
Dbms ii mca-ch9-transaction-processing-2013
 
Dbms acid
Dbms acidDbms acid
Dbms acid
 
Acid properties
Acid propertiesAcid properties
Acid properties
 
Distributed deadlock
Distributed deadlockDistributed deadlock
Distributed deadlock
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
 
Primary and secondary needs
Primary and secondary needsPrimary and secondary needs
Primary and secondary needs
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
deadlock prevention
deadlock preventiondeadlock prevention
deadlock prevention
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactions
 
Distributed databases,types of database
Distributed databases,types of databaseDistributed databases,types of database
Distributed databases,types of database
 
Transaction Management
Transaction Management Transaction Management
Transaction Management
 
Transaction management DBMS
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMS
 
Chapter 5 Database Transaction Management
Chapter 5 Database Transaction ManagementChapter 5 Database Transaction Management
Chapter 5 Database Transaction Management
 
Transaction management
Transaction managementTransaction management
Transaction management
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 

Similaire à 3 transaction

Transaction management and concurrency
Transaction management and concurrencyTransaction management and concurrency
Transaction management and concurrencyVenkata Sreeram
 
ch 5 Daatabase Recovery.ppt
ch 5 Daatabase Recovery.pptch 5 Daatabase Recovery.ppt
ch 5 Daatabase Recovery.pptAdemeCheklie
 
7. transaction mang
7. transaction mang7. transaction mang
7. transaction mangkhoahuy82
 
Chapter 12 transactions and concurrency control
Chapter 12 transactions and concurrency controlChapter 12 transactions and concurrency control
Chapter 12 transactions and concurrency controlAbDul ThaYyal
 
Transaction Properties(ACID Properties)
Transaction Properties(ACID Properties)Transaction Properties(ACID Properties)
Transaction Properties(ACID Properties)Yaksh Jethva
 
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptxFALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptxhritikraj888
 
Transaction Processing Concept
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing ConceptNishant Munjal
 
Unit iv -Transactions
Unit iv -TransactionsUnit iv -Transactions
Unit iv -TransactionsDhivyaa C.R
 
What is Database Backup? The 3 Important Recovery Techniques from transaction...
What is Database Backup? The 3 Important Recovery Techniques from transaction...What is Database Backup? The 3 Important Recovery Techniques from transaction...
What is Database Backup? The 3 Important Recovery Techniques from transaction...Raj vardhan
 
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
 
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
 
Transactionsmanagement
TransactionsmanagementTransactionsmanagement
TransactionsmanagementSanjeev Gupta
 
Transaction & Concurrency Control
Transaction & Concurrency ControlTransaction & Concurrency Control
Transaction & Concurrency ControlRavimuthurajan
 

Similaire à 3 transaction (20)

Transaction management and concurrency
Transaction management and concurrencyTransaction management and concurrency
Transaction management and concurrency
 
ch 5 Daatabase Recovery.ppt
ch 5 Daatabase Recovery.pptch 5 Daatabase Recovery.ppt
ch 5 Daatabase Recovery.ppt
 
7. transaction mang
7. transaction mang7. transaction mang
7. transaction mang
 
Chapter 12 transactions and concurrency control
Chapter 12 transactions and concurrency controlChapter 12 transactions and concurrency control
Chapter 12 transactions and concurrency control
 
ch-5 advanced db.pdf
ch-5 advanced db.pdfch-5 advanced db.pdf
ch-5 advanced db.pdf
 
Transaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptxTransaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptx
 
Transaction Properties(ACID Properties)
Transaction Properties(ACID Properties)Transaction Properties(ACID Properties)
Transaction Properties(ACID Properties)
 
19.TRANSACTIONs.ppt
19.TRANSACTIONs.ppt19.TRANSACTIONs.ppt
19.TRANSACTIONs.ppt
 
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptxFALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
 
Unit 4 dbms
Unit 4 dbmsUnit 4 dbms
Unit 4 dbms
 
transaction_processing.ppt
transaction_processing.ppttransaction_processing.ppt
transaction_processing.ppt
 
Transaction Processing Concept
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing Concept
 
Lec08
Lec08Lec08
Lec08
 
Unit iv -Transactions
Unit iv -TransactionsUnit iv -Transactions
Unit iv -Transactions
 
What is Database Backup? The 3 Important Recovery Techniques from transaction...
What is Database Backup? The 3 Important Recovery Techniques from transaction...What is Database Backup? The 3 Important Recovery Techniques from transaction...
What is Database Backup? The 3 Important Recovery Techniques from transaction...
 
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 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
 
Transactionsmanagement
TransactionsmanagementTransactionsmanagement
Transactionsmanagement
 
DBMS Vardhaman.pdf
DBMS Vardhaman.pdfDBMS Vardhaman.pdf
DBMS Vardhaman.pdf
 
Transaction & Concurrency Control
Transaction & Concurrency ControlTransaction & Concurrency Control
Transaction & Concurrency Control
 

Plus de Mr Patrick NIYISHAKA (20)

Summary
SummarySummary
Summary
 
3 summary
3 summary3 summary
3 summary
 
2 ddb architecture
2 ddb architecture2 ddb architecture
2 ddb architecture
 
1 ddb
1 ddb1 ddb
1 ddb
 
2 countermeasures
2 countermeasures2 countermeasures
2 countermeasures
 
2 countermeasures
2 countermeasures2 countermeasures
2 countermeasures
 
3 summary
3 summary3 summary
3 summary
 
1 db security
1 db security1 db security
1 db security
 
4 summary
4 summary4 summary
4 summary
 
3 summary
3 summary3 summary
3 summary
 
2 con control
2 con control2 con control
2 con control
 
1 con exe
1 con exe1 con exe
1 con exe
 
1 basic concepts
1 basic concepts1 basic concepts
1 basic concepts
 
2 recovery
2 recovery2 recovery
2 recovery
 
3 summary
3 summary3 summary
3 summary
 
1 query processing
1 query processing1 query processing
1 query processing
 
1 query processing
1 query processing1 query processing
1 query processing
 
2 optimization
2 optimization2 optimization
2 optimization
 
2 collision
2 collision2 collision
2 collision
 
4 summary
4 summary4 summary
4 summary
 

Dernier

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Dernier (20)

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

3 transaction

  • 1. 3. Acid Property of Transactions Transactions should possess several properties. These are often called the acid properties, and they should be enforced by the concurrency control and recovery methods of the DBMS. ♦ Acid properties: ▪ Atomicity: Transaction is an atomic unit of processing; Performed entirety or not. ▪ Consistency preservation: ▪ Isolation: Execution of a transaction should not be interfered with other transactions. ▪ Durability or permanency: The changes applied to the database by a committed transaction must persist in the database.
  • 2. 3. Acid Property of Transactions ▪ Atomicity: Consider the case of funds transfer from account a to account b. A.bal -= amount; B.bal += amount; A.bal -= amount; Crash … … Recovery A.bal += amount;  rollback Within the scope of a transaction - all changes occur together or no changes occur - atomicity is the responsibility of the transaction manager Ex) a money transfer, debit removes funds, credit add funds, no funds are lost!
  • 3. 3. Acid Property of Transactions ▪ Consistency preservation: • Consider the case of funds transfer from account a to account b. A.bal -= amount; B.bal += amount; A.bal -= amount; B.bal += amount(fails!! A’s balance is 0) A.bal += amount;  rollback • Transactions scope a set of operations - consistency can be violated within a transaction - transaction must be correct according to application rules - begin and commit are points of consistency - consistency preservation is a property of a transaction, not of the tp system.
  • 4. 3. Acid Property of Transactions ▪ Isolation : • Consider the case of funds transfer from account a to account b. Transaction t1: A.bal -= amount; (let a’s balance become 0 after this…) B.bal += amount; Transaction t2: A.bal -= amount2; Net effect should be either t1,t2 (in which case t2 fails) or t2,t1 (in which case t1 fails).
  • 5. 3. Acid Property of Transactions ▪ Durability : • Consider the case of funds transfer from account a to account b. Account a should have a balance of amount Transaction t1: A.bal -= amount; B.bal += amount; Commit Account a should have a balance of 0. • When a transaction commits, its results must survive failures – must be durably recorded prior to commit – system waits for disk ask before asking to user • If a transaction rolls back, changes must be undone – before images recorded – undo processing after failure
  • 6. 4. Transaction States ◆ Transaction States Active: initial state; when the transaction is executing Partially committed: when the last statement has finished execution Failed: on discovery that normal execution can no longer proceed Aborted: after the rollback is performed from a failed transaction Committed: after successful completion Terminated: either committed or aborted
  • 7. 4. Transaction States ◆ Transaction Execution A transaction reaches its commit point when all operations accessing the database are completed and the result has been recorded in the log. It then writes a [commit, transaction-id]. If a system failure occurs, searching the log and rollback the transactions that have written into the log a [start_transaction, transaction-id] [write_item, transaction-id, x, old_value, new_value] But have not recorded into the log a [commit, transaction-id]
  • 8. 4. Transaction States ◆ Transaction states and additional operations For recovery purposes, the system needs to keep track of when the transaction starts, terminates, and commits or aborts (see below). Hence, the recovery manager keeps track of the following operations: Begin transaction: End transaction: Commit transaction: Rollback (or abort):
  • 9. 4. Transaction States ◆ Acid using shadow copy • Assume that only one transaction is active at a time. • db pointer always points to the current consistent copy of the database. • All updates are made on a shadow copy of the database, and db pointer is made to point to the updated shadow copy only after the transaction reaches partial commit and all updated pages have been flushed to disk. • In case transaction fails, old consistent copy pointed to by db pointer can be used, and the shadow copy can be deleted. • Simple but extremely inefficient implementation • Assumes database to be a file.
  • 10. 4. Transaction States ◆ The shadow-database scheme This assumes disks do not fail. It is useful for text editors, but extremely inefficient for large databases and does not handle concurrent transactions.
  • 11. 4. Transaction States ◆ Transaction as a Concurrency Unit Transactions must be synchronized for database consistency.
  • 12. 4. Transaction States ◆ Concurrent executions Multiple transactions are allowed to run concurrently. Advantages are: Increased processor and disk utilization Reduced average response time for transactions Concurrency control schemes