Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Transaction Management Overview

Transaction Management Overview

Ratings: (0)|Views: 65|Likes:
Published by api-3749180

More info:

Published by: api-3749180 on Oct 15, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

Database\ue000Management\ue000Systems\ue0003ed,\ue000\ue000R.\ue000Ramakrishnan\ue000and\ue000J.\ue000Gehrke
1
Transaction\ue000Management\ue000Overview
Chapter\ue00016
Database\ue000Management\ue000Systems\ue0003ed,\ue000\ue000R.\ue000Ramakrishnan\ue000and\ue000J.\ue000Gehrke
2
Transactions
Concurrent\ue000execution\ue000of\ue000user\ue000programs\ue000is\ue000essential\ue000for\ue000
good\ue000DBMS\ue000performance.
\u00a1

Because\ue000disk\ue000accesses\ue000are\ue000frequent,\ue000and\ue000relatively\ue000slow,\ue000it\ue000is\ue000 important\ue000to\ue000keep\ue000the\ue000cpu\ue000humming\ue000by\ue000working\ue000on\ue000several\ue000 user\ue000programs\ue000concurrently.

A\ue000user\u2019s\ue000program\ue000may\ue000carry\ue000out\ue000many\ue000operations\ue000on\ue000
the\ue000data\ue000retrieved\ue000from\ue000the\ue000database,\ue000but\ue000the\ue000DBMS\ue000is\ue000
only\ue000concerned\ue000about\ue000what\ue000data\ue000is\ue000read/written\ue000
from/to\ue000the\ue000database.

A\ue000transaction is\ue000the\ue000DBMS\u2019s\ue000abstract\ue000view\ue000of\ue000a\ue000user\ue000
program:\ue000\ue000a\ue000sequence\ue000of\ue000reads\ue000and\ue000writes.
Database\ue000Management\ue000Systems\ue0003ed,\ue000\ue000R.\ue000Ramakrishnan\ue000and\ue000J.\ue000Gehrke
3
Concurrency\ue000in\ue000a\ue000DBMS
Users\ue000submit\ue000transactions,\ue000and\ue000can\ue000think\ue000of\ue000each\ue000
transaction\ue000as\ue000executing\ue000by\ue000itself.
\u00a1
Concurrency\ue000is\ue000achieved\ue000by\ue000the\ue000DBMS,\ue000which\ue000interleaves\ue000
actions\ue000(reads/writes\ue000of\ue000DB\ue000objects)\ue000of\ue000various\ue000transactions.
\u00a1
Each\ue000transaction\ue000must\ue000leave\ue000the\ue000database\ue000in\ue000a\ue000consistent\ue000
state\ue000if\ue000the\ue000DB\ue000is\ue000consistent\ue000when\ue000the\ue000transaction\ue000begins.
\u2022 DBMS\ue000will\ue000enforce\ue000some\ue000ICs,\ue000depending\ue000on\ue000the\ue000ICs\ue000
declared\ue000in\ue000CREATE\ue000TABLE\ue000statements.

\u2022 Beyond\ue000this,\ue000the\ue000DBMS\ue000does\ue000not\ue000really\ue000understand\ue000the\ue000
semantics\ue000of\ue000the\ue000data.\ue000\ue000(e.g.,\ue000it\ue000does\ue000not\ue000understand\ue000how\ue000
the\ue000interest\ue000on\ue000a\ue000bank\ue000account\ue000is\ue000computed).

Issues:Effect\ue000of\ue000interleavingtransactions,\ue000and\ue000crashes.
Database\ue000Management\ue000Systems\ue0003ed,\ue000\ue000R.\ue000Ramakrishnan\ue000and\ue000J.\ue000Gehrke
4
Atomicity\ue000of\ue000Transactions

A\ue000transaction\ue000mightcommit after\ue000completing\ue000all\ue000its\ue000
actions,\ue000or\ue000it\ue000could\ue000abort (or\ue000be\ue000aborted\ue000by\ue000the\ue000DBMS)\ue000
after\ue000executing\ue000some\ue000actions.

A\ue000very\ue000important\ue000property\ue000guaranteed\ue000by\ue000the\ue000DBMS\ue000
for\ue000all\ue000transactions\ue000is\ue000that\ue000they\ue000are\ue000atomic.That\ue000is,\ue000a\ue000
user\ue000can\ue000think\ue000of\ue000a\ue000Xact\ue000as\ue000always\ue000executing\ue000all\ue000its\ue000
actions\ue000in\ue000one\ue000step,\ue000or\ue000not\ue000executing\ue000any\ue000actions\ue000at\ue000all.

