SlideShare a Scribd company logo
1 of 27
Module IV – Concurrency Control & Recovery Management
DBMS (CSEN 3101) – BTech/CSE(AIML) – 3rd yr (5th Sem)
Prepared by Dr. Nilina Bera, CSE, HITK
A transaction is an atomic unit of execution, i.e., it is a sequence of
operations which either are performed in entirety or are not performed
at all.
Properties:
1. A Ti preserves the consistency of a database.
2. A Ti terminates in finite time.
What is termination? 🡪 Commit operation.
1. Ensures integrity, recovery & concurrency control.
2. Isolation
3. Serializability
A transaction Ti that does not modify any data object but just
performs read-operation is referred to as read-only transaction or
query. A Ti that modifies at least one ds is known as an update
transaction or an update or write-operation.
Transactions
A transaction Ti can be viewed as a partially ordered set (Si , <i )
where Si is the set of read and write actions of the transaction and
<i dictates the order in which these actions must be executed.
Ex:- For the purpose of concurrency control & serializability, a
transaction Ti can be considered as a sequence, {a1(d1), a2(d2),
a3(d3),…,an(dn)} of n steps, where, ai= action at step i, action like
read and write
di=data object acted upon at step i.
Summary of Transaction:
1) Group of actions (read and/or write) performed by an user
with a DBMS is referred to as a transaction (Ti).
2) Ti is an atomic unit of execution.
3) Begin Transaction to Commit transaction
4) Begin Transaction to Abort transaction
5) Begin Transaction can be X (System forces abort)
Transactions
Transactions
Transactions
Conflicts during transactions handling
Conflict occurs if two transactions T1 and T2 access the same shared
data object(s), ds at a particular time instant, Ti, and AT LEAST
ONE OF THEM IS A WRITE ACTION. There can be conflict if T1
wants to read ds and T2 wants to write (update/insert/delete) the same
ds at the same time instant.
RS (Read-set); WS (Write-set);
Transaction Conflict type
T1, T2 r-w, w-r, w-w
Action 🡪 RS(T1) ∩ WS(T2) ≠ ø (null)
WS (T1) ∩ RS(T2) ≠ ø (null)
WS (T1) ∩ WS (T2) ≠ ø (null)
Three transactions with their read-sets and write-sets :-
T1: RS(T1) = {d1, d3, d5}; WS(T1) = {d3, d6};
T2: RS(T2) = {d2, d4, d5}; WS(T2) = {d2, d4, d6};
T3: RS(T3) = {d1, d2, d4}; WS(T3) = {d2, d4};
T1 has w-w conflict with T2, WS(T1) ∩ WS(T2) = d6.
T2 has r-w, w-r and w-w conflicts with T3,
RS(T2) ∩ WS(T3) = {d2, d4}
WS(T2) ∩ RS(T3) = {d2, d4}
WS(T2) ∩ WS(T3) = {d2, d4}
T3 has no conflict with T1.
Conflicts during transactions handling
Serializability in a centralized database
A schedule (or a history or log) is a sequence of operations
performed by transactions (T1, T2,….,Tn). Let, S be a schedule;
comm. 🡪 commit Ti ; data-items🡪 {x, y, z}; r(x)🡪 read x; w(y)🡪
write y; .
T1 T2 T3
r(x), w(x), comm.
r(y), w(y), comm.
r(z), w(z), comm.
S =
Ex-1: S1=r(x)w(x)comm.r(y)w(y)comm.r(z)w(z)comm.
i.e., S1=r(x)w(x)r(y)w(y)r(z)w(z) ---------------------------(1)
Ex-2: S2=ri(x)rj(x)wi(y)rk(y)wj(x); T={Ti, Tj, Tk};
Data-items = {x, y} --------------------------------- (2)
Serializability of a set of transactions
■ Two transactions, Ti and Tj execute serially in a schedule S1
(equation-1), if the last operation of Ti precedes the first operation of
Tj in S1; otherwise, they execute concurrently.
S2 (equation-2) is NOT serial.
❑ A serial schedule, S2 = ri(x) wi(x) ri(y) rj(x) wj(y) rk(y) wk(x);
Serial(S2) = Ti.Tj.Tk 🡪Ti < Tj < Tk
S2 =
Ti Tj Tk
r(x)
w(x)
r(y)
r(x)
w(y)
r(y)
w(x)
Oi
Oj
Ok
Oi < Oj < Ok , i.e.,
operation Oi precedes
Oj and Oj precedes Ok.
Read and write
operations on data
objects x and y.
■ As serial execution of transactions are time-
consuming, inefficient and not cost-effective,
transactions should execute as concurrently as
possible with correct execution, i.e., we define
the concept of serializability as “a schedule is
correct if it is serializable, i.e., it is
computationally equivalent to a serial
schedule.”
Serializability of a set of transactions
Definition of correctness for a non-serial schedule
Given three transactions, T1, T2 and T3 as follows:
T1 = r1(x).r1(z).w1(x)
T2 = r2(y).r2(z).w2(y)
T3 = w3(x).r3(y).w3(z)
The above set of transactions are associated with the schedules as follows:
S1 = w3(x).r1(x).r3(y).r2(y).w3(z).r2(z).r1(z).w2(y).w1(x);
Or
S1′ = w3(x).r1(x).w1(x).r3(y).r2(y).w2(y).w3(z).r2(z).r1(z);
T3 T2
T1
S1′ and S2′
both are
conflict
serializable.
S2 = w3(x).r3(y).w3(z).r2(y).r2(z).w2(y).r1(x).r1(z).w1(x);
Or
S2′ = w3(x).r1(x).w1(x).r3(y).r2(y).w2(y).w3(z).r2(z).r1(z);
Equivalence of two schedules:
Condition 1: Each read operation reads data values
which are produced by the same write operations in
both schedules.
Condition 2: The final write operation on each data
item is the same in both schedules.
In order to apply these two conditions in the analysis of
concurrency control mechanisms, the conflict between operations
is defined as:
1. Two operations are in conflict if they operate on the same
data item.
2. One of them is a write operation.
3. The operations/actions are issued by different transactions.
Serializability of schedules
❑ When several transactions are executing concurrently then the
order of execution of various instructions is known as a
schedule.
❑ The concept of serializability of schedules is used to identify
which schedules are correct when transaction executions have
interleaving of their operations in the schedules.
Types of schedules
❑Serial schedules
❑Non-serial schedules
❑Conflicting schedules
❑View Schedules
Serial Schedules
Serial Schedule A Serial Schedule B
T1:
Read-item(X)
X:=X-N
Write-item(X)
Read-item(Y)
Y:=Y+N
Write-item(Y)
T2:
Read-item(X)
X:X+M
Write-item(X)
T2:
Read-item(X)
X:=X+M
Write-item(X)
T1:
Read-item(X)
X:X+N
Write-item(X)
Read-item(Y)
Y:=Y-N
Write-item(Y)
■ Two schedules A and B are called serial
schedule if the operations of each
transaction are executed consecutively,
without any interleaved operations from the
other transaction. T1 is performed first,
then T2 follows T1 (T1<T2) or T2 is
performed, then T1 follows T2 (T2<T1).
Serial Schedules
Serial & Non-Serial Schedules
Serial vs Non-Serial Schedules
Serial Schedule Non-Serial Schedule
A serial schedule is a sequence of
operation by a set of concurrent
transaction that preserves the
order of operations in each of the
individual transactions.
A non-serial schedule is a
schedule where the operations of
a group of concurrent
transactions are interleaved.
Transactions are performed
in serial order.
Transactions are performed
in non-serial order, but
result should be same as
serial.
EXAMPLE:
If some transaction T is long, the
other transaction must wait for T to
complete all its operations.
EXAMPLE:
In this schedule the execution of
other transaction goes on without
waiting the completion of T
Conflict Serializability examples:
Consider two transactions T1 and T2 and four schedules S1, S2, S3,
S4 of T1 and T2 as given below:
T1: r1[x] w1[x] w1[y]
T2: r2[x] r2[y] w2[y]
S1: r1[x] r2[x] r2[y] w1[x] w1[y] w2[y]
S2: r1[x] r2[x] r2[y] w1[x] w2[y] w1[y]
S3: r1[x] w1[x] r2[x] w1[y] r2[y] w2[y]
S4: r2[x] r2[y] r1[x] w1[x] w1[y] w2[y]
Which of the above schedules are conflict serializable?
a) S1 and S2 b) S2 and S3 c) S3 only d) S4 only
Conflict Serializability examples (continued):
S1: Check out conflicting actions:
1. r1(x) : Read action on data item x is the starting point (from
transaction T1), but no conflicting actions between T1 and T2 on
data-item x, {r1(x), r2(x), w1(x)}.
2. {r2(x), w1(x)} 🡪 Conflict T2 and 1 on data-item=x, T2 < T1
or T2 🡪 T1, i.e, T2 precedes T1.
3. Data-item y: {r2(y), w1(y), w2(y)}
Conflicts 🡪 {r2(y), w1(y)} 🡪 T2 < T1 🡪 T2 🡪 T1
Conflicts 🡪 {w1(y), w2(y)} 🡪 T1 < T2 🡪 T1 🡪 T2
The above analysis denotes that S1 is NOT conflict serializable,
because serialization graph is Cyclic.
T
1
T
2
y
y
Conflict Serializability examples (continued):
S2: Grouping of events: {r1(x), r2(x), w1(x)} and {r2(y), w2(y), w1(y)}
Conflicting operations involving T1 and T2 with data-item x 🡪 {r2(x),
w1(x)} 🡪 T2 🡪 T1 (T2 < T1).
In the same transaction, read – write operations on the same data-item is
OK, i.e., {r2(y), w2(y)} is without conflict.
Conflicting operations involving T1 and T2 with data-item y 🡪 {r2(y),
w1(y)} and {w2(y), w1(y)}🡪 (T2 🡪 T1) 🡪 (T2 < T1).
Thus, S2 is conflict serializable.
T2 T1
Serialization
Graph
Conflict Serializability examples (continued):
S3: Grouping of events: {r1(x), w1(x), r2(x)} and {w1(y), r2(y), w2(y)}
Conflicting operations involving T1 and T2 with data-item x 🡪 {w1(x),
r2(x)} 🡪 T1 🡪 T2 (T1 < T2).
Conflicting operations involving T1 and T2 with data-item y 🡪 {w1(y),
r2(y)} and {w1(y), w2(y)}🡪 (T1 🡪 T2) 🡪 (T1 < T2).
Thus, S3 is conflict serializable.
T1 T2
Serialization
Graph
Conflict Serializability examples (continued):
S4: Grouping of events: {r2(x), r1(x), w1(x)} and {r2(y), w1(y), w2(y)}
Conflicting operations involving T1 and T2 with data-item x 🡪 {r2(x),
w1(x)} 🡪 T2 🡪 T1 (T2 < T1).
Conflicting operations involving T1 and T2 with data-item y 🡪 {r2(y),
w1(y)} and {w1(y), w2(y)}🡪 Edges created for the serialization graph
(SG) (T1 🡪 T2) and (T2 🡪 T1).
Thus, S4 is NOT conflict serializable because SG is cyclic.
T1 T2
Serialization
Graph
Ans: (b) S2 and S3; (c.) S3
Conflict Serializability examples (continued):
Consider the following schedules, S1 and S2
involving two transactions, T1 and T2.
S1: r1(x), r1(y), r2(x), r2(y), w2(y), w1(x)
S2: r1(x), r2(x), r2(y), w2(y), r1(y), w1(x)
Select the correct option:
(a) S1 is not conflict serializable and S2 is conflict
serializable.
(b) Both S1 and S2 are conflict serializable.
(c) S1 is conflict serializable and S2 is not conflict
serializable.
(d) Both S1 and S2 are not conflict serializable.
Conflict Serializability examples (continued):
S1: Grouping actions involving T1 and T2 on data-item
x 🡪 {r1(x), r2(x), w1(x)}; {r1(y), r2(y), w2(y)};
Conflicts: {r2(x), w1(x)}; {r1(y), w2(y)}
Edges: T2 🡪 T1; T1 🡪 T2
Serialization Graph: Cyclic T
1
T
2
S2: Grouping actions involving T1 and T2 on data-item
x 🡪 {r1(x), r2(x), w1(x)}; {r2(y), w2(y), r1(y)};
Conflicts: {r2(x), w1(x)}; {w2(y), r1(y)}
Edges: T2 🡪 T1; T2 🡪 T1
Serialization Graph: Not Cyclic.
T
1
T
2
Ans: (a)
Conflict Serializability examples (continued):
“In a concurrent schedule, set of transactions may conflict” -- Justify
Conflicting operations in concurrent schedule (type consistent), T1
initiating W(B) [write on data-item B], without commit, if T2
initiates read operation on the same data-item B [R(B)]. Similarly,
in “inconsistent”-concurrent schedule, T1🡪W(A) and T2🡪R(A)
[without commit]; T2🡪R(B) and T1🡪W(B) are conflicting
operations.
• When are two schedules conflict equivalent?
• What is a conflict serializable schedule?
• What is a strict schedule?
What is a precedence graph or serializability
graph? How is it related to conflict serializability?
How is it related to two-phase locking?

