0% found this document useful (0 votes)
33 views10 pages

3C03 Concurrency: Distributed Transactions

Centralised DBMS controls transaction execution DBMS implements concurrency control transaction processing transparent to application developers. Distributed objects do not use a database.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views10 pages

3C03 Concurrency: Distributed Transactions

Centralised DBMS controls transaction execution DBMS implements concurrency control transaction processing transparent to application developers. Distributed objects do not use a database.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

3C03 Concurrency: Distributed Transactions

Anthony Steed
Reading: Connolly & Begg, Database Systems (3rd edition), Sections 23.1, 23.2.1, 23.2.3, 23.4.123.4.3
Wolfgang Emmerich, Anthony Steed, 1998-2003

Outline
Distributed Transaction Processing Centralised & Distributed 2PL Two Phase Commit Protocol (2PC)

Wolfgang Emmerich, Anthony Steed, 1998-2003

Central vs. Distributed Transactions


Transactions in a Database
Centralized DBMS controls transaction execution DBMS implements concurrency control Transaction processing transparent to application developers

Problem occurs if:


Data kept in different databases or Distributed objects do not use a database Transaction processing not transparent to application developers
Wolfgang Emmerich, Anthony Steed, 1998-2003

Components of a DDBMS
Data Comms Data Comms Coordinator Coordinator Transaction Transaction Manager Manager Transaction Transaction Server Server Data Comms Data Comms Coordinator Coordinator Transaction Transaction Manager Manager Transaction Transaction Client Client Data Comms Data Comms Coordinator Coordinator Transaction Transaction Manager Manager Transaction Transaction Server Server

Wolfgang Emmerich, Anthony Steed, 1998-2003

Roles of Components
Distributed system components involved in transactions can take the following roles:
Transaction Client Transaction Server Transaction Manager Coordinator

Wolfgang Emmerich, Anthony Steed, 1998-2003

Transaction Manager
Manages transaction on behalf of local clients Understands the begin, commit and abort commands

Wolfgang Emmerich, Anthony Steed, 1998-2003

Transaction Coordinator
Coordinator plays key role in managing transaction. Manages both locally and remotely initiated transactions. Coordinator allocates system-wide unique transaction identifier. Different transactions may have different coordinators.
Wolfgang Emmerich, Anthony Steed, 1998-2003

Transactional Server
Every component with a resource accessed or modified under transaction control. Transactional server has to know coordinator for each transaction. Transactional server registers its participation in a transaction with the coordinator. Transactional server has to implement a transaction protocol (e.g. two-phase commit or centralised 2PL).
Wolfgang Emmerich, Anthony Steed, 1998-2003

Transactional Client
Only sees transactions through the transaction manager. Invokes services from the manager to begin, commit and abort transactions. Implementation of transactions are transparent for the client.

Wolfgang Emmerich, Anthony Steed, 1998-2003

Centralised & Distributed 2PL


Even with distributed DBMS, can centralise lock distribution.
One coordinator manages all lock request This coordinator becomes bottleneck and point of failure

OR distribute lock management


Coordinator manages lock for data on its local server Much higher overhead and more complicated to manage
Wolfgang Emmerich, Anthony Steed, 1998-2003

10

Complexity
Assuming N participating servers Centralised 2PL:
1 lock request 1 lock grant n update messages n acknowledgements 1 unlock

Distributed 2PL:
n lock request n lock grant n update messages n acknowledgements n unlock

Wolfgang Emmerich, Anthony Steed, 1998-2003

11

Two-Phase Commit
Multiple autonomous distributed servers:
For a commit, all transactional servers have to be able to commit. If a single transactional server cannot commit its changes every server has to abort.

Single phase protocol is insufficient. Two phases are needed:


Phase one: Voting Phase two: Completion.
Wolfgang Emmerich, Anthony Steed, 1998-2003

12

Phase One
Called the voting phase. Coordinator asks all servers if they are able (and willing) to commit. Servers reply:
Ready: it will commit if asked, but does not yet know if it is actually going to commit. Abort: immediately aborts its operations. A server might not reply (maybe it died)

Hence, servers can unilaterally abort but not unilaterally commit a transaction.
Wolfgang Emmerich, Anthony Steed, 1998-2003

13

Phase Two
Called the completion phase. Co-ordinator collates all votes, including its own, and decides to
commit if everyone voted Ready. abort if anyone voted Abort or doesnt vote within a short period.

All voters that voted Ready are sent


Global_Commit if transaction is to be committed. Otherwise Abort'.

Servers acknowledge once they have committed.


Wolfgang Emmerich, Anthony Steed, 1998-2003

14

Server Uncertainty
Period when a server must be able to commit, but does not yet know if has to. This period is known as server uncertainty. Usually short (time needed for coordinator to receive and process votes). However, failures can lengthen this process, which may cause problems.
Wolfgang Emmerich, Anthony Steed, 1998-2003

15

Complexity
Assuming N participating servers and in addition to updates on actual databases:
(N-1) Voting requests from coordinator to servers. (N-1) Completion requests from coordinator to servers.

Hence, complexity of requests is linear in the number of participating servers.


Wolfgang Emmerich, Anthony Steed, 1998-2003

16

State Diagrams for 2PC


Initial Initial
Prepare Sent

Initial Initial
Prepare Received Abort Sent

Waiting Waiting
All Received or timeout

Prepared Prepared
Abort Sent

Commit sent

Decided Decided Completed Completed

Acknowledgement

Aborted Aborted

Committed Committed

Wolfgang Emmerich, Anthony Steed, 1998-2003

17

Committing Nested Transactions


Cannot use same mechanism to commit nested transactions as:
subtransactions can abort independently of parent. subtransactions must have made decision to commit or abort before parent transaction.

Top level transaction needs to be able to communicate its decision down to all subtransactions so they may react accordingly.
Wolfgang Emmerich, Anthony Steed, 1998-2003

18

Example: Funds Transfer


TM begin debit credit commit prepare prepare ready ready commit commit
19

Coordinator

Bank1

Bank2

Wolfgang Emmerich, Anthony Steed, 1998-2003

Summary
Centralised and Distributed Two Phase Locking
Trade-off between reliability and performance

Two Phase Commit Protocol (2PC)


Voting procedures and failure

Wolfgang Emmerich, Anthony Steed, 1998-2003

20

You might also like