1. introduction csep 545 transaction processing philip a

55
1. Introduction 3/24/07 1 CSEP 545 Transaction Processing Philip A. Bernstein Copyright '2007 Philip A. Bernstein

Upload: others

Post on 18-Dec-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

1. In

trodu

ctio

n

3/24

/07

1

CSE

P 54

5 Tr

ansa

ctio

n Pr

oces

sing

Phili

p A

. Ber

nste

in

Cop

yrig

ht ©

2007

Phi

lip A

. Ber

nste

in

Out

line

1. T

he B

asic

s2.

AC

ID P

rope

rties

3A

tom

icity

and

Two-

Phas

eC

omm

it

3/24

/07

2

3. A

tom

icity

and

Tw

o-Ph

ase

Com

mit

4. P

erfo

rman

ce5.

Sty

les o

f Sys

tem

1.1

The

Bas

ics -

Wha

t�s a

Tra

nsac

tion?

�Th

e ex

ecut

ion

of a

pro

gram

that

per

form

s an

adm

inis

trativ

e fu

nctio

n by

acc

essi

ng a

shar

ed

data

base

, usu

ally

on

beha

lf of

an

on-li

neus

er.

Exam

ples

3/24

/07

3

p�

Res

erve

an

airli

ne se

at. B

uy a

n ai

rline

tick

et�

With

draw

mon

ey fr

om a

n A

TM.

�V

erify

a c

redi

t car

d sa

le.

�O

rder

an

item

from

an

Inte

rnet

reta

iler

�Pl

ace

a bi

d at

an

on-li

ne a

uctio

n�

Subm

it a

corp

orat

e pu

rcha

se o

rder

The

�itie

s� a

re W

hat M

akes

Tr

ansa

ctio

n Pr

oces

sing

(TP)

Har

d�

Rel

iabi

lity

-sys

tem

shou

ld ra

rely

fail

�A

vaila

bilit

y -s

yste

m m

ust b

e up

all

the

time

�R

espo

nse

time

-with

in 1

-2 se

cond

s�

Thro

ughp

ut -

thou

sand

s of t

rans

actio

ns/s

econ

d

3/24

/07

4

gp

�Sc

alab

ility

-st

art s

mal

l, ra

mp

up to

Inte

rnet

-sca

le�

Secu

rity

�fo

r con

fiden

tialit

y an

d hi

gh fi

nanc

e�

Con

figur

abili

ty -

for a

bove

requ

irem

ents

+ lo

w c

ost

�A

tom

icity

-no

par

tial r

esul

ts�

Dur

abili

ty -

a tra

nsac

tion

is a

lega

l con

tract

�D

istri

butio

n -o

f use

rs a

nd d

ata

Wha

t Mak

es T

P Im

porta

nt?

�It�

s at t

he c

ore

of e

lect

roni

c co

mm

erce

�M

ost m

ediu

m-to

-larg

e bu

sine

sses

use

TP

for

thei

r pro

duct

ion

syst

ems.

The

busi

ness

can

�t op

erat

ew

ithou

tit

3/24

/07

5

oper

ate

with

out i

t.

�It�

s a h

uge

slic

e of

the

com

pute

r sys

tem

m

arke

t. O

ne o

f the

larg

est a

pplic

atio

ns o

f co

mpu

ters

.

TP S

yste

m In

fras

truct

ure

�U

ser�

s vie

wpo

int

�En

ter a

requ

est f

rom

a b

row

ser o

r oth

er d

ispl

ay d

evic

e�

The

syst

em p

erfo

rms s

ome

appl

icat

ion-

spec

ific

wor

k,

whi

ch in

clud

es d

atab

ase

acce

sses

�R

ecei

ve a

repl

y (u

sual

ly, b

ut n

ot a

lway

s)Th

TPt

tht

ht

ti

3/24

/07

6

�Th

e TP

syst

em e

nsur

es th

at e

ach

trans

actio

n�

is a

n in

depe

nden

t uni

t of w

ork

�ex

ecut

es e

xact

ly o

nce,

and

prod

uces

per

man

ent r

esul

ts.

�TP

syst

em m

akes

it e

asy

to p

rogr

am tr

ansa

ctio

ns�

TP sy

stem

has

tool

s to

mak

e it

easy

to m

anag

e

TP S

yste

m In

fras

truct

ure

Def

ines

Sys

tem

and

App

licat

ion

Stru

ctur

e

Fron

tEnd

Prog

ram

Cli

t

End

-Use

r

3/24

/07

7

Fron

t End

Pro

gram

Req

uest

Con

trolle

r(r

oute

s re

ques

ts a

ndsu

perv

ises

thei

r exe

cutio

n)

Dat

abas

e S

yste

m

Clie

nt

Bac

k-E

nd(S

erve

r)Tr

ansa

ctio

n S

erve

r

requ

ests

Syst

em C

hara

cter

istic

s�

Typi

cally

< 1

00 tr

ansa

ctio