More Related Content

Similar to 7. CSEN3101-MIV-TransactionProcessing-SolvedProblems-06.11.2023.pptx

3 concurrencycontrolone
3 concurrencycontrolone3 concurrencycontrolone
3 concurrencycontroloneKamal Shrish
 
UNIT-IV: Transaction Processing Concepts
UNIT-IV: Transaction Processing ConceptsUNIT-IV: Transaction Processing Concepts
UNIT-IV: Transaction Processing ConceptsRaj vardhan
 
Transaction management
Transaction managementTransaction management
Transaction managementrenuka_a
 
Concurrency control iN Advanced Database
Concurrency control iN Advanced DatabaseConcurrency control iN Advanced Database
Concurrency control iN Advanced DatabaseDaniel181688
 
Databases: Concurrency Control
Databases: Concurrency ControlDatabases: Concurrency Control
Databases: Concurrency ControlDamian T. Gordon
 
recoverability and serializability dbms
recoverability and serializability  dbmsrecoverability and serializability  dbms
recoverability and serializability dbmsKumari Naveen
 
time_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdftime_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdfSrinivasaReddyPolamR
 
Concurrency control and Serializability
Concurrency control and SerializabilityConcurrency control and Serializability
Concurrency control and Serializabilitysuraj1536
 
db unit 4 dbms protocols in transaction
db unit 4 dbms  protocols in transactiondb unit 4 dbms  protocols in transaction
db unit 4 dbms protocols in transactionKumari Naveen
 
