SlideShare a Scribd company logo
Distributed Transactions and
Atomic commit protocols
Presented by -
Sachin Chauhan[0802IT141077]
What are we going to discuss?
 Introduction of Distributed Transaction
 Types of Distributed Transaction
• Flat
• Nested
 Atomic Commit Protocols
• One phase commit protocol
• Two phase commit protocol
Introduction
➔A Distributed Transaction is a logical unit of work on database that
accesses objects managed by multiple servers.
➔A Distributed Transaction is composed of several sub-transaction, each
running on different sites.Each Database Manager (DM )can decide to
abort.
➔When the Transaction is submitted the transaction manager at that site
breaks it up into 1or more sub-transaction at diff sites and coordinate their
activity.
Introduction
➔Atomic Commit Protocol(ACP) at DM’s has to ensure that all the sub-
transaction are consistently committed or abort.
➔Each server applies local concurrency control to its own object,Which
ensures that transaction are serialized locally as well as serialized globally.
➔When a distributed transaction comes to an end
◆ either all of the servers commit the transaction or all of them abort the transaction.
Introduction
➔One of the servers is coordinator, it must ensure the same outcome at all
of the servers.
➔The ‘two-phase commit protocol’ is the most commonly used protocol for
achieving Distributed Transaction.
➔Distributed Transaction are of two type –
➔A)Flat Transaction
➔B)Nested Transaction
Flat and Nested Transaction
completes each of its requests before going on to the
next one. Therefore, each
transaction accesses server’s
objects sequentially.
subtransactions at the same level can run
concurrently, so T1 and T2 are concurrent.
And as they
invoke objects
in different
servers, they
can run in
parallel
Nested banking transaction
A Client has to transfer $10 from account A to C
and then transfer $20 from B to D.A and B are
on separate servers X and Y and accounts C
and D are at same server Z. if this transaction is
structured as a set of four nested transactions,
the four requests (two deposit and two
withdraw) can run in parallel and overall effect
can be achieved with better performance than a
simple transaction in which the four operations
are invoked sequentially.
Requests can
be run in parallel
with several servers
So,nested transaction
is more efficient.
openTransactionT =
openSubTransaction
a.withdraw(10);
openSubtransaction
b.Withdraw(20);
...c.dep(10);....d.dep(20);
closeTransaction
The coordinator of a flat distributed transaction
➔Servers execute requests in a distributed transaction
◆ When it commits they must communicate with one another to coordinate their actions
◆ A client starts a transaction by sending an openTransaction request to a coordinator in
any server (next slide)
● It returns a TID unique in the distributed system(e.g. server ID + local transaction
number)
● At the end, it will be responsible for committing or aborting it
The coordinator of a flat distributed transaction
◆ Each server managing an object accessed by the transaction is a participant - it joins the
transaction (next slide)
● A participant keeps track of objects involved in the transaction
● At the end it cooperates with the coordinator in carrying out the commit protocol
◆ Note that a participant can call abortTransaction in coordinator
A flat distributed banking transaction
Each server is shown with a participant, which joins the
transaction by invoking the join method in the
coordinator
The coordinator is in one
of the server Eg. BranchX
openTransaction goes to the coordinator
➔The interface for Coordinator has
◆ it has openTransaction, closeTransaction and abortTransaction
◆ openTransaction returns a TID which is passed with each operation so that servers know
which transaction is accessing its objects
➔ The Coordinator interface provides an additional method, join, which is
used whenever a new participant joins the transaction
◆ join(Trans, reference to participant)
◆ informs a coordinator that a new participant has joined the transaction Trans.
◆ the coordinator records the new participant in its participant list.
The join operation
Flat and Nested Transaction
Limitations of(Flat):-
•All-or-nothing is not
appropriate.
•It is beneficial to
commit partial
results(violate
atomiocity)
•Trip planning:commit
part of transactipon
•Bulk update:can be
expensive to undo all
updates
Advantages of (Nested ):-
•Subtransaction at one level may run concurrently with
Other subtransaction at the same level
•Subtransaction can commit or abort independently.
Rules for Nested trx:-
•A Transaction may commit or abort only after its child
transaction have completed.
•When a parent aborts,all of its Subtransaction are
aborted
•When a subtransaction abort,the parent can decide
whether to abort or not.
Atomic commit
protocols
Transaction atomicity requires
that at the end.
I.e. either all of its operations are
carried out or none of them.
In a distributed transaction, the
client has requested the
operations at more than one
server
One-phase atomic commit protocol
The coordinator tells the participants whether to commit
or abort. The Problem with it that
This does not allow one of the servers to decide to abort
– it may have discovered a deadlock or it may have
crashed and been restarted
Two-phase atomic commit protocol
Is designed to allow any participant to choose to abort a
transaction
phase 1 - each participant votes. If it votes to commit, it
is prepared. It cannot change its mind. In case it
crashes, it must save updates in permanent store
phase 2 - the participants carry out the joint decision
Decision must be commit /abort - participants record it
in permanent store
Failure model for the commit protocols
➔Commit protocols are designed to work in
◆ asynchronous system (e.g. messages may take a very long time)
◆ servers may crash
◆ messages may be lost.
◆ assume corrupt and duplicated messages are removed.
◆ no byzantine faults – servers either crash or they obey their requests
Failure model for the commit protocols
➔2PC is an example of a protocol for reaching a consensus.
◆ consensus cannot be reached in an asynchronous system if processes sometimes fail.
◆ however, 2PC does reach consensus under those conditions.
◆ because crash failures of processes are masked by replacing a crashed process with a
new process whose state is set from information saved in permanent storage and
information held by other processes.
The two-phase commit protocol
➔During the progress of a transaction, the only communication between
coordinator and participant is the join request
◆ The client request to commit or abort goes to the coordinator
● if client or participant request abort, the coordinator informs the participants
immediately
● if the client asks to commit, the 2PC comes into use
➔2PC
◆ voting phase: coordinator asks all participants if they can commit
Operations for two-phase commit protocol
canCommit?(trans)-> Yes / No
Call from coordinator to participant to ask whether it can commit a transaction. Participant replies with its vote.
doCommit(trans)
Call from coordinator to participant to tell participant to commit its part of a transaction.
doAbort(trans)
Call from coordinator to participant to tell participant to abort its part of a transaction.
haveCommitted(trans, participant)
Call from participant to coordinator to confirm that it has committed the transaction.
Operations for two-phase commit protocol
Phase 1 (voting phase):
The coordinator sends a canCommit? request to each of the participants in the transaction.
When a participant receives a canCommit? request it replies with its vote (Yes or No) to the coordinator. Before
voting Yes, it prepares to commit by saving objects in permanent storage. If the vote is No the participant aborts
immediately.
Phase 2 (completion according to outcome of vote):
The coordinator collects the votes (including its own).
If there are no failures and all the votes are Yes the coordinator decides to commit the transaction and sends
a doCommit request to each of the participants.
Otherwise the coordinator decides to abort the transaction and sends doAbort requests to all participants that
voted Yes.
Communication in two-phase commit protocol
Two-phase commit protocol for nested transactions
top-level transaction T and subtransactions T1, T2, T11, T12, T21, T22
A subtransaction starts after its parent and finishes before it
When a subtransaction completes, it makes an independent decision either
to commit provisionally or to abort.
A provisional commit is not the same as being prepared: it is a local decision and is not
backed up on permanent storage.
If the server crashes subsequently, its replacement will not be able to carry out a provisional
commit.
A two-phase commit protocol is needed for nested transactions
Operations in coordinator for nested transactions
openSubTransaction(trans) -> subTrans
Opens a new subtransaction whose parent is trans and returns a unique
subtransaction identifier.
getStatus(trans)-> committed, aborted, provisional
Asks the coordinator to report on the status of the transaction trans.
Returns values representing one of the following: committed, aborted,
provisional.
Transaction T decides whether to commit
1
2
T11
T12
T22
T21
abort (at M)
provisional commit (at
N)
provisional commit (at X)
aborted (at
Y)
provisional commit (at
N)
provisional commit (at P)
T
T
T
Information held by coordinators of nested transactions
When a top-level transaction commits it carries out a 2PC
Each coordinator has a list of its subtransactions
At provisional commit, a subtransaction reports its status and the status of
its descendents to its parent
If a subtransaction aborts, it tells its parent
Information held by coordinators of nested transactions
Summary
● a distributed transaction involves several different
servers.
○ A nested transaction structure allows
■ additional concurrency
■ independent committing by the servers in a distributed
transaction.
● atomicity requires that the servers participating in a
distributed transaction either all commit it or all abort
it.
● atomic commit protocols are designed to achieve this
effect, even if servers crash during their execution.
● the 2PC protocol allows a server to abort unilaterally.
○ it includes timeout actions to deal with delays due to servers
crashing.
○ 2PC protocol can take an unbounded amount of time to
complete but is guaranteed to complete eventually.
Thank you!