n ty

pes p

er a

pplic

atio

n�

Tran

sact

ion

size

has

hig

h va

rianc

e. T

ypic

ally

,�

0-30

dis

k ac

cess

es�

10K

-1M

inst

ruct

ions

exe

cute

d

3/24

/07

8

�2-

20 m

essa

ges

�A

larg

e-sc

ale

exam

ple:

airl

ine

rese

rvat

ions

�hu

ndre

ds o

f tho

usan

ds o

f act

ive

disp

lay

devi

ces

�pl

us in

dire

ct a

cces

s via

Inte

rnet

�te

ns o

f tho

usan

ds o

f tra

nsac

tions

per

seco

nd, p

eak

Ava

ilabi

lity

�Fr

actio

n of

tim

e sy

stem

is a

ble

to d

o us

eful

wor

k�

Som

e sy

stem

s are

ver

yse

nsiti

ve to

dow

ntim

e�

airli

ne re

serv

atio

n, st

ock

exch

ange

, tel

epho

ne sw

itchi

ng�

dow

ntim

e is

fron

t pag

e ne

ws

Dow

ntim

eAv

aila

bilit

y1

hour

/day

95.8

%

3/24

/07

9

�C

ontri

butin

g fa

ctor

s�

failu

res d

ue to

env

ironm

ent,

syst

em m

gmt,

h/w,

s/w

�re

cove

ry ti

me

y1

hour

/wee

k99

.41%

1 ho

ur/m

onth

99.8

6%1

hour

/yea

r99

.988

6%1

hour

/20y

ears

99.9

9942

%

App

licat

ion

Serv

ers

�A

softw

are

prod

uct t

o cr

eate

, exe

cute

and

man

age

TP

appl

icat

ions

�Fo

rmer

ly c

alle

d TP

mon

itors

.Som

e pe

ople

say

App

Ser

ver =

TP

mon

itor +

web

func

tiona

lity.

�Pr

ogra

mm

er w

rites

an

app

to p

roce

ss a

sing

le re

ques

t.

3/24

/07

10

App

Ser

ver s

cale

s it u

p to

a la

rge,

dis

tribu

ted

syst

em�

E.g.

app

licat

ion

deve

lope

r writ

es p

rogr

ams t

o de

bit a

che

ckin

g ac

coun

t and

ver

ify a

cre

dit c

ard

purc

hase

. �

App

Ser

ver h

elps

syst

em e

ngin

eer d

eplo

y it

to 1

0s/1

00s o

f se

rver

s and

10K

s of d

ispl

ays

�A

pp S

erve

r hel

ps sy

stem

eng

inee

r dep

loy

it on

the

Inte

rnet

, ac

cess

ible

from

web

bro

wse

rs

App

licat

ion

Serv

ers (

cont

�d)

�C

ompo

nent

s inc

lude

an a

pplic

atio

n pr

ogra

mm

ing

inte

rfac

e (A

PI)

(e.g

., En

terp

rise

Java

Bea

ns)

3/24

/07

11

�to

ols f

or p

rogr

am d

evel

opm

ent

�to

ols f

or sy

stem

man

agem

ent (

app

depl

oym

ent,

faul

t & p

erfo

rman

ce m

onito

ring,

use

r mgm

t, et

c.)

�En

terp

rise

Java

Bea

ns, I

BM

Web

sphe

re,

Mic

roso

ft .N

ET (C

OM

+), B

EA W

eblo

gic,

O

racl

e A

pplic

atio

n Se

rver

Fron

t End

Pro

gram

Message

Inputs

App

Ser

ver A

rchi

tect

ure,

pre

-Web

�B

oxes

bel

ow a

re d

istri

bute

d on

an

intra

net

3/24

/07

12

Req

uest

Con

trolle

r

Tran

sact

ion

Ser

ver

Tran

sact

ion

Ser

ver

Network

Que

ues

Aut

omat

ed T

elle

r Mac

hine

(A

TM) A

pplic

atio

n Ex

ampl

e

ATM

ATM

ATM

ATM

ATM

ATM

ATM

ATM

Ban

k B

ranc

h 1

Ban

k B

ranc

h 2

Ban

k B

ranc

h 50

0

3/24

/07

13

Req

uest

C

ontro

ller

CIR

RU

SA

ccou

nts

Cre

dit C

ard

Acc

ount

sLo

anA

ccou

nts

Req

uest

C

ontro

ller

Che

ckin

gA

ccou

nts

Web

Ser

ver

Message

Inputs

App

licat

ion

Serv

er A

rchi

tect

ure

3/24

/07

14

Req

uest

Con

trolle

r

Tran

sact

ion

Ser

ver

Tran

sact

ion

Ser

ver

intranet

Que

ues

othe

r TP

syst

ems

Inte

rnet

Ret

aile

r

The

Inte

rnet

Toys

…�

3/24

/07

15

Req

uest

C

ontro

ller

Mus

icC

ompu

ters