Unit 5 - PPT.pdf DBMS SRM university chennai
Unit 5 - PPT.pdf DBMS SRM university chennaiUnit 5 - PPT.pdf DBMS SRM university chennai
Unit 5 - PPT.pdf DBMS SRM university chennaiPriyanshuJha69
 
Transaction and serializability
Transaction and serializabilityTransaction and serializability
Transaction and serializabilityYogita Jain
 
UNIT 2- TRANSACTION CONCEPTS AND CONCURRENCY CONCEPTS (1).pdf
UNIT 2- TRANSACTION CONCEPTS AND CONCURRENCY CONCEPTS (1).pdfUNIT 2- TRANSACTION CONCEPTS AND CONCURRENCY CONCEPTS (1).pdf
UNIT 2- TRANSACTION CONCEPTS AND CONCURRENCY CONCEPTS (1).pdfKavitaShinde26
 
Transactions in dbms
Transactions in dbmsTransactions in dbms
Transactions in dbmsNancy Gulati
 
Transaction Timestamping in Temporal Databases
Transaction Timestamping in Temporal DatabasesTransaction Timestamping in Temporal Databases
Transaction Timestamping in Temporal DatabasesGera Shegalov
 

Similar to 7. CSEN3101-MIV-TransactionProcessing-SolvedProblems-06.11.2023.pptx (20)