\u00a1
DBMS\ue000logs all\ue000actions\ue000so\ue000that\ue000it\ue000can\ue000undo the\ue000actions\ue000of\ue000
aborted\ue000transactions.
Database\ue000Management\ue000Systems\ue0003ed,\ue000\ue000R.\ue000Ramakrishnan\ue000and\ue000J.\ue000Gehrke
5
Example
Consider\ue000two\ue000transactions\ue000(Xacts):
T1:
BEGIN\ue000\ue000\ue000A=A+100,\ue000\ue000\ue000B=B-100\ue000\ue000\ue000END
T2:
BEGIN\ue000\ue000\ue000A=1.06*A,\ue000\ue000\ue000B=1.06*B\ue000\ue000\ue000END

Intuitively,\ue000the\ue000first\ue000transaction\ue000is\ue000transferring\ue000$100\ue000
from\ue000B\u2019s\ue000account\ue000to\ue000A\u2019s\ue000account.\ue000\ue000The\ue000second\ue000is\ue000
crediting\ue000both\ue000accounts\ue000with\ue000a\ue0006%\ue000interest\ue000payment.

There\ue000is\ue000no\ue000guarantee\ue000that\ue000T1\ue000will\ue000execute\ue000before\ue000T2\ue000or\ue000
vice-versa,\ue000if\ue000both\ue000are\ue000submitted\ue000together.\ue000\ue000However,\ue000
the\ue000net\ue000effect\ue000must\ue000be\ue000equivalent\ue000to\ue000these\ue000two\ue000
transactions\ue000running\ue000serially\ue000in\ue000some\ue000order.

Database\ue000Management\ue000Systems\ue0003ed,\ue000\ue000R.\ue000Ramakrishnan\ue000and\ue000J.\ue000Gehrke
6
Example\ue000(Contd.)
Consider\ue000a\ue000possible\ue000interleaving\ue000(schedule):
T1:
A=A+100,\ue000\ue000\ue000
B=B-100\ue000\ue000\ue000
T2:
A=1.06*A,\ue000\ue000
B=1.06*B
This\ue000is\ue000OK.\ue000\ue000But\ue000what\ue000about:
T1:
A=A+100,\ue000\ue000\ue000
B=B-100\ue000\ue000\ue000
T2:
A=1.06*A,\ue000B=1.06*B
The\ue000DBMS\u2019s\ue000view\ue000of\ue000the\ue000second\ue000schedule:
T1:
R(A),\ue000W(A),\ue000\ue000\ue000
R(B),\ue000W(B)
T2:
R(A),\ue000W(A),\ue000R(B),\ue000W(B)
Database\ue000Management\ue000Systems\ue0003ed,\ue000\ue000R.\ue000Ramakrishnan\ue000and\ue000J.\ue000Gehrke
7
Scheduling\ue000Transactions
Serial\ue000schedule:Schedule\ue000that\ue000does\ue000not\ue000interleave\ue000the\ue000
actions\ue000of\ue000different\ue000transactions.
Equivalent\ue000schedules: For\ue000any\ue000database\ue000state,\ue000the\ue000effect\ue000

(on\ue000the\ue000set\ue000of\ue000objects\ue000in\ue000the\ue000database)\ue000of\ue000executing\ue000the\ue000 first\ue000schedule\ue000is\ue000identical\ue000to\ue000the\ue000effect\ue000of\ue000executing\ue000the\ue000 second\ue000schedule.

Serializable\ue000schedule:\ue000\ue000A\ue000schedule\ue000that\ue000is\ue000equivalent\ue000to\ue000
some\ue000serial\ue000execution\ue000of\ue000the\ue000transactions.
(Note:\ue000If\ue000each\ue000transaction\ue000preserves\ue000consistency,\ue000every\ue000
serializable\ue000schedule\ue000preserves\ue000consistency.\ue000)
Database\ue000Management\ue000Systems\ue0003ed,\ue000\ue000R.\ue000Ramakrishnan\ue000and\ue000J.\ue000Gehrke
8
Anomalies\ue000with\ue000Interleaved\ue000Execution
Reading\ue000Uncommitted\ue000Data\ue000(WR\ue000Conflicts,\ue000
\u201cdirty\ue000reads\u201d):
Unrepeatable\ue000Reads\ue000(RW\ue000Conflicts):
T1:\ue000 R(A),\ue000W(A),\ue000\ue000\ue000
R(B),\ue000W(B),\ue000Abort
T2:
R(A),\ue000W(A),\ue000C
T1:
R(A),\ue000\ue000
R(A),\ue000W(A),\ue000C
T2:
R(A),\ue000W(A),\ue000C
Database\ue000Management\ue000Systems\ue0003ed,\ue000\ue000R.\ue000Ramakrishnan\ue000and\ue000J.\ue000Gehrke
9
Anomalies\ue000(Continued)
Overwriting\ue000Uncommitted\ue000Data\ue000(WW\ue000
Conflicts):
T1:
W(A),\ue000\ue000
W(B),\ue000C
T2:
W(A),\ue000W(B),\ue000C

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->