More Related Content

PPTX
Distributed Mutual Exclusion and Distributed Deadlock Detection
PDF
management of distributed transactions
PPTX
Concurrency Control in Distributed Database.
PPTX
Distributed system lamport's and vector algorithm
PDF
Agreement Protocols, distributed File Systems, Distributed Shared Memory
PPTX
Optimistic concurrency control in Distributed Systems
PPTX
Synchronization in distributed computing
PDF
Resource management
Distributed Mutual Exclusion and Distributed Deadlock Detection
management of distributed transactions
Concurrency Control in Distributed Database.
Distributed system lamport's and vector algorithm
Agreement Protocols, distributed File Systems, Distributed Shared Memory
Optimistic concurrency control in Distributed Systems
Synchronization in distributed computing
Resource management

What's hot (20)

PDF
Deadlock Avoidance - OS
PPT
Distributed Deadlock Detection.ppt
PDF
Methods for handling deadlocks
PPTX
Physical and Logical Clocks
PPT
Two phase commit protocol in dbms
PPT
Chapter 12 transactions and concurrency control
PPTX
Security in distributed systems
PPTX
Inter Process Communication
PPTX
Remote Procedure Call in Distributed System
PDF
8. mutual exclusion in Distributed Operating Systems
PPT
Group Communication (Distributed computing)
PPTX
Stream oriented communication
DOC
Distributed Mutual exclusion algorithms
PPTX
Parallel Programing Model
PPTX
object oriented methodologies
PPT
Aggrement protocols
PPT
Chapter 14 replication
PDF
Deadlock in distribute system by saeed siddik
PPT
Chapter 13
PDF
CS9222 ADVANCED OPERATING SYSTEMS
Deadlock Avoidance - OS
Distributed Deadlock Detection.ppt
Methods for handling deadlocks
Physical and Logical Clocks
Two phase commit protocol in dbms
Chapter 12 transactions and concurrency control
Security in distributed systems
Inter Process Communication
Remote Procedure Call in Distributed System
8. mutual exclusion in Distributed Operating Systems
Group Communication (Distributed computing)
Stream oriented communication
Distributed Mutual exclusion algorithms
Parallel Programing Model
object oriented methodologies
Aggrement protocols
Chapter 14 replication
Deadlock in distribute system by saeed siddik
Chapter 13
CS9222 ADVANCED OPERATING SYSTEMS
Ad