Web

S

erve

r

Ele

ctro

nics

Serv

ice

Orie

nted

Arc

hite

ctur

e (S

OA

)

The

Inte

rnet

Toys

…�

eb Service

�W

eb se

rvic

es -

inte

rfac

e an

d pr

otoc

ol st

anda

rds

to d

o ap

p se

rver

func

tions

ove

r the

inte

rnet

.

3/24

/07

16

Req

uest

C

ontro

ller

Mus

icC

ompu

ters

Web

S

erve

r

Ele

ctro

nics

Web

Ser

vice

We

Ente

rpris

e A

pplic

atio

n In

tegr

atio

n (E

AI)

�A

softw

are

prod

uct t

o ro

ute

requ

ests

bet

wee

n in

depe

nden

t app

licat

ion

syst

ems.

Ofte

n in

clud

e�

A q

ueui

ng sy

stem

Ai

t

3/24

/07

17

�A

mes

sage

map

ping

syst

em�

App

licat

ion

adap

tors

(SA

P, P

eopl

eSof

t, et

c.)

�EA

I and

App

licat

ion

Serv

ers a

ddre

ss a

sim

ilar

prob

lem

, with

diff

eren

t em

phas

is�

IBM

Web

sphe

re M

Q, T

IBC

O, V

itria

, See

Bey

ond

ATM

Exa

mpl

ew

ith a

n EA

I Sys

tem

ATM

ATM

ATM

ATM

ATM

ATM

ATM

ATM

Ban

k B

ranc

h 1

Ban

k B

ranc

h 2

Ban

k B

ranc

h 50

0

3/24

/07

18

CIR

RU

SA

ccou

nts

Cre

dit C

ard

Acc

ount

sLo

anA

ccou

nts

EA

I Rou

ting

Che

ckin

gA

ccou

nts

EA

I Rou

ting

Que

ues

Que

ues

Wor

kflo

w, o

r Bus

ines

s Pro

cess

Mgm

t�

A so

ftwar

e pr

oduc

t tha

t exe

cute

s mul

ti-tra

nsac

tion

long

-run

ning

scrip

ts (e

.g. p

roce

ss a

n or

der)

�Pr

oduc

t com

pone

nts

�A

wor

kflo

w sc

ript l

angu

age

�W

orkf

low

scrip

t int

erpr

eter

and

sche

dule

rW

orkf

low

track

ing

3/24

/07

19

�W

orkf

low

trac

king

�M

essa

ge tr

ansl

atio

n�

App

licat

ion

and

queu

e sy

stem

ada

ptor

s�

Tran

sact

ion-

cent

ric v

s. do

cum

ent-c

entri

c�

Stru

ctur

ed p

roce

sses

vs.

case

man

agem

ent

�IB

M W

ebsp

here

MQ

Wor

kflo

w, M

icro

soft

Biz

Talk

, SA

P,

Vitr

ia, O

racl

e W

orkf

low

, File

NET

, Doc

umen

tum

, �.

Dat

a In

tegr

atio

n Sy

stem

s(E

nter

pris

e In

form

atio

n In

tegr

atio

n)Q

uery

Med

iato

r

Che

ckin

gLo

anC

redi

t car

d

3/24

/07

20

gA

ccou

nts

Acc

ount

sA

ccou

nts

�H

eter

ogen

eous

que

ry sy

stem

s (m

edia

tors

). It�

s dat

abas

e sy

stem

softw

are,

but

��

It�s s

imila

r to

EAI w

ith m

ore

focu

s on

data

tra

nsfo

rmat

ions

than

on

mes

sage

mgm

t�

Ther

e ar

e hy

brid

s, e.

g., B

EA A

quaL

ogic

Tran

sact

iona

l Mid

dlew

are

�In

sum

mar

y, th

ere

are

man

yva

riatio

ns th

at

pack

age

diff

eren

t com

bina

tions

of m

iddl

ewar

e fe

atur

es.

�A

pplic

atio

nSe

rver

3/24

/07

21

App

licat

ion

Serv

er�

Ente

rpris

e A

pplic

atio

n In

tegr

atio

n �

Bus

ines

s pro

cess

man

agem

ent (

aka

Wor

kflo

w)

�En

terp

rise

Serv

er B

us�

New

one

s all

the

time,

that

def

y ca

tego

rizat

ion.

Syst

em S

oftw

are

Ven

dor�

s Vie

w�

TP is

par

tly a

com

pone

nt p

rodu

ct p

robl

em�

Har

dwar

e�

Ope

ratin

g sy

stem

�D

atab

ase

syst

em

3/24

/07

22

�A

pplic

atio

n Se

rver

�TP

is p

artly

a sy

stem

eng

inee

ring

prob

lem

�G

ettin

g al

l tho

se c

ompo

nent

s to

wor

k to

geth

er

to p

rodu

ce a

syst

em w

ith a

ll th

ose

�ilit

ies�

.

�Th

is c

ours

e fo