3 concurrencycontrolone
3 concurrencycontrolone3 concurrencycontrolone
3 concurrencycontrolone
 
UNIT-IV: Transaction Processing Concepts
UNIT-IV: Transaction Processing ConceptsUNIT-IV: Transaction Processing Concepts
UNIT-IV: Transaction Processing Concepts
 
Transaction management
Transaction managementTransaction management
Transaction management
 
Question answer
Question answerQuestion answer
Question answer
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Concurrency control iN Advanced Database
Concurrency control iN Advanced DatabaseConcurrency control iN Advanced Database
Concurrency control iN Advanced Database
 
Databases: Concurrency Control
Databases: Concurrency ControlDatabases: Concurrency Control
Databases: Concurrency Control
 
recoverability and serializability dbms
recoverability and serializability  dbmsrecoverability and serializability  dbms
recoverability and serializability dbms
 
time_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdftime_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdf
 
Concurrency control and Serializability
Concurrency control and SerializabilityConcurrency control and Serializability
Concurrency control and Serializability
 
db unit 4 dbms protocols in transaction
db unit 4 dbms  protocols in transactiondb unit 4 dbms  protocols in transaction
db unit 4 dbms protocols in transaction
 
Unit 5 - PPT.pdf DBMS SRM university chennai
Unit 5 - PPT.pdf DBMS SRM university chennaiUnit 5 - PPT.pdf DBMS SRM university chennai
Unit 5 - PPT.pdf DBMS SRM university chennai
 
