SlideShare a Scribd company logo
1 of 16
Transaction Management 
Overview
Transactions 
• Concurrent execution of user programs is essential for good 
DBMS performance. 
– Because disk accesses are frequent, and relatively slow, it is 
important to keep the cpu humming by working on several user 
programs concurrently. 
• A user’s program may carry out many operations on the data 
retrieved from the database, but the DBMS is only concerned 
about what data is read/written from/to the database. 
• A transaction is the DBMS’s abstract view of a user program: a 
sequence of reads and writes.
Concurrency in a DBMS 
• Users submit transactions, and can think of each transaction as 
executing by itself. 
– Concurrency is achieved by the DBMS, which interleaves actions 
(reads/writes of DB objects) of various transactions. 
– Each transaction must leave the database in a consistent state if the 
DB is consistent when the transaction begins. 
• DBMS will enforce some ICs, depending on the ICs declared 
in CREATE TABLE statements. 
• Beyond this, the DBMS does not really understand the 
semantics of the data. (e.g., it does not understand how the 
interest on a bank account is computed). 
• Issues: Effect of interleaving transactions, and crashes.
Atomicity of Transactions 
• A transaction might commit after completing all its actions, or it 
could abort (or be aborted by the DBMS) after executing some 
actions. 
• A very important property guaranteed by the DBMS for all 
transactions is that they are atomic. That is, a user can think of a 
Xact as always executing all its actions in one step, or not executing 
any actions at all. 
– DBMS logs all actions so that it can undo the actions of aborted 
transactions.
Example 
• Consider two transactions (Xacts): 
T1: BEGIN A=A+100, B=B-100 END 
T2: BEGIN A=1.06*A, B=1.06*B END 
 Intuitively, the first transaction is transferring $100 from 
B’s account to A’s account. The second is crediting both 
accounts with a 6% interest payment. 
 There is no guarantee that T1 will execute before T2 or 
vice-versa, if both are submitted together. However, the net 
effect must be equivalent to these two transactions running 
serially in some order.
Example (Contd.) 
• Consider a possible interleaving (schedule): 
T1: A=A+100, B=B-100 
T2: A=1.06*A, B=1.06*B 
 This is OK. But what about: 
T1: A=A+100, B=B-100 
T2: A=1.06*A, B=1.06*B 
 The DBMS’s view of the second schedule: 