cuse

s prim

arily

on

the

Dat

abas

e Sy

stem

and

App

licat

ion

Serv

er

Out

line

!1.

The

Bas

ics

2. A

CID

Pro

perti

es3

Ato

mic

ityan

dTw

oPh

ase

Com

mit

3/24

/07

23

3. A

tom

icity

and

Tw

o-Ph

ase

Com

mit

4. P

erfo

rman

ce5.

Sty

les o

f Sys

tem

1.2

The

AC

ID P

rope

rties

�Tr

ansa

ctio

ns h

ave

4 m

ain

prop

ertie

s�

Ato

mic

ity -

all o

r not

hing

�C

onsi

sten

cy-p

rese

rve

data

base

inte

grity

3/24

/07

24

Con

sist

ency

pr

eser

ve d

atab

ase

inte

grity

�Is

olat

ion

-exe

cute

as i

f the

y w

ere

run

alon

e�

Dur

abili

ty -

resu

lts a

ren�

t los

t by

a fa

ilure

Ato

mic

ity�

All-

or-n

othi

ng, n

o pa

rtial

resu

lts.

�E.

g. in

a m

oney

tran

sfer

, deb

it on

e ac

coun

t, cr

edit

the

othe

r. Ei

ther

deb

it an

d cr

edit

both

run,

or n

eith

er ru

ns.

�Su

cces

sful

com

plet

ion

is c

alle

d C

omm

it.�

Tran

sact

ion

failu

re is

cal

led

Abor

t.

3/24

/07

25

�C

omm

it an

d ab

ort a

re ir

revo

cabl

e ac

tions

.�

An

Abo

rt un

does

ope

ratio

ns th

at a

lread

y ex

ecut

ed�

For d

atab

ase

oper

atio

ns, r

esto

re th

e da

ta�s

pre

viou

s val

ue

from

bef

ore

the

trans

actio

n�

But

som

e re

al w

orld

ope

ratio

ns a

re n

ot u

ndoa

ble.

Exam

ples

-tra

nsfe

r mon

ey, p

rint t

icke

t, fir

e m

issi

le

Exam

ple

-ATM

Dis

pens

es M

oney

(a n

on-u

ndoa

ble

oper

atio

n)T1: Start

. . .

Dispense Money

Commit

Syst

em c

rash

esTr

ansa

ctio

nab

orts

3/24

/07

26

T1: Start

. . .

Commit

Dispense Money

Syst

em c

rash

es

Def

erre

d op

erat

ion

neve

r get

s exe

cute

d

Tran

sact

ion

abor

tsM

oney

is d

ispe

nsed

Rea

ding

Unc

omm

itted

Out

put I

sn�t

Und

oabl

eT1: Start

...

Display output

...

If error, Abort

Use

r rea

ds o

utpu

t� U

ti

t

3/24

/07

27

T2: Start

Get input from display

...

Commit

Use

r ent

ers i

nput

Bra

intra

nspo

rt

Com

pens

atin

g Tr

ansa

ctio

ns�

A tr

ansa

ctio

n th

at re

vers

es th

e ef

fect

of a

noth

er

trans

actio

n (th

at c

omm

itted

). Fo

r exa

mpl

e,

��A

djus

tmen

t� in

a fi

nanc

ial s

yste

m�

Ann

ul a

mar

riage

�N

otal

ltra

nsac

tions

have

com

plet

eco

mpe

nsat

ions

3/24

/07

28

Not

all

trans

actio

ns h

ave

com

plet

e co

mpe

nsat

ions

�E.

g. C

erta

in m

oney

tran

sfer

s�

E.g.

Fire

mis

sile

, can

cel c

ontra

ct�

Con

tract

law

talk

s a lo

t abo

ut a

ppro

pria

te c

ompe

nsat

ions

"A

wel

l-des

igne

d TP

app

licat

ion

shou

ld h

ave

a co

mpe

nsat

ion

for e

very

tran

sact

ion

type

Con

sist

ency

Ever

y tra

nsac

tion

shou

ld m

aint

ain

DB

con

sist

ency

�R

efer

entia

l int

egrit

y -E

.g. e

ach

orde

r ref

eren

ces a

n ex

istin

g cu

stom

er n

umbe

r and

exi

stin

g pa

rt nu

mbe

rs�

The

book

s bal

ance

(deb

its =

cre

dits

, ass

ets =

liab

ilitie

s)"

Con

sist

ency

pres

erva

tion

isa

prop

erty

ofa

3/24

/07

29

"C

onsi

sten

cy p

rese

rvat

ion

is a

pro

pert

y of

a

tran

sact

ion,

not

of t

he T

P sy

stem

(u

nlik

e th

e A

, I, a

nd D

of A

CID

)�

If e

ach

trans

actio

n m

aint

ains

con

sist

ency

, th

en se

rial e

xecu

tions

of t

rans

actio

ns d

o to

o.

Som

e N

otat

ion

�r i[

x] =