Transaction and serializability
Transaction and serializabilityTransaction and serializability
Transaction and serializability
 
dbms sanat ppt.pdf
dbms sanat ppt.pdfdbms sanat ppt.pdf
dbms sanat ppt.pdf
 
Unit-IV_transaction.pptx
Unit-IV_transaction.pptxUnit-IV_transaction.pptx
Unit-IV_transaction.pptx
 
Serializability
SerializabilitySerializability
Serializability
 
UNIT 2- TRANSACTION CONCEPTS AND CONCURRENCY CONCEPTS (1).pdf
UNIT 2- TRANSACTION CONCEPTS AND CONCURRENCY CONCEPTS (1).pdfUNIT 2- TRANSACTION CONCEPTS AND CONCURRENCY CONCEPTS (1).pdf
UNIT 2- TRANSACTION CONCEPTS AND CONCURRENCY CONCEPTS (1).pdf
 
Transactions in dbms
Transactions in dbmsTransactions in dbms
Transactions in dbms
 
Transaction Timestamping in Temporal Databases
Transaction Timestamping in Temporal DatabasesTransaction Timestamping in Temporal Databases
Transaction Timestamping in Temporal Databases
 
unit06-dbms-new.ppt
unit06-dbms-new.pptunit06-dbms-new.ppt
unit06-dbms-new.ppt
 

Recently uploaded

Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuidePixlogix Infotech
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfAnubhavMangla3
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftshyamraj55
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandIES VE
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewDianaGray10
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxFIDO Alliance
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxjbellis
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxMasterG
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Hiroshi SHIBATA
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...marcuskenyatta275
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 

Recently uploaded (20)

Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 