Similar to Distributed Transactions(flat and nested) and Atomic Commit Protocols (20)

PDF
Management of Distributed Transactions
PDF
Bab8 transaction
PDF
Lec13s transaction
PDF
module-4.1-Class notes_R and DD_basket-IV -.pdf
PPTX
UNIT IV DIS.pptx
PPTX
Transaction management transparencies
PPTX
Distributed datababase Transaction and concurrency control
PPT
Transactions (Distributed computing)
PPTX
enc=encoded=TlJst0_SHq0cPRhLS74QDXTP4FpU303sSqpyVVkfhckA93UCiZrRF0QVNAFGmuGu9...
PPT
3 distributed transactions-cocurrency-query
PPT
4. concurrency control
PPTX
Dos.pptx
PPTX
Transactions and Concurrency Control
PPT
Distributed Transaction
PPT
19. Distributed Databases in DBMS
PPT
2 PHASE COMMIT PROTOCOL
PPTX
Unit iv -Transactions
PDF
Distributed Transactions on databases. Silberschatz
PPTX
ch23.pptx distrubuted database management
Management of Distributed Transactions
Bab8 transaction
Lec13s transaction
module-4.1-Class notes_R and DD_basket-IV -.pdf
UNIT IV DIS.pptx
Transaction management transparencies
Distributed datababase Transaction and concurrency control
Transactions (Distributed computing)
enc=encoded=TlJst0_SHq0cPRhLS74QDXTP4FpU303sSqpyVVkfhckA93UCiZrRF0QVNAFGmuGu9...
3 distributed transactions-cocurrency-query
4. concurrency control
Dos.pptx
Transactions and Concurrency Control
Distributed Transaction
19. Distributed Databases in DBMS
2 PHASE COMMIT PROTOCOL
Unit iv -Transactions
Distributed Transactions on databases. Silberschatz
ch23.pptx distrubuted database management
Ad

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
KodekX | Application Modernization Development
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
cuic standard and advanced reporting.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
Building Integrated photovoltaic BIPV_UPV.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
KodekX | Application Modernization Development
Understanding_Digital_Forensics_Presentation.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Spectral efficient network and resource selection model in 5G networks
NewMind AI Weekly Chronicles - August'25 Week I
cuic standard and advanced reporting.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Diabetes mellitus diagnosis method based random forest with bat algorithm