Rea

d(x)

by

trans

actio

n T i

�w

i[x] =

Writ

e(x)

by

trans

actio

n T i

�c

=C

omm

itby

trans

actio

nT

3/24

/07

30

�c i

= C

omm

it by

tran

sact

ion

T i�

a i=

Abo

rt by

tran

sact

ion

T i�

A h

isto

ryis

a se

quen

ce o

f suc

h op

erat

ions

, in

the

orde

r tha

t the

dat

abas

e sy

stem

pr

oces

sed

them

.

Con

sist

ency

Pre

serv

atio

n Ex

ampl

e T 1

: Sta

rt;A

= R

ead(

x);

A =

A -

1;W

rite(

y, A

);C

omm

it;

T 2: S

tart;

B =

Rea

d(x)

;C

= R

ead(

y);

If (

B >

C+1

) the

n B

= B

-1;

Writ

e(x,

B);

Com

mit;

3/24

/07

31

�C

onsi

sten

cy p

redi

cate

is x

> y

.�

Seria

l exe

cutio

ns p

rese

rve

cons

iste

ncy.

Inte

rleav

ed e

xecu

tions

may

not

.�

H =

r 1[x

] r2[

x] r 2

[y] w

2[x]

w1[

y]�

e.g.

try

it w

ith x

=4 a

nd y

=2 in

itial

ly

Isol

atio

n�

Intu

itive

ly, t

he e

ffec

t of a

set o

f tra

nsac

tions

sh

ould

be

the

sam

e as

if th

ey ra

n in

depe

nden

tly�

Form

ally

, an

inte

rleav

ed e

xecu

tion

of

trans

actio

ns is

seri

aliz

able

if it

s eff

ect i

s e q

uiva

lent

to a

seria

l one

.

3/24

/07

32

q�

Impl

ies a

use

r vie

w w

here

the

syst

em ru

ns e

ach

user

�s tr

ansa

ctio

n st

and-

alon

e.�

Of c

ours

e, tr

ansa

ctio

ns in

fact

run

with

lots

of

conc

urre

ncy,

to u

se d

evic

e pa

ralle

lism

.

A S

eria

lizab

ility

Exa

mpl

eT 1

: Sta

rt;A

= R

ead(

x);

A =

A +

1;

Writ

e(x,

A);

Com

mit;

T 2: S

tart;

B =

Rea

d(x)

;B

= B

+ 1

;W

rite(

y, B

);C

omm

it;

3/24

/07

33

�H

= r 1

[x] r

2[x]

w1[

x] c

1w

2[y]

c2

�H

is e

quiv

alen

t to

exec

utin

g T 2

follo

wed

by

T 1�

Not

e, H

is n

oteq

uiva

lent

to T

1 fo

llow

ed b

y T 2

�A

lso,

not

e th

at T

1 st

arte

d be

fore

T2 an

d fin

ishe

d be

fore

T2,

yet t

he e

ffec

t is t

hat T

2ra

n fir

st.

Seria

lizab

ility

Exa

mpl

es (c

ont�d

)�

Clie

nt m

ust c

ontro

l the

rela

tive

orde

r of t

rans

actio

ns,

usin

g ha

ndsh

akes

(w

ait f

or T

1to c

omm

it be

fore

subm

ittin

g T 2

).�

Som

e m

ore

seria

lizab

le e

xecu

tions

:r 1

[x]r

2[y]

w2[

y]w

1[x]

≡T 1

T 2≡

T 2T 1

3/24

/07

34

r 1[x

] r2[

y] w

2[y]

w1[

x] ≡

T 1T 2

≡T 2

T 1r 1

[y] r

2[y]

w2[

y]w

1[x]

≡T 1

T 2≡

T 2T 1

r 1[x

] r2[

y] w

2[y]

w1[

y] ≡

T 2T 1

≡T 1

T 2�

Seria

lizab

ility

says

the

exec

utio

n is

equ

ival

ent t

o so

me

seria

l ord

er, n

ot n

eces

saril

y to

all

seria

l ord

ers

Non

-Ser

ializ

able

Exa

mpl

es�

r 1[x

] r2[

x] w

2[x]

w1[

x] (r

ace

cond

ition

)�

e.g.

T1

and

T 2ar

e ea

ch a

ddin

g 10

0 to

x�

r 1[x

] r2[

y] w

2[x]

w1[

y]�

e.g.

eac

h tra

nsac

tion

is tr

ying

to m

ake

x =

y,

but t

he in

terle

aved

eff

ect i

s a sw

ap

3/24

/07

35

�r 1

[x] r

1[y]

w1[

x] r 2

[x] r

2[y]

c2

w1[

y] c

1(in

cons

iste

ntre

trie

val)

�e.

g. T

1is

mov

ing

$100

from

x to

y.

�T 2

sees

onl

y ha

lf of

the

resu

lt of

T1

�C

ompa

re to

the

OS

view

of s

ynch

roni

zatio

n