7. CSEN3101-MIV-TransactionProcessing-SolvedProblems-06.11.2023.pptx

  • 1. Module IV – Concurrency Control & Recovery Management DBMS (CSEN 3101) – BTech/CSE(AIML) – 3rd yr (5th Sem) Prepared by Dr. Nilina Bera, CSE, HITK
  • 2. A transaction is an atomic unit of execution, i.e., it is a sequence of operations which either are performed in entirety or are not performed at all. Properties: 1. A Ti preserves the consistency of a database. 2. A Ti terminates in finite time. What is termination? 🡪 Commit operation. 1. Ensures integrity, recovery & concurrency control. 2. Isolation 3. Serializability A transaction Ti that does not modify any data object but just performs read-operation is referred to as read-only transaction or query. A Ti that modifies at least one ds is known as an update transaction or an update or write-operation. Transactions
  • 3. A transaction Ti can be viewed as a partially ordered set (Si , <i ) where Si is the set of read and write actions of the transaction and <i dictates the order in which these actions must be executed. Ex:- For the purpose of concurrency control & serializability, a transaction Ti can be considered as a sequence, {a1(d1), a2(d2), a3(d3),…,an(dn)} of n steps, where, ai= action at step i, action like read and write di=data object acted upon at step i. Summary of Transaction: 1) Group of actions (read and/or write) performed by an user with a DBMS is referred to as a transaction (Ti). 2) Ti is an atomic unit of execution. 3) Begin Transaction to Commit transaction 4) Begin Transaction to Abort transaction 5) Begin Transaction can be X (System forces abort) Transactions
  • 5.
  • 7. Conflicts during transactions handling Conflict occurs if two transactions T1 and T2 access the same shared data object(s), ds at a particular time instant, Ti, and AT LEAST ONE OF THEM IS A WRITE ACTION. There can be conflict if T1 wants to read ds and T2 wants to write (update/insert/delete) the same ds at the same time instant. RS (Read-set); WS (Write-set); Transaction Conflict type T1, T2 r-w, w-r, w-w Action 🡪 RS(T1) ∩ WS(T2) ≠ ø (null) WS (T1) ∩ RS(T2) ≠ ø (null) WS (T1) ∩ WS (T2) ≠ ø (null)
  • 8. Three transactions with their read-sets and write-sets :- T1: RS(T1) = {d1, d3, d5}; WS(T1) = {d3, d6}; T2: RS(T2) = {d2, d4, d5}; WS(T2) = {d2, d4, d6}; T3: RS(T3) = {d1, d2, d4}; WS(T3) = {d2, d4}; T1 has w-w conflict with T2, WS(T1) ∩ WS(T2) = d6. T2 has r-w, w-r and w-w conflicts with T3, RS(T2) ∩ WS(T3) = {d2, d4} WS(T2) ∩ RS(T3) = {d2, d4} WS(T2) ∩ WS(T3) = {d2, d4} T3 has no conflict with T1. Conflicts during transactions handling
  • 9. Serializability in a centralized database A schedule (or a history or log) is a sequence of operations performed by transactions (T1, T2,….,Tn). Let, S be a schedule; comm. 🡪 commit Ti ; data-items🡪 {x, y, z}; r(x)🡪 read x; w(y)🡪 write y; . T1 T2 T3 r(x), w(x), comm. r(y), w(y), comm. r(z), w(z), comm. S = Ex-1: S1=r(x)w(x)comm.r(y)w(y)comm.r(z)w(z)comm. i.e., S1=r(x)w(x)r(y)w(y)r(z)w(z) ---------------------------(1) Ex-2: S2=ri(x)rj(x)wi(y)rk(y)wj(x); T={Ti, Tj, Tk}; Data-items = {x, y} --------------------------------- (2)
  • 10. Serializability of a set of transactions ■ Two transactions, Ti and Tj execute serially in a schedule S1 (equation-1), if the last operation of Ti precedes the first operation of Tj in S1; otherwise, they execute concurrently. S2 (equation-2) is NOT serial. ❑ A serial schedule, S2 = ri(x) wi(x) ri(y) rj(x) wj(y) rk(y) wk(x); Serial(S2) = Ti.Tj.Tk 🡪Ti < Tj < Tk S2 = Ti Tj Tk r(x) w(x) r(y) r(x) w(y) r(y) w(x) Oi Oj Ok Oi < Oj < Ok , i.e., operation Oi precedes Oj and Oj precedes Ok. Read and write operations on data objects x and y.
  • 11. ■ As serial execution of transactions are time- consuming, inefficient and not cost-effective, transactions should execute as concurrently as possible with correct execution, i.e., we define the concept of serializability as “a schedule is correct if it is serializable, i.e., it is computationally equivalent to a serial schedule.” Serializability of a set of transactions
  • 12. Definition of correctness for a non-serial schedule Given three transactions, T1, T2 and T3 as follows: T1 = r1(x).r1(z).w1(x) T2 = r2(y).r2(z).w2(y) T3 = w3(x).r3(y).w3(z) The above set of transactions are associated with the schedules as follows: S1 = w3(x).r1(x).r3(y).r2(y).w3(z).r2(z).r1(z).w2(y).w1(x); Or S1′ = w3(x).r1(x).w1(x).r3(y).r2(y).w2(y).w3(z).r2(z).r1(z); T3 T2 T1 S1′ and S2′ both are conflict serializable. S2 = w3(x).r3(y).w3(z).r2(y).r2(z).w2(y).r1(x).r1(z).w1(x); Or S2′ = w3(x).r1(x).w1(x).r3(y).r2(y).w2(y).w3(z).r2(z).r1(z);
  • 13. Equivalence of two schedules: Condition 1: Each read operation reads data values which are produced by the same write operations in both schedules. Condition 2: The final write operation on each data item is the same in both schedules. In order to apply these two conditions in the analysis of concurrency control mechanisms, the conflict between operations is defined as: 1. Two operations are in conflict if they operate on the same data item. 2. One of them is a write operation. 3. The operations/actions are issued by different transactions.
  • 14. Serializability of schedules ❑ When several transactions are executing concurrently then the order of execution of various instructions is known as a schedule. ❑ The concept of serializability of schedules is used to identify which schedules are correct when transaction executions have interleaving of their operations in the schedules. Types of schedules ❑Serial schedules ❑Non-serial schedules ❑Conflicting schedules ❑View Schedules
  • 15. Serial Schedules Serial Schedule A Serial Schedule B T1: Read-item(X) X:=X-N Write-item(X) Read-item(Y) Y:=Y+N Write-item(Y) T2: Read-item(X) X:X+M Write-item(X) T2: Read-item(X) X:=X+M Write-item(X) T1: Read-item(X) X:X+N Write-item(X) Read-item(Y) Y:=Y-N Write-item(Y)
  • 16. ■ Two schedules A and B are called serial schedule if the operations of each transaction are executed consecutively, without any interleaved operations from the other transaction. T1 is performed first, then T2 follows T1 (T1<T2) or T2 is performed, then T1 follows T2 (T2<T1). Serial Schedules
  • 17. Serial & Non-Serial Schedules
  • 18. Serial vs Non-Serial Schedules Serial Schedule Non-Serial Schedule A serial schedule is a sequence of operation by a set of concurrent transaction that preserves the order of operations in each of the individual transactions. A non-serial schedule is a schedule where the operations of a group of concurrent transactions are interleaved. Transactions are performed in serial order. Transactions are performed in non-serial order, but result should be same as serial. EXAMPLE: If some transaction T is long, the other transaction must wait for T to complete all its operations. EXAMPLE: In this schedule the execution of other transaction goes on without waiting the completion of T
  • 19. Conflict Serializability examples: Consider two transactions T1 and T2 and four schedules S1, S2, S3, S4 of T1 and T2 as given below: T1: r1[x] w1[x] w1[y] T2: r2[x] r2[y] w2[y] S1: r1[x] r2[x] r2[y] w1[x] w1[y] w2[y] S2: r1[x] r2[x] r2[y] w1[x] w2[y] w1[y] S3: r1[x] w1[x] r2[x] w1[y] r2[y] w2[y] S4: r2[x] r2[y] r1[x] w1[x] w1[y] w2[y] Which of the above schedules are conflict serializable? a) S1 and S2 b) S2 and S3 c) S3 only d) S4 only
  • 20. Conflict Serializability examples (continued): S1: Check out conflicting actions: 1. r1(x) : Read action on data item x is the starting point (from transaction T1), but no conflicting actions between T1 and T2 on data-item x, {r1(x), r2(x), w1(x)}. 2. {r2(x), w1(x)} 🡪 Conflict T2 and 1 on data-item=x, T2 < T1 or T2 🡪 T1, i.e, T2 precedes T1. 3. Data-item y: {r2(y), w1(y), w2(y)} Conflicts 🡪 {r2(y), w1(y)} 🡪 T2 < T1 🡪 T2 🡪 T1 Conflicts 🡪 {w1(y), w2(y)} 🡪 T1 < T2 🡪 T1 🡪 T2 The above analysis denotes that S1 is NOT conflict serializable, because serialization graph is Cyclic. T 1 T 2 y y
  • 21. Conflict Serializability examples (continued): S2: Grouping of events: {r1(x), r2(x), w1(x)} and {r2(y), w2(y), w1(y)} Conflicting operations involving T1 and T2 with data-item x 🡪 {r2(x), w1(x)} 🡪 T2 🡪 T1 (T2 < T1). In the same transaction, read – write operations on the same data-item is OK, i.e., {r2(y), w2(y)} is without conflict. Conflicting operations involving T1 and T2 with data-item y 🡪 {r2(y), w1(y)} and {w2(y), w1(y)}🡪 (T2 🡪 T1) 🡪 (T2 < T1). Thus, S2 is conflict serializable. T2 T1 Serialization Graph
  • 22. Conflict Serializability examples (continued): S3: Grouping of events: {r1(x), w1(x), r2(x)} and {w1(y), r2(y), w2(y)} Conflicting operations involving T1 and T2 with data-item x 🡪 {w1(x), r2(x)} 🡪 T1 🡪 T2 (T1 < T2). Conflicting operations involving T1 and T2 with data-item y 🡪 {w1(y), r2(y)} and {w1(y), w2(y)}🡪 (T1 🡪 T2) 🡪 (T1 < T2). Thus, S3 is conflict serializable. T1 T2 Serialization Graph
  • 23. Conflict Serializability examples (continued): S4: Grouping of events: {r2(x), r1(x), w1(x)} and {r2(y), w1(y), w2(y)} Conflicting operations involving T1 and T2 with data-item x 🡪 {r2(x), w1(x)} 🡪 T2 🡪 T1 (T2 < T1). Conflicting operations involving T1 and T2 with data-item y 🡪 {r2(y), w1(y)} and {w1(y), w2(y)}🡪 Edges created for the serialization graph (SG) (T1 🡪 T2) and (T2 🡪 T1). Thus, S4 is NOT conflict serializable because SG is cyclic. T1 T2 Serialization Graph Ans: (b) S2 and S3; (c.) S3
  • 24. Conflict Serializability examples (continued): Consider the following schedules, S1 and S2 involving two transactions, T1 and T2. S1: r1(x), r1(y), r2(x), r2(y), w2(y), w1(x) S2: r1(x), r2(x), r2(y), w2(y), r1(y), w1(x) Select the correct option: (a) S1 is not conflict serializable and S2 is conflict serializable. (b) Both S1 and S2 are conflict serializable. (c) S1 is conflict serializable and S2 is not conflict serializable. (d) Both S1 and S2 are not conflict serializable.
  • 25. Conflict Serializability examples (continued): S1: Grouping actions involving T1 and T2 on data-item x 🡪 {r1(x), r2(x), w1(x)}; {r1(y), r2(y), w2(y)}; Conflicts: {r2(x), w1(x)}; {r1(y), w2(y)} Edges: T2 🡪 T1; T1 🡪 T2 Serialization Graph: Cyclic T 1 T 2 S2: Grouping actions involving T1 and T2 on data-item x 🡪 {r1(x), r2(x), w1(x)}; {r2(y), w2(y), r1(y)}; Conflicts: {r2(x), w1(x)}; {w2(y), r1(y)} Edges: T2 🡪 T1; T2 🡪 T1 Serialization Graph: Not Cyclic. T 1 T 2 Ans: (a)
  • 26. Conflict Serializability examples (continued): “In a concurrent schedule, set of transactions may conflict” -- Justify Conflicting operations in concurrent schedule (type consistent), T1 initiating W(B) [write on data-item B], without commit, if T2 initiates read operation on the same data-item B [R(B)]. Similarly, in “inconsistent”-concurrent schedule, T1🡪W(A) and T2🡪R(A) [without commit]; T2🡪R(B) and T1🡪W(B) are conflicting operations.
  • 27. • When are two schedules conflict equivalent? • What is a conflict serializable schedule? • What is a strict schedule? What is a precedence graph or serializability graph? How is it related to conflict serializability? How is it related to two-phase locking?