TPM – Transaction Processing Monitor

indigoo.com

TPM

TRANSACTION
PROCESSING MONITOR
OVERVIEW OF TPM FOR
DISTRIBUTED TRANSACTION PROCESSING

© Peter R. Egli 2015

Peter R. Egli
INDIGOO.COM
1/9
Rev. 1.10

TPM – Transaction Processing Monitor

indigoo.com

Contents
1.
2.
3.
4.
5.

What are Transaction Processing Monitors?
Properties of DB transactions
Two-Phase Commit architecture
Two-Phase Commit sequence
TPM structure

© Peter R. Egli 2015

2/9
Rev. 1.10

TPM – Transaction Processing Monitor

indigoo.com

1. What are Transaction Processing Monitors (TPM)?
Typical problem of distributed applications:
Operations involving multiple databases (DB) require transactional access.
The operation is either successful or fails, but always has to leave all involved databases in a
consistent state.
Debit account
Server
DB
1
Client

Transfer

Credit account

Server
2

DB

TPM:
TPMs are an early solution for distributed transactions (booking systems, bank account
transfers etc.).
TPMs support distributed database transactions by coordinating multiple DB accesses.

Client

© Peter R. Egli 2015

Server
1

DB

Server
2

DB

TPM

3/9
Rev. 1.10

TPM – Transaction Processing Monitor

indigoo.com

2. Properties of DB transactions (1/2)
Relational databases support ACID properties:
1. Atomicity
2. Consistency
3. Isolation
4. Durability
Atomicity: Consistent state before & after transaction.

Account 1

Transfer
1000 CHF

Account 2

Consistency: No integrity constraint violations

Case 1:
Successful Account 1
transaction
-1'000 CHF
or
Case 2:
Account 1
Failed
transaction
-0 CHF

Key

Name

balance_key

Key

balance

1

Egli

3

1

2.95 CHF

2

Müller

1

2

56'342'786'129.98 CHF

3

Meier

5

3

88.70 CHF

4

Huber

7

4

23.67 CHF

5

Gates

2

5

14'78 CHF

Account 2
+1'000 CHF
Account 2
+0 CHF

Integrity violation (missing entry with key=7)
© Peter R. Egli 2015

4/9
Rev. 1.10

TPM – Transaction Processing Monitor

indigoo.com

2. Properties of DB transactions (2/2)
Isolation: DB accesses are isolated from each other so they do not impact each other.
Typically this is done with some sort of locking of resources (tables in DB) and serialization of
the requests.
Request 2
Request 2
Request 1

Execution

Execution

Execution

Time
Durability: Transaction is persistent, even in case of errors (crash of DB, error etc.)

Write to DB

Successful
transaction

Write data
to disk buffer

Crash of
DB

© Peter R. Egli 2015

Commit data
to disk

Failed
transaction
Commit data to
disk after restart
5/9
Rev. 1.10

TPM – Transaction Processing Monitor

indigoo.com

3. Two-Phase Commit architecture
TPMs employ a mechanism called Two-Phase Commit to support distributed DB transactions.
Transaction manager (Coordinator):
The coordinator serves as coordination point in the distributed transaction.

Resource manager:
The resource managers (aka "Cohort") perform the individual transactional DB accesses and
are able to either commit or rollback an individual DB access.
Undo / redo logs:
Undo / redo logs are used by the
transaction managers for transactional
access to their respective DB.
Client interface
for distributed
transactions

Undo/Redo
logs

Resource
manager
(cohort)

Transaction
Manager
(Coordinator)

Undo/Redo
logs

Resource
manager
(cohort)

© Peter R. Egli 2015

DB

DB
6/9
Rev. 1.10

TPM – Transaction Processing Monitor

indigoo.com

4. Two-Phase Commit sequence (1/2)
A. Successful transaction:
When all transaction managers agree with the commit (vote "yes"), the transaction can be
successfully committed.
Resource
manager

Transaction
Manager

Client
1

Resource
manager

Request
2

2

4

Query to commit

Query to commit

Ack (agreement)

3

* Prepare for commit
* Write undo / redo logs
4

© Peter R. Egli 2015

Commit

Ack

* Commit
* Release all locks
7

8

* Prepare for commit
* Write undo / redo logs

Commit phase
(=completion phase)

Commit
6

7

3

Ack (agreement)
5

5

Commit request
phase
(=voting phase)

6

* Commit
* Release all locks

Ack

Ack

7/9
Rev. 1.10

TPM – Transaction Processing Monitor

indigoo.com

4. Two-Phase Commit sequence (2/2)
A. Failed transaction:
When either of the transaction manager does not positively acknowledge the transaction,
the coordinator sends a rollback command to all transaction managers.
Resource
manager

Transaction
Manager

Client
1

Resource
manager

Request
2

2

4

Query to commit

Query to commit

Ack (agreement)

3

* Prepare for commit
* Write undo / redo logs
4

© Peter R. Egli 2015

Rollback

Ack

* Undo transaction
* Release all locks
7

8

* Prepare for commit
* Write undo / redo logs

Commit phase
(=completion phase)

Rollback
6

7

3

Not Ack (or timeout)
5

5

Commit request
phase
(=voting phase)

6

* Undo transaction
* Release all locks

Ack

Negative Ack

8/9
Rev. 1.10

TPM – Transaction Processing Monitor

indigoo.com

5. TPM structure
TPMs represent complete systems akin to operating systems capable of running entire
applications. Resource managers may be internal or external to the TPM.
Request
Queue

Authentication

Client

E.g. transactional
RPC XA interface=2PC
(X/Open)

TPM

Presentation

Service (application)
Response
Queue

Transaction
Manager

Log manager
(undo/redo)

Resource
manager

DB

Recovery
manager

Binding
Scheduling
Load Balancing
Appl. Lifecycle

© Peter R. Egli 2015

9/9
Rev. 1.10

Sign up to vote on this title
UsefulNot useful