Dur

abili

ty�

Whe

n a

trans

actio

n co

mm

its, i

ts re

sults

will

su

rviv

e fa

ilure

s (e.

g. o

f the

app

licat

ion,

OS,

D

B sy

stem

� e

ven

of th

e di

sk).

�M

akes

it p

ossi

ble

for a

tran

sact

ion

to b

e a

lega

l co

ntra

ct

3/24

/07

36

cont

ract

.�

Impl

emen

tatio

n is

usu

ally

via

a lo

g�

DB

syst

em w

rites

all

trans

actio

n up

date

s to

its lo

g�

to c

omm

it, it

add

s a re

cord

�co

mm

it(T i

)� to

the

log

�w

hen

the

com

mit

reco

rd is

on

disk

, the

tran

sact

ion

is

com

mitt

ed.

�sy

stem

wai

ts fo

r dis

k ac

k be

fore

ack

ing

to u

ser

Out

line

!1.

The

Bas

ics

!2.

AC

ID P

rope

rties

3A

tom

icity

and

Two

Phas

eC

omm

it

3/24

/07

37

3. A

tom

icity

and

Tw

o-Ph

ase

Com

mit

4. P

erfo

rman

ce

5. S

tyle

s of S

yste

m

1.3

Ato

mic

ity a

nd T

wo-

Phas

e C

omm

it�

Dis

tribu

ted

syst

ems m

ake

atom

icity

har

der

�Su

ppos

e a

trans

actio

n up

date

s dat

a m

anag

ed b

y tw

o D

B sy

stem

s.�

One

DB

syst

em c

ould

com

mit

the

trans

actio

n,

3/24

/07

38

y,

but a

failu

re c

ould

pre

vent

the

othe

r sys

tem

from

co

mm

ittin

g.�

The

solu

tion

is th

e tw

o-ph

ase

com

mit

prot

ocol

.�

Abs

tract

�D

B sy

stem

� by

reso

urce

man

ager

(c

ould

be

a SQ

L D

BM

S, m

essa

ge m

gr, q

ueue

m

gr, O

O D

BM

S, e

tc.)

Two-

Phas

e C

omm

it�

Mai

n id

ea -

all r

esou

rce

man

ager

s (R

Ms)

save

a

dura

ble

copy

of t

he tr

ansa

ctio

n�s u

pdat

es b

efor

ean

y of

them

com

mit.

�If

one

RM

fails

afte

r ano

ther

com

mits

, the

faile

d R

M c

an st

ill c

omm

it af

ter i

t rec

over

s.

3/24

/07

39

�Th

e pr

otoc

ol to

com

mit

trans

actio

n T

�Ph

ase

1 -T

�s c

oord

inat

or a

sks a

ll pa

rtici

pant

RM

s to

�pre

pare

the

trans

actio

n�.

Each

par

ticip

ant R

M re

plie

s �p

repa

red�

afte

r T�s

upd

ates

are

dur

able

.�

Phas

e 2

-Afte

r rec

eivi

ng �

prep

ared

� fr

om a

llpa

rtici

pant

RM

s, th

e co

ordi

nato

r tel

ls a

ll pa

rtici

pant

R

Ms t

o co

mm

it.

Two-

Phas

e C

omm

it Sy

stem

Arc

hite

ctur

e

Res

ourc

eTr

ansa

ctio

n

App

licat

ion

Prog

ram

Oth

er

Star

tCo

mm

it, A

bort

Read

,W

rite

3/24

/07

40

Res

ourc

eM

anag

erTr

ansa

ctio

nM

anag

er (T

M)

Tran

sact

ion

Man

ager

s1.

Sta

rt tra

nsac

tion

retu

rns a

uni

que

tran

sact

ion

iden

tifie

r2.

Res

ourc

e ac

cess

es in

clud

e th

e tra

nsac

tion

iden

tifie

r. Fo

r eac

h tra

nsac

tion,

RM

regi

ster

s with

TM

3.

Whe

n ap

plic

atio

n as

ks T

M to

com

mit,

the

TM ru

ns

two-

phas

e co

mm

it.

Out

line

!1.

The

Bas

ics

!2.

AC

ID P

rope

rties

!3

Ato

mic

ityan

dTw

oPh

ase

Com

mit

3/24

/07

41

!3.

Ato

mic

ity a

nd T

wo-

Phas

e C

omm

it4.

Per

form

ance

5.

Sty

les o

f Sys

tem

1.4

Perf

orm

ance

Req

uire

men

ts�

Mea

sure

d in

max

tran

sact

ion

per s

econ

d (tp

s) o

r pe

r min

ute

(tpm

), an

d do

llars

per

tps o

r tpm

.�

Dol

lars

mea

sure

d by

list

pur

chas

e pr

ice

plus

5 y

ear

vend

or m

aint

enan

ce (�

cost

of o

wne

rshi

p�)

�W

orkl

oad

typi

cally

hast

hisp

rofil

e:

3/24

/07

42

�W

orkl

oad

typi

cally

has

this

pro

file:

�10

% a

pplic

atio

n se

rver

plu

s app

licat

ion

�30

% c

omm

unic

atio

ns sy

stem

(not

cou

ntin

g pr

esen

tatio

n)�

50%

DB

syst

em�

TP P

erfo

rman

ce C

ounc

il (T

PC)s

ets s

tand

ards

�ht

tp://

ww

w.tp

c.or

g.

�TP

C A

& B

(�89

-�95

), no

w T

PC C

&W

TPC

-A/B

�B

ank

Telle

rs

Start

Read message from terminal

(100

byt

es)

�O

bsol

ete

(a re

tired

stan

dard

), bu

t int

eres

ting

�In

put i

s 100

byt

e m

essa

ge re

ques

ting

depo

sit/w

ithdr

awal

�D

atab

ase

tabl

es =

{A

ccou

nts,

Telle

rs, B

ranc

hes,

His

tory

}

3/24

/07

43

Read+write account record

(ran

dom

acc

ess)

Write history record

(seq

uent

ial a

cces

s)Read+write teller record

(ran

dom

acc

ess)

Read+write branch record

(ran

dom

acc

ess)

Write message to terminal

(200

byt

es)

Commit

�En

d of

his

tory

and

bra

nch

reco

rds a

re b

ottle

neck

s

The

TPC

-C O

rder

-Ent

ry B

ench

mar

kT

able

Row

s/W

hse

Byt

es/r

owW

areh

ouse

189

Dis

tric

t10

95C

usto

mer

30K

655

His

tory

30K

46O

rder

30K

24

3/24

/07

44

�TP

C-C

use

s hea

vier

wei

ght t

rans

actio

ns

Ord

er30

K24

New

-Ord

er9K

8O

rder

Lin

e30

0K54

Stoc

k10

0K30

6It

em10

0K82

TPC

-C T

rans

actio

ns�

New

-Ord

er�

Get

reco

rds d

escr

ibin

g a

war

ehou

se, c

usto

mer

, & d

istri

ct�

Upd

ate

the

dist

rict

�In

crem

ent n

ext a

vaila

ble

orde

r num

ber

Inse

rtre

cord

into

Ord

eran

dN

ewO

rder

tabl

es

3/24

/07

45

�In

sert

reco

rd in

to O

rder

and

New

-Ord

er ta

bles

�Fo

r 5-1

5 ite

ms,

get I

tem

reco

rd, g

et/u

pdat

e St

ock

reco

rd�

Inse

rt O

rder

-Lin

e R

ecor

d�

Paym

ent,

Ord

er-S

tatu

s, D

eliv

ery,

Sto

ck-L

evel

hav

e si

mila

r com

plex

ity, w

ith d

iffer

ent f

requ

enci

es�

tpm

C =

num

ber o

f New

-Ord

er tr

ansa

ctio

n pe

r min

.

Com

men

ts o

n TP

C-C

�En

able

s app

les-

to-a

pple

s com

paris

on o

f TP

syst

ems

�D

oes n

ot p

redi

ct h

ow y

oura

pplic

atio

n w

ill ru

n,

orho

wm

uch

hard

war

eyo

uw

illne

ed,

3/24

/07

46

or h

ow m

uch

hard

war

e yo

u w

ill n

eed,

or

whi

ch sy

stem

will

wor

k be

st o

n yo

ur w

orkl

oad

�N

ot a

ll ve

ndor

s opt

imiz

e fo

r TPC

-C.

�So

me

high

-end

syst

em sa

les r

equi

re c

usto

m

benc

hmar

ks.

Typi

cal T

PC-C

Num

bers

�A

ll nu

mbe

rs a

re h

ighl

y se

nsiti

ve to

dat

e su

bmitt

ed.

�$1

-$6

/ tp

mC

for r

esul

ts re

leas

ed in

200

6-20

07.

�Lo

w e

nd n

umbe

rs a

re a

lmos

t all

MS

SQL

Serv

er &

Win

dow

s. �

Hig

h en

d is

mos

tly O

racl

e an

d IB

M, L

inux

, BEA

Tux

edo

�Sy

stem

cos

t $27

K (H

P) -

$12M

(IB

M)

3/24

/07

47

�Ex

ampl

es o

f hig

h th

roug

hput

(32

dual

-cor

e pr

oces

sors

)�

IBM

, 4.0

M tp

mC

, $12

.0M

, $2.

97/tp

mC

(1

/22/

07 IB

M A

IX/D

B2,

MS

Win

dow

s/C

OM

+)�

Exam

ples

of l

ow c

ost (

MS

SQL

Serv

er, W

indo

ws,

CO

M+)

�H

P Pr

oLia

nt, 1

8K tp

mC

, $28

K, $

1.57

/tpm

C, 1

0/19

/04

�D

ell,

70K

tpm

C, $

66K

, $0.

96/tp

mC