T1: R(A), W(A), R(B), W(B) 
T2: R(A), W(A), R(B), W(B)
Scheduling Transactions 
• Serial schedule: Schedule that does not interleave the actions of 
different transactions. 
• Equivalent schedules: For any database state, the effect (on the set of 
objects in the database) of executing the first schedule is identical to 
the effect of executing the second schedule. 
• Serializable schedule: A schedule that is equivalent to some serial 
execution of the transactions. 
(Note: If each transaction preserves consistency, every serializable 
schedule preserves consistency. )
Anomalies with Interleaved Execution 
• Reading Uncommitted Data (WR Conflicts, 
“dirty reads”): 
T1: R(A), W(A), R(B), W(B), Abort 
T2: R(A), W(A), C 
• Unrepeatable Reads (RW Conflicts): 
T1: R(A), R(A), W(A), C 
T2: R(A), W(A), C
Anomalies (Continued) 
• Overwriting Uncommitted Data (WW 
Conflicts): 
T1: W(A), W(B), C 
T2: W(A), W(B), C
Lock-Based Concurrency Control 
• Strict Two-phase Locking (Strict 2PL) Protocol: 
– Each Xact must obtain a S (shared) lock on object before reading, and an X 
(exclusive) lock on object before writing. 
– All locks held by a transaction are released when the transaction completes 
• (Non-strict) 2PL Variant: Release locks anytime, but cannot acquire locks 
after releasing any lock. 
– If an Xact holds an X lock on an object, no other Xact can get a lock (S or X) 
on that object. 
• Strict 2PL allows only serializable schedules. 
– Additionally, it simplifies transaction aborts 
– (Non-strict) 2PL also allows only serializable schedules, but involves more 
complex abort processing
Aborting a Transaction 
• If a transaction Ti is aborted, all its actions have to be undone. Not 
only that, if Tj reads an object last written by Ti, Tj must be aborted 
as well! 
• Most systems avoid such cascading aborts by releasing a 
transaction’s locks only at commit time. 
– If Ti writes an object, Tj can read this only after Ti commits. 
• In order to undo the actions of an aborted transaction, the DBMS 
maintains a log in which every write is recorded. This mechanism is 
also used to recover from system crashes: all active Xacts at the time 
of the crash are aborted when the system comes back up.
The Log 
• The following actions are recorded in the log: 
– Ti writes an object: the old value and the new value. 
• Log record must go to disk before the changed page! 
– Ti commits/aborts: a log record indicating this action. 
• Log records are chained together by Xact id, so it’s easy to undo a 
specific Xact. 
• Log is often duplexed and archived on stable storage. 
• All log related activities (and in fact, all CC related activities such as 
lock/unlock, dealing with deadlocks etc.) are handled transparently by 
the DBMS.
Recovering From a Crash 
• There are 3 phases in the Aries recovery algorithm: 
– Analysis: Scan the log forward (from the most recent checkpoint) 
to identify all Xacts that were active, and all dirty pages in the 
buffer pool at the time of the crash. 
– Redo: Redoes all updates to dirty pages in the buffer pool, as 
needed, to ensure that all logged updates are in fact carried out and 
written to disk. 
– Undo: The writes of all Xacts that were active at the crash are 
undone (by restoring the before value of the update, which is in 
the log record for the update), working backwards in the log. 
(Some care must be taken to handle the case of a crash occurring 
during the recovery process!)
ACID Properties of Transaction 
• Atomicity: All or none, either every part of a 
transaction gets completed, or none of it does at all. If 
everything works correctly without any errors, 
everything gets committed to the database. If any one 
part of the transaction fails, the entire transaction gets 
rolled back. 
• Consistency: This property ensures that the state of 
the database is the same when it ends as it was when 
it began, and that no rules or constraints of the 
database are violated as a result of the transaction. 
Any violation of rules or constraints will cause the 
transaction to fail.
ACID Properties of Transaction 
• Isolation: The operations that take place within a 
transaction are isolated from the operations of 
other transactions or other database operations, 
and that no other transaction or operation can 
have access in any way to the data that's being 
affected by a transaction in it's intermediate state 
(while the transaction is taking place). 
• Durability: The guarantee that once a transaction 
has completed, the results of it will persist and 
remain accurate and stable within the database.
Summary 
• Concurrency control and recovery are among the most important 
functions provided by a DBMS. 
• Users need not worry about concurrency. 
– System automatically inserts lock/unlock requests and schedules 
actions of different Xacts in such a way as to ensure that the 
resulting execution is equivalent to executing the Xacts one after 
the other in some order. 
• Write-ahead logging (WAL) is used to undo the actions of aborted 
transactions and to restore the system to a consistent state after a 
crash. 
– Consistent state: Only the effects of commited Xacts seen.

More Related Content

What's hot

Validation based protocol
Validation based protocolValidation based protocol
Validation based protocolBBDITM LUCKNOW
 
Databases: Concurrency Control
Databases: Concurrency ControlDatabases: Concurrency Control
Databases: Concurrency ControlDamian T. Gordon
 
Databases: Locking Methods
Databases: Locking MethodsDatabases: Locking Methods
Databases: Locking MethodsDamian T. Gordon
 
Multiversion Concurrency Control Techniques
Multiversion Concurrency Control TechniquesMultiversion Concurrency Control Techniques
Multiversion Concurrency Control TechniquesRaj vardhan
 
Transaction management in DBMS
Transaction management in DBMSTransaction management in DBMS
Transaction management in DBMSMegha Sharma
 
Concurrency control
Concurrency controlConcurrency control
Concurrency controlkansel85
 
Timestamp based protocol
Timestamp based protocolTimestamp based protocol
Timestamp based protocolVincent Chu
 
Database management system chapter16
Database management system chapter16Database management system chapter16
Database management system chapter16Md. Mahedi Mahfuj
 
Concurrent transactions
Concurrent transactionsConcurrent transactions
Concurrent transactionsSajan Sahu
 

What's hot (20)

Validation based protocol
Validation based protocolValidation based protocol
Validation based protocol
 
Databases: Concurrency Control
Databases: Concurrency ControlDatabases: Concurrency Control
Databases: Concurrency Control
 
Concurrency control
Concurrency control Concurrency control
Concurrency control
 