Distributed Transactions(flat and nested) and Atomic Commit Protocols

  • 1. Distributed Transactions and Atomic commit protocols Presented by - Sachin Chauhan[0802IT141077]
  • 2. What are we going to discuss?  Introduction of Distributed Transaction  Types of Distributed Transaction • Flat • Nested  Atomic Commit Protocols • One phase commit protocol • Two phase commit protocol
  • 3. Introduction ➔A Distributed Transaction is a logical unit of work on database that accesses objects managed by multiple servers. ➔A Distributed Transaction is composed of several sub-transaction, each running on different sites.Each Database Manager (DM )can decide to abort. ➔When the Transaction is submitted the transaction manager at that site breaks it up into 1or more sub-transaction at diff sites and coordinate their activity.
  • 4. Introduction ➔Atomic Commit Protocol(ACP) at DM’s has to ensure that all the sub- transaction are consistently committed or abort. ➔Each server applies local concurrency control to its own object,Which ensures that transaction are serialized locally as well as serialized globally. ➔When a distributed transaction comes to an end ◆ either all of the servers commit the transaction or all of them abort the transaction.
  • 5. Introduction ➔One of the servers is coordinator, it must ensure the same outcome at all of the servers. ➔The ‘two-phase commit protocol’ is the most commonly used protocol for achieving Distributed Transaction. ➔Distributed Transaction are of two type – ➔A)Flat Transaction ➔B)Nested Transaction
  • 6. Flat and Nested Transaction completes each of its requests before going on to the next one. Therefore, each transaction accesses server’s objects sequentially. subtransactions at the same level can run concurrently, so T1 and T2 are concurrent. And as they invoke objects in different servers, they can run in parallel
  • 7. Nested banking transaction A Client has to transfer $10 from account A to C and then transfer $20 from B to D.A and B are on separate servers X and Y and accounts C and D are at same server Z. if this transaction is structured as a set of four nested transactions, the four requests (two deposit and two withdraw) can run in parallel and overall effect can be achieved with better performance than a simple transaction in which the four operations are invoked sequentially. Requests can be run in parallel with several servers So,nested transaction is more efficient. openTransactionT = openSubTransaction a.withdraw(10); openSubtransaction b.Withdraw(20); ...c.dep(10);....d.dep(20); closeTransaction
  • 8. The coordinator of a flat distributed transaction ➔Servers execute requests in a distributed transaction ◆ When it commits they must communicate with one another to coordinate their actions ◆ A client starts a transaction by sending an openTransaction request to a coordinator in any server (next slide) ● It returns a TID unique in the distributed system(e.g. server ID + local transaction number) ● At the end, it will be responsible for committing or aborting it
  • 9. The coordinator of a flat distributed transaction ◆ Each server managing an object accessed by the transaction is a participant - it joins the transaction (next slide) ● A participant keeps track of objects involved in the transaction ● At the end it cooperates with the coordinator in carrying out the commit protocol ◆ Note that a participant can call abortTransaction in coordinator
  • 10. A flat distributed banking transaction Each server is shown with a participant, which joins the transaction by invoking the join method in the coordinator The coordinator is in one of the server Eg. BranchX openTransaction goes to the coordinator
  • 11. ➔The interface for Coordinator has ◆ it has openTransaction, closeTransaction and abortTransaction ◆ openTransaction returns a TID which is passed with each operation so that servers know which transaction is accessing its objects ➔ The Coordinator interface provides an additional method, join, which is used whenever a new participant joins the transaction ◆ join(Trans, reference to participant) ◆ informs a coordinator that a new participant has joined the transaction Trans. ◆ the coordinator records the new participant in its participant list. The join operation
  • 12. Flat and Nested Transaction Limitations of(Flat):- •All-or-nothing is not appropriate. •It is beneficial to commit partial results(violate atomiocity) •Trip planning:commit part of transactipon •Bulk update:can be expensive to undo all updates Advantages of (Nested ):- •Subtransaction at one level may run concurrently with Other subtransaction at the same level •Subtransaction can commit or abort independently. Rules for Nested trx:- •A Transaction may commit or abort only after its child transaction have completed. •When a parent aborts,all of its Subtransaction are aborted •When a subtransaction abort,the parent can decide whether to abort or not.
  • 13. Atomic commit protocols Transaction atomicity requires that at the end. I.e. either all of its operations are carried out or none of them. In a distributed transaction, the client has requested the operations at more than one server One-phase atomic commit protocol The coordinator tells the participants whether to commit or abort. The Problem with it that This does not allow one of the servers to decide to abort – it may have discovered a deadlock or it may have crashed and been restarted Two-phase atomic commit protocol Is designed to allow any participant to choose to abort a transaction phase 1 - each participant votes. If it votes to commit, it is prepared. It cannot change its mind. In case it crashes, it must save updates in permanent store phase 2 - the participants carry out the joint decision Decision must be commit /abort - participants record it in permanent store
  • 14. Failure model for the commit protocols ➔Commit protocols are designed to work in ◆ asynchronous system (e.g. messages may take a very long time) ◆ servers may crash ◆ messages may be lost. ◆ assume corrupt and duplicated messages are removed. ◆ no byzantine faults – servers either crash or they obey their requests
  • 15. Failure model for the commit protocols ➔2PC is an example of a protocol for reaching a consensus. ◆ consensus cannot be reached in an asynchronous system if processes sometimes fail. ◆ however, 2PC does reach consensus under those conditions. ◆ because crash failures of processes are masked by replacing a crashed process with a new process whose state is set from information saved in permanent storage and information held by other processes.
  • 16. The two-phase commit protocol ➔During the progress of a transaction, the only communication between coordinator and participant is the join request ◆ The client request to commit or abort goes to the coordinator ● if client or participant request abort, the coordinator informs the participants immediately ● if the client asks to commit, the 2PC comes into use ➔2PC ◆ voting phase: coordinator asks all participants if they can commit
  • 17. Operations for two-phase commit protocol canCommit?(trans)-> Yes / No Call from coordinator to participant to ask whether it can commit a transaction. Participant replies with its vote. doCommit(trans) Call from coordinator to participant to tell participant to commit its part of a transaction. doAbort(trans) Call from coordinator to participant to tell participant to abort its part of a transaction. haveCommitted(trans, participant) Call from participant to coordinator to confirm that it has committed the transaction.
  • 18. Operations for two-phase commit protocol Phase 1 (voting phase): The coordinator sends a canCommit? request to each of the participants in the transaction. When a participant receives a canCommit? request it replies with its vote (Yes or No) to the coordinator. Before voting Yes, it prepares to commit by saving objects in permanent storage. If the vote is No the participant aborts immediately. Phase 2 (completion according to outcome of vote): The coordinator collects the votes (including its own). If there are no failures and all the votes are Yes the coordinator decides to commit the transaction and sends a doCommit request to each of the participants. Otherwise the coordinator decides to abort the transaction and sends doAbort requests to all participants that voted Yes.
  • 19. Communication in two-phase commit protocol
  • 20. Two-phase commit protocol for nested transactions top-level transaction T and subtransactions T1, T2, T11, T12, T21, T22 A subtransaction starts after its parent and finishes before it When a subtransaction completes, it makes an independent decision either to commit provisionally or to abort. A provisional commit is not the same as being prepared: it is a local decision and is not backed up on permanent storage. If the server crashes subsequently, its replacement will not be able to carry out a provisional commit. A two-phase commit protocol is needed for nested transactions
  • 21. Operations in coordinator for nested transactions openSubTransaction(trans) -> subTrans Opens a new subtransaction whose parent is trans and returns a unique subtransaction identifier. getStatus(trans)-> committed, aborted, provisional Asks the coordinator to report on the status of the transaction trans. Returns values representing one of the following: committed, aborted, provisional.
  • 22. Transaction T decides whether to commit 1 2 T11 T12 T22 T21 abort (at M) provisional commit (at N) provisional commit (at X) aborted (at Y) provisional commit (at N) provisional commit (at P) T T T
  • 23. Information held by coordinators of nested transactions When a top-level transaction commits it carries out a 2PC Each coordinator has a list of its subtransactions At provisional commit, a subtransaction reports its status and the status of its descendents to its parent If a subtransaction aborts, it tells its parent
  • 24. Information held by coordinators of nested transactions
  • 25. Summary ● a distributed transaction involves several different servers. ○ A nested transaction structure allows ■ additional concurrency ■ independent committing by the servers in a distributed transaction. ● atomicity requires that the servers participating in a distributed transaction either all commit it or all abort it. ● atomic commit protocols are designed to achieve this effect, even if servers crash during their execution. ● the 2PC protocol allows a server to abort unilaterally. ○ it includes timeout actions to deal with delays due to servers crashing. ○ 2PC protocol can take an unbounded amount of time to complete but is guaranteed to complete eventually.