, 3/9

/07

Com

ing

Soon

, TPC

-E

�A

ppro

ved

Mar

ch 0

7�

Rep

lace

s TPC

-C, i

t�s d

atab

ase-

cent

ricA

bk

lii

3/24

/07

48

�A

bro

kera

ge a

pplic

atio

n�

Mor

e re

alis

tic d

isk

conf

igur

atio

n (s

mal

ler %

of

pric

e)

Out

line

!1.

The

Bas

ics

!2.

AC

ID P

rope

rties

!3

Ato

mic

ityan

dTw

oPh

ase

Com

mit

3/24

/07

49

!3.

Ato

mic

ity a

nd T

wo-

Phas

e C

omm

it!

4. P

erfo

rman

ce

5. S

tyle

s of S

yste

m

1.5

Styl

es o

f Sys

tem

s�

TP is

Sys

tem

Eng

inee

ring

�C

ompa

re T

P to

oth

er k

inds

of s

yste

m

engi

neer

ing

��

Bat

ch p

roce

ssin

g -S

ubm

ita

job

and

rece

ive

file

tt

3/24

/07

50

outp

ut.

�R

eal t

ime

-Sub

mit

requ

ests

that

hav

e a

dead

line

�D

ata

war

ehou

se -

Subm

it qu

erie

sto

a sh

ared

da

taba

se, p

opul

ated

from

TP

data

sour

ces

�TP

-Su

bmit

a re

ques

tto

run

a tra

nsac

tion

TP v

s. B

atch

Pro

cess

ing

(BP)

�A

BP

appl

icat

ion

is u

sual

ly u

nipr

ogra

mm

ed so

se

rializ

abili

ty is

triv

ial.

TP is

mul

tipro

gram

med

.�

BP

perf

orm

ance

is m

easu

red

by th

roug

hput

.TP

is a

lso

mea

sure

d by

resp

onse

tim

e.�

BP

can

optim

ize

by so

rting

tran

sact

ions

by

the

file

key.

TP

mus

than

dle

rand

omtra

nsac

tion

arriv

als

3/24

/07

51

TP m

ust h

andl

e ra

ndom

tran

sact

ion

arriv

als.

�B

P pr

oduc

es n

ew o

utpu

t file

. To

reco

ver,

re-r

un th

e ap

p.�

BP

has f

ixed

and

pre

dict

able

load

, unl

ike

TP.

�B

ut, w

here

ther

e is

TP,

ther

e is

alm

ost a

lway

s BP

too.

�TP

gat

hers

the

inpu

t. B

P po

st-p

roce

sses

wor

k th

at h

as w

eak

resp

onse

tim

e re

quire

men

ts�

So, T

P sy

stem

s mus

t als

o do

BP

wel

l.

TP v

s. R

eal T

ime

(RT)

�R

T ha

s mor

e st

ringe

nt re

spon

se ti

me

requ

irem

ents

. It m

ay

cont

rol a

phy

sica

l pro

cess

.�

RT

deal

s with

mor

e sp

ecia

lized

dev

ices

.�

RT

does

n�t n

eed

or u

se a

tran

sact

ion

abst

ract

ion

usua

llylo

ose

abou

tato

mic

ityan

dse

rializ

abili

ty

3/24

/07

52

�us

ually

loos

e ab

out a

tom

icity

and

seria

lizab

ility

�In

RT,

resp

onse

tim

e go

als a

re u

sual

ly m

ore

impo

rtant

th

an c

ompl

eten

ess

or c

orre

ctne

ss. I

n TP

, cor

rect

ness

is

para

mou

nt.

TP a

nd D

ata

War

ehou

se

�Tw

o us

age

scen

ario

s�

Popu

late

the

war

ehou

se (e

xtra

ct, t

rans

form

, loa

d (E

TL))

�R

un q

uerie

s aga

inst

the

data

war

ehou

se

3/24

/07

53

�O

ften

long

-run

ning

que

ries,

usua

lly w

ith lo

wer

dat

a in

tegr

ity re

quire

men

ts th

an T

P.�

TP sy

stem

s pro

vide

the

raw

dat

a fo

r DSS

s.

Out

line

!1.

The

Bas

ics

!2.

AC

ID P

rope

rties

!3

Ato

mic

ityan

dTw

oPh

ase

Com

mit

3/24

/07

54

!3.

Ato

mic

ity a

nd T

wo-

Phas

e C

omm

it!

4. P

erfo

rman

ce

!5.

Sty

les o

f Sys

tem

Wha

t�s N

ext?

�Th

is c

hapt

er c

over

ed T

P sy

stem

stru

ctur

e an

d pr

oper

ties o

f tra

nsac

tions

and

TP

syst

ems

�Th

ere

stof

the

cour

sedr

illsd

eepl

yin

toea

ch

3/24

/07

55

The

rest

of t

he c

ours

e dr

ills d

eepl

y in

to e

ach

of th

ese

area

s, on

e by

one

.