Databases: Locking Methods
Databases: Locking MethodsDatabases: Locking Methods
Databases: Locking Methods
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Multiversion Concurrency Control Techniques
Multiversion Concurrency Control TechniquesMultiversion Concurrency Control Techniques
Multiversion Concurrency Control Techniques
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Chapter17
Chapter17Chapter17
Chapter17
 
Timestamp protocols
Timestamp protocolsTimestamp protocols
Timestamp protocols
 
Schedule in DBMS
Schedule in DBMSSchedule in DBMS
Schedule in DBMS
 
Unit 6
Unit 6Unit 6
Unit 6
 
Transaction management in DBMS
Transaction management in DBMSTransaction management in DBMS
Transaction management in DBMS
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Timestamp based protocol
Timestamp based protocolTimestamp based protocol
Timestamp based protocol
 
Database management system chapter16
Database management system chapter16Database management system chapter16
Database management system chapter16
 
Concurrent transactions
Concurrent transactionsConcurrent transactions
Concurrent transactions
 
2 phase locking protocol DBMS
2 phase locking protocol DBMS2 phase locking protocol DBMS
2 phase locking protocol DBMS
 
DBMS - Transactions
DBMS - TransactionsDBMS - Transactions
DBMS - Transactions
 
concurrency-control
concurrency-controlconcurrency-control
concurrency-control
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 

Viewers also liked

Transactions in dbms
Transactions in dbmsTransactions in dbms
Transactions in dbmsNancy Gulati
 
24. Advanced Transaction Processing in DBMS
24. Advanced Transaction Processing in DBMS24. Advanced Transaction Processing in DBMS
24. Advanced Transaction Processing in DBMSkoolkampus
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMSkoolkampus
 
Sedna XML Database: Transactions and Recovery
Sedna XML Database: Transactions and RecoverySedna XML Database: Transactions and Recovery
Sedna XML Database: Transactions and RecoveryIvan Shcheklein
 
Mca ii-dbms-u-v-transaction management
Mca ii-dbms-u-v-transaction managementMca ii-dbms-u-v-transaction management
Mca ii-dbms-u-v-transaction managementRai University
 
Transaction Management - Lecture 11 - Introduction to Databases (1007156ANR)
Transaction Management - Lecture 11 - Introduction to Databases (1007156ANR)Transaction Management - Lecture 11 - Introduction to Databases (1007156ANR)
Transaction Management - Lecture 11 - Introduction to Databases (1007156ANR)Beat Signer
 
Slide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schemaSlide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schemaVisakh V
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic ConceptsTony Wong
 
Transaction Management
Transaction Management Transaction Management
Transaction Management Visakh V
 
Chapter 5 Database Transaction Management
Chapter 5 Database Transaction ManagementChapter 5 Database Transaction Management
Chapter 5 Database Transaction ManagementEddyzulham Mahluzydde
 
4. concurrency control
4. concurrency control4. concurrency control
4. concurrency controlAbDul ThaYyal
 
16. Concurrency Control in DBMS
16. Concurrency Control in DBMS16. Concurrency Control in DBMS
16. Concurrency Control in DBMSkoolkampus
 

Viewers also liked (17)

Transactions in dbms
Transactions in dbmsTransactions in dbms
Transactions in dbms
 
24. Advanced Transaction Processing in DBMS
24. Advanced Transaction Processing in DBMS24. Advanced Transaction Processing in DBMS
24. Advanced Transaction Processing in DBMS
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 
Sedna XML Database: Transactions and Recovery
Sedna XML Database: Transactions and RecoverySedna XML Database: Transactions and Recovery
Sedna XML Database: Transactions and Recovery
 
Mca ii-dbms-u-v-transaction management
Mca ii-dbms-u-v-transaction managementMca ii-dbms-u-v-transaction management
Mca ii-dbms-u-v-transaction management
 
Transaction Management - Lecture 11 - Introduction to Databases (1007156ANR)
Transaction Management - Lecture 11 - Introduction to Databases (1007156ANR)Transaction Management - Lecture 11 - Introduction to Databases (1007156ANR)
Transaction Management - Lecture 11 - Introduction to Databases (1007156ANR)
 
Data independence
Data independenceData independence
Data independence
 
Slide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schemaSlide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schema
 
Advanced DBMS presentation
Advanced DBMS presentationAdvanced DBMS presentation
Advanced DBMS presentation
 
Distributed deadlock
Distributed deadlockDistributed deadlock
Distributed deadlock
 
Dbms architecture
Dbms architectureDbms architecture
Dbms architecture
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic Concepts
 
Transaction Management
Transaction Management Transaction Management
Transaction Management
 
Chapter 5 Database Transaction Management
Chapter 5 Database Transaction ManagementChapter 5 Database Transaction Management
Chapter 5 Database Transaction Management
 
4. concurrency control
4. concurrency control4. concurrency control
4. concurrency control
 
16. Concurrency Control in DBMS
16. Concurrency Control in DBMS16. Concurrency Control in DBMS
16. Concurrency Control in DBMS
 
Concurrent control
Concurrent controlConcurrent control
Concurrent control
 

Similar to 7. transaction mang

Transaction & Concurrency Control
Transaction & Concurrency ControlTransaction & Concurrency Control
Transaction & Concurrency ControlRavimuthurajan
 
Dartabase Transaction.pptx
Dartabase Transaction.pptxDartabase Transaction.pptx
Dartabase Transaction.pptxBibus Poudel
 
Concepts of Data Base Management Systems
Concepts of Data Base Management SystemsConcepts of Data Base Management Systems
Concepts of Data Base Management SystemsDinesh Devireddy
 
Transaction Processing Concept
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing ConceptNishant Munjal
 
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
 
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...DrCViji
 
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
 
recovery system
recovery systemrecovery system
recovery systemshreeuva
 
DBMS-chap 2-Concurrency Control
DBMS-chap 2-Concurrency ControlDBMS-chap 2-Concurrency Control
DBMS-chap 2-Concurrency ControlMukesh Tekwani
 

Similar to 7. transaction mang (20)

Transaction & Concurrency Control
Transaction & Concurrency ControlTransaction & Concurrency Control
Transaction & Concurrency Control
 
Lec08
Lec08Lec08
Lec08
 
Dartabase Transaction.pptx
Dartabase Transaction.pptxDartabase Transaction.pptx
Dartabase Transaction.pptx
 
transaction_processing.ppt
transaction_processing.ppttransaction_processing.ppt
transaction_processing.ppt
 
Unit 06 dbms
Unit 06 dbmsUnit 06 dbms
Unit 06 dbms
 
Unit 4 dbms
Unit 4 dbmsUnit 4 dbms
Unit 4 dbms
 
Transaction processing
Transaction processingTransaction processing
Transaction processing
 
Concepts of Data Base Management Systems
Concepts of Data Base Management SystemsConcepts of Data Base Management Systems
Concepts of Data Base Management Systems
 
Tybsc cs dbms2 notes
Tybsc cs dbms2 notesTybsc cs dbms2 notes
Tybsc cs dbms2 notes
 
Transaction Processing Concept
Transaction Processing ConceptTransaction Processing Concept
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 RECOVERY
 
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...
 
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
 
Ch 9
Ch 9Ch 9
Ch 9
 
Transactions
TransactionsTransactions
Transactions
 
recovery system
recovery systemrecovery system
recovery system
 
DBMS 4.pdf
DBMS 4.pdfDBMS 4.pdf
DBMS 4.pdf
 
Transactions
TransactionsTransactions
Transactions
 
DBMS-chap 2-Concurrency Control
DBMS-chap 2-Concurrency ControlDBMS-chap 2-Concurrency Control
DBMS-chap 2-Concurrency Control
 
DBMS UNIT 4
DBMS UNIT 4DBMS UNIT 4
DBMS UNIT 4
 

More from khoahuy82

13. case study
13. case study13. case study
13. case studykhoahuy82
 
6. normalization
6. normalization6. normalization
6. normalizationkhoahuy82
 
5. relational structure
5. relational structure5. relational structure
5. relational structurekhoahuy82
 
4. case study
4. case study4. case study
4. case studykhoahuy82
 
Cac phuong phap tim kiem tham do
Cac phuong phap tim kiem tham doCac phuong phap tim kiem tham do
Cac phuong phap tim kiem tham dokhoahuy82
 
07 2 chapter7-cross-section diagrams in 3 dimentions part 2-2
07 2 chapter7-cross-section diagrams in 3 dimentions part 2-207 2 chapter7-cross-section diagrams in 3 dimentions part 2-2
07 2 chapter7-cross-section diagrams in 3 dimentions part 2-2khoahuy82
 
01 begin & chapter1
01 begin & chapter101 begin & chapter1
01 begin & chapter1khoahuy82
 
06 chuong 6 moi truong ngam
06 chuong 6 moi truong ngam06 chuong 6 moi truong ngam
06 chuong 6 moi truong ngamkhoahuy82
 

More from khoahuy82 (19)

13. case study
13. case study13. case study
13. case study
 
8. sql
8. sql8. sql
8. sql
 
20. quiz
20. quiz20. quiz
20. quiz
 
1. intro
1. intro1. intro
1. intro
 
19. quiz
19. quiz19. quiz
19. quiz
 
6. normalization
6. normalization6. normalization
6. normalization
 
5. relational structure
5. relational structure5. relational structure
5. relational structure
 
4. case study
4. case study4. case study
4. case study
 
Ch6
Ch6Ch6
Ch6
 
Ch7
Ch7Ch7
Ch7
 
Ch5
Ch5Ch5
Ch5
 
Ch4
Ch4Ch4
Ch4
 
Ch3
Ch3Ch3
Ch3
 
Ch1
Ch1Ch1
Ch1
 
Ch2
Ch2Ch2
Ch2
 
Cac phuong phap tim kiem tham do
Cac phuong phap tim kiem tham doCac phuong phap tim kiem tham do
Cac phuong phap tim kiem tham do
 
07 2 chapter7-cross-section diagrams in 3 dimentions part 2-2
07 2 chapter7-cross-section diagrams in 3 dimentions part 2-207 2 chapter7-cross-section diagrams in 3 dimentions part 2-2
07 2 chapter7-cross-section diagrams in 3 dimentions part 2-2
 
01 begin & chapter1
01 begin & chapter101 begin & chapter1
01 begin & chapter1
 
06 chuong 6 moi truong ngam
06 chuong 6 moi truong ngam06 chuong 6 moi truong ngam
06 chuong 6 moi truong ngam
 

Recently uploaded

Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...amitlee9823
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...amitlee9823
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...amitlee9823
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 

Recently uploaded (20)

Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 

7. transaction mang

  • 2. Transactions • Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are frequent, and relatively slow, it is important to keep the cpu humming by working on several user programs concurrently. • A user’s program may carry out many operations on the data retrieved from the database, but the DBMS is only concerned about what data is read/written from/to the database. • A transaction is the DBMS’s abstract view of a user program: a sequence of reads and writes.
  • 3. Concurrency in a DBMS • Users submit transactions, and can think of each transaction as executing by itself. – Concurrency is achieved by the DBMS, which interleaves actions (reads/writes of DB objects) of various transactions. – Each transaction must leave the database in a consistent state if the DB is consistent when the transaction begins. • DBMS will enforce some ICs, depending on the ICs declared in CREATE TABLE statements. • Beyond this, the DBMS does not really understand the semantics of the data. (e.g., it does not understand how the interest on a bank account is computed). • Issues: Effect of interleaving transactions, and crashes.
  • 4. Atomicity of Transactions • A transaction might commit after completing all its actions, or it could abort (or be aborted by the DBMS) after executing some actions. • A very important property guaranteed by the DBMS for all transactions is that they are atomic. That is, a user can think of a Xact as always executing all its actions in one step, or not executing any actions at all. – DBMS logs all actions so that it can undo the actions of aborted transactions.
  • 5. Example • Consider two transactions (Xacts): T1: BEGIN A=A+100, B=B-100 END T2: BEGIN A=1.06*A, B=1.06*B END  Intuitively, the first transaction is transferring $100 from B’s account to A’s account. The second is crediting both accounts with a 6% interest payment.  There is no guarantee that T1 will execute before T2 or vice-versa, if both are submitted together. However, the net effect must be equivalent to these two transactions running serially in some order.
  • 6. Example (Contd.) • Consider a possible interleaving (schedule): T1: A=A+100, B=B-100 T2: A=1.06*A, B=1.06*B  This is OK. But what about: T1: A=A+100, B=B-100 T2: A=1.06*A, B=1.06*B  The DBMS’s view of the second schedule: T1: R(A), W(A), R(B), W(B) T2: R(A), W(A), R(B), W(B)
  • 7. Scheduling Transactions • Serial schedule: Schedule that does not interleave the actions of different transactions. • Equivalent schedules: For any database state, the effect (on the set of objects in the database) of executing the first schedule is identical to the effect of executing the second schedule. • Serializable schedule: A schedule that is equivalent to some serial execution of the transactions. (Note: If each transaction preserves consistency, every serializable schedule preserves consistency. )
  • 8. Anomalies with Interleaved Execution • Reading Uncommitted Data (WR Conflicts, “dirty reads”): T1: R(A), W(A), R(B), W(B), Abort T2: R(A), W(A), C • Unrepeatable Reads (RW Conflicts): T1: R(A), R(A), W(A), C T2: R(A), W(A), C
  • 9. Anomalies (Continued) • Overwriting Uncommitted Data (WW Conflicts): T1: W(A), W(B), C T2: W(A), W(B), C
  • 10. Lock-Based Concurrency Control • Strict Two-phase Locking (Strict 2PL) Protocol: – Each Xact must obtain a S (shared) lock on object before reading, and an X (exclusive) lock on object before writing. – All locks held by a transaction are released when the transaction completes • (Non-strict) 2PL Variant: Release locks anytime, but cannot acquire locks after releasing any lock. – If an Xact holds an X lock on an object, no other Xact can get a lock (S or X) on that object. • Strict 2PL allows only serializable schedules. – Additionally, it simplifies transaction aborts – (Non-strict) 2PL also allows only serializable schedules, but involves more complex abort processing
  • 11. Aborting a Transaction • If a transaction Ti is aborted, all its actions have to be undone. Not only that, if Tj reads an object last written by Ti, Tj must be aborted as well! • Most systems avoid such cascading aborts by releasing a transaction’s locks only at commit time. – If Ti writes an object, Tj can read this only after Ti commits. • In order to undo the actions of an aborted transaction, the DBMS maintains a log in which every write is recorded. This mechanism is also used to recover from system crashes: all active Xacts at the time of the crash are aborted when the system comes back up.
  • 12. The Log • The following actions are recorded in the log: – Ti writes an object: the old value and the new value. • Log record must go to disk before the changed page! – Ti commits/aborts: a log record indicating this action. • Log records are chained together by Xact id, so it’s easy to undo a specific Xact. • Log is often duplexed and archived on stable storage. • All log related activities (and in fact, all CC related activities such as lock/unlock, dealing with deadlocks etc.) are handled transparently by the DBMS.
  • 13. Recovering From a Crash • There are 3 phases in the Aries recovery algorithm: – Analysis: Scan the log forward (from the most recent checkpoint) to identify all Xacts that were active, and all dirty pages in the buffer pool at the time of the crash. – Redo: Redoes all updates to dirty pages in the buffer pool, as needed, to ensure that all logged updates are in fact carried out and written to disk. – Undo: The writes of all Xacts that were active at the crash are undone (by restoring the before value of the update, which is in the log record for the update), working backwards in the log. (Some care must be taken to handle the case of a crash occurring during the recovery process!)
  • 14. ACID Properties of Transaction • Atomicity: All or none, either every part of a transaction gets completed, or none of it does at all. If everything works correctly without any errors, everything gets committed to the database. If any one part of the transaction fails, the entire transaction gets rolled back. • Consistency: This property ensures that the state of the database is the same when it ends as it was when it began, and that no rules or constraints of the database are violated as a result of the transaction. Any violation of rules or constraints will cause the transaction to fail.
  • 15. ACID Properties of Transaction • Isolation: The operations that take place within a transaction are isolated from the operations of other transactions or other database operations, and that no other transaction or operation can have access in any way to the data that's being affected by a transaction in it's intermediate state (while the transaction is taking place). • Durability: The guarantee that once a transaction has completed, the results of it will persist and remain accurate and stable within the database.
  • 16. Summary • Concurrency control and recovery are among the most important functions provided by a DBMS. • Users need not worry about concurrency. – System automatically inserts lock/unlock requests and schedules actions of different Xacts in such a way as to ensure that the resulting execution is equivalent to executing the Xacts one after the other in some order. • Write-ahead logging (WAL) is used to undo the actions of aborted transactions and to restore the system to a consistent state after a crash. – Consistent state: Only the effects of commited Xacts seen.