DBMS4
DBMS4
1
Database Management Systems
UNIT
TRANSACTION
MANAGEMENT
Important Formulae
Transaction Management (1)
’ Transactions
Transactions :
’ Transaction concept Collections of operations that from a single
logical unit of work are called
’A simple Transaction Model A database transactions.
system must ensure proper
execution of transactions despite failures,
’ Storage Structure either the entire
’ Transaction Atomicity and Durability none of it does. transaction executes, or
’ Transaction Isolation A
transaction
is a, unit of
programme
’ Serializability execution that accesses and possibly updates
various data items.
’ Transaction Isolation and
Transaction Isolátion LevelsAtomicity (2) Acid Properties:
’ Implementation of Isolation Acid is a acronym which stands for
Levels
’ Atomicity
Concurrency Control:
’ Lock - Based ’ Consistency
protocols ’ Isolation
’ Multiple Granularity
’ Time Stamp - ’ Durability
Based Protocols (3)
’ Validation - Based Protocols State of transactions
’ Multi The different states of
version Schemes as follows transactions are
Recovery System - Failure
’ Storage Classification (i) Active state
(ii) Partially committed state
’ Recovery and Atomicity
’ Recovery Algorithm (ii) Failstate
’ Buffer Management (iv) Abort state
’ (v) Full committed state
Failure with loss of non
volatile storage ARIES: ARIES as
"Algorithm for Recoveryabbreviated
-’Early lock release and as
operations logical undo exploiting semantics"
and lsolation
’
Remote backup systems Serializability :Serializability is a standard
that ensures the consistency of a schedule
Warning :
XerowPhotocopying of this book is a CRIMINAL Act. Anyone
found guilty is LIABLE to face LEGAL proceedings
Database Management Systems
42
ShortQuestions with Answers
What is a Schedule ?
Q1. What is transaction ? Q4.
Ans : Ans :
Schedule is can have many
Transaction :
A transaction is a set of changes that must
it, each comprising of a number of transact
tasks schedule is a series of actions that instrreueprictoinseosensnt
in
all be made together. It is a program unit whose sequence of execution
exeCutn maN may not change the contents of a Serial schedule :
atabase Transaction is executed as a single unit.
Ê the database waz în consistent state before a It is a schedule in which
ranstion, then after exEcution of the transaction aligned in such a way that one transaction are
asn the databE must be in a consistate executed first when the first transactiontransaction is
n a transaction, database is accessed by two its cycle. then the next transaction iscompletes
executed
operations transaction are ordered one after the other. T
() Read (x
type of schedule is called a serial schedulesa
transactions are executed in serial manner.
Wite (x)
05. Give the state diagram ofa transaction?
Q2. What is ACID properties?
Ans :
Ans : Partialy Comitted
ommited
Ans:
Warning : Xerox/Photocopying of this book is a CRIMINAL Act. Anyone found guilty is LIABLE to face LEGAL proceedings
Database Management Systems
46
Essay Questions with Answers
4.1 TRANSACTION CONCEPT A:=A-100;
Q1. Bxplain Tranhs actlon Concept briefly ? Write(A);
Ans : Read(B);
Transaction Concepts: B: = B+100;
Collection of operations that from a single Write(B);
logicalunit of work are called tr¡nsactions". ACID Properties :
For example, transfer of funds from the These are the properties that a
customers checking account to a savings
account is a single operation, however it
should posses in order to avoid failures
concurrent access of a database. ACID transactdurioinn,g
consists of several operations. acronym which stands for atomicity. is pn
It is also essential that all these operations,
occur, or in case of failure non occurs.
Isolation and durability.
(1) Atomicity :
consistency,
It would be acceptable if the checking Atomicity ensures that the
either executed completely ortransaction
account were debited, but the savings i
account were not credited. not executod
at all incomplete
A transcation is a unit a program execution are not valid.
transaction consequences
that accesses and possibly updates various (2) Consistency :
data items. A program contains statements
of form begin transaction and end The data in the database must always be in
transaction. a consistent state. A transaction that is
The transaction consists of all operations carried on aconsistent data should bring the
data to another consistent state after
executed between the begin and end execution.
transaction.
(3) lsolation :
Q2. What is a transaction? Explain ACID
properties ? All transactions must run in isolation from
one another that is every transaction should
Ans : be kept, unaware of the transaction and
Transactions : execute independently. The intermediate
A transactioD is a set of results generated by the transactions should
changes that must not be available to other transactions.
all the made together. It is a programme unit whose
execution may or may not change the contents of (4) Durability :
the a database. This property ensures that data remains in a
Transaction is executed as a single unit if consistent state even after failure. This is
the database was in consistent state before a ensured by loading modified data into disk.
transaction then after execution of the transaction This task is handled by recovery management
also, the database be in a consistent. component of DBMS
In atransaction, database is accessed by two 4.2 TRANSACTION STATE
operations
Q3. Explain different states of transactions
(i) Read (x);
Ans :
(i) Write (x);
The different states of transactions are as follows:
The first one performs the reading operation
of data item from the (1) Active state
database, whereas the
second one performs the writing operation of data (2) Partially committed state
item x to the database consider a transactions Ti
(3) Fail state
which transfers $100 from 'A' account to 'B'
account. This transaction will be as follows. (4) Abort state
Ti=read(A); (5) Full committed state
Warning : XeroxJPhotocopying of this book is a CRIMINAL Act. Anyone found guity is LIABLE to face LEGAL proceeu
4.7 Database Management Systems
4.3
IMPLEMENTATION OF ATOMICITY AND
Active
DURABILITY
Q4. Explain shadow - copy
atomicity and durability ?technique for
Ans :
Partialy
Fail
Shadow - copy Technique:
ommitted There are many technique that are
by recovery employed
atomicity andmanagement component for ensuring
"shadow - copy"durability.
technique.
One such technique is
copies of database calledWhere many duplicate
shadow copies are
created. This technique assumes
ommitt Aborted (i) that
There is onlyone active
time. transactions at any
(ü) Database is
on the disk. nothing but a file which is written
Working of shadow - copy
Kill
restart
technique :
Before performing any sort of
in the modifications
database, it is necessary
FIG: State diagram of a transaction to create a copy of for the
transaction database. entire
A transaction starts in the
this point the transaction has
active state. At The operating system must
completed its that every page of new initially ensure
execution,but it is still possible that it may have disk. Once database is written onto
to be aborted, since.the actual entire database is loaded, only then
possible that it may have to be output may stillbe dptr is updated by the
database system. This
actual output may preclude its aborted, since the now points to the new copy of the database points
completion. successful then becomes the current database copy.which The
orifinal database which then deleted from disk.
(1) Active State : Once the updated obptr is written
The initial state, the the transaction is said to onto the disk
transaction
state while it is executing. stays in this committed
dbptr
(2) Partially dbptr
committed state :
After the final statement has been
(3) Failed : executed
Old data Old data New
After the discovery that base copy
no longer proceed. normal execution can base copy database
copy
(4) Aborted :
After the transaction has be rolled
back and the Figure: Before updata Figure : After Update
database has been restored to its state prior to
the start of the transaction. Shadow copy technique has the ability of
Restart : handlingtwo major issues.
If the (i) Transaction failure issue
transaction was aborted due to (ü)
hardware or software failure, System failure issue
transaction can be restarted such then the (i) Transaction failure issue:
is
considered as a new transaction.transaction The original copy of database remains
Kill : unaffected if the transaction failure occur
If the before updating dbptr
transaction was aborted due to some
internal logical error due to bad input then (ii) System failure issue :
the system can kill the
(5 transactions. The original copy of database remains
Committed state:
After successful completion.
unaffected if the system fails before writing
the updated dptr onto the disk.
Warning :
Xerox/Photocopying of. this book is a CRIMINAL Act. Anyone found guilty is LIABLEto face LEGAL proceedings
Databese Manngement Syatems
Q5, Explaln tn detall aboutthe datn structures DPT thenthe value of Rec LSNis set
current log end, but when the
of ARIES?
to the disk, then it is deleted pae is
Ana: fron the
page table, In additiorn to DPT
Following datastctures are associated with transactions checkpoint log and iy
the logvecords in ARIES record the inforrnation recorda,
record in last LSN field. about the last
(a) log sequence number (LSN)
(b) Page |SN 4.4 CONCURRENT EXECUTIONS
Explain B* tree
(c) Compensation log records Q6.
concurr-ency control locking
with used
(d)
(a)
Check point log record
Log sequence number :
Ans :
example?
suitabl,
In ARIES, everylog recond has anassoclated Concurrency control using B' - tree:
log nequence number (LSN) that is
monotontcally increasing and indicates the Concurrency control using B' tree
address of the logrecord on disk. Each LSN achieved by, can te
rorresponds to a specific change to some (i) Ignoring the structure of index
transaction. In addition, each datapage will
store the LSN of the latest log record
(ii) Considering every individual page as dats
coresponding to change for that page. A log object
record is written for any of the following (iii) Applying some version of 2PL
actions Theresult of employing B* - tree concuneres
0 Updating a transaction (write) control approach is that a high lock çontentiz
() Committing a transaction (commit) exist in the higher level nodes of the tree. Thit
(ni) Aborting a transaction (abort)
because the search process initiates from the rot
node and continues to leaf node by following a
(N) Undoing an update (undo) particular path following two observations must be
(v) Ending a transaction (end) considered while úsing any of the locking protocok
Page LSN: (i Searching is directed by the higher leved
Page LSN is an identifier, which is assigned nodes and the actual data is present in the
leaf node.
to every individual page of the databases.
The value of LSN associated with the log (ii) While inserting a data value, it is necessary
record is stored in the page LSN field of the to acquire an exclusive lock on a node, i
database page by an operation that occurred there is apossibility for a split to propagat?
on that page. Page LSN is capable of back from the modified node to reach the
ensuring idempotent property, whenever root node.
physiological redo operation is present. Before inítiating thesearch process. every
Because if this operation is applied tree node i.e, from root node to the desired lea
repeatediy. it leads to inconsistent result
node must acquire a separate shared locs
(c) Compensation log records : However, it is necessary to ensure that, wne"
These are the specialkind of log records that node acquires a shared lock, the lock acquiredb
perform only redo operation these records its parent lock is released. The purpose of releasing
lock s
are generated, when atransaction performs the lock as sons as child node acquire o
in
the rollback operation . CLR not only act as because the search process cannot propagate
aredo only log record but also as backward direction.
abort log record. operation conservative
While inserting a data value, a 'x'lock
(d) Cbeckpoint log record : locking strategy must be used in which an from
This log record contains the 0s acquired by every node being transvered| the
about dirty page table and listinformation
of active
root node to the actual node. This is because
i.e.
transactions. Dirty page Table (DPT) table split can propagate in the backward direction
acquired
stores the information regarding the pages from modified leaf to roof node. The lock thereis
that are modified in the database buffer. by the parent node is not released if
tothe
Every page isassigned a unique page LSN possibility that the split may propagate lockon
the
and ReclLSN, which helps in identifying log parent node. The process of acquiringacquired by
records that have already been reflected child node and the releasing the lock crabbing.
onto the disk, whenever a page is stored in parent node is called lock coupling or
proceeting
Warning : XeroxPhotocopying of this book ls a CRIMINAL Act. Anyone found gulty is LIABLE to
face LEGAL
Database Management Systems
4.9 associated
a7 Discuss various anomalies 4.5 SERIALIZABILITY
execution?
with inter leaved Q8. Define serializability. Explainconflict
Ans : serializabilityand view serializability in
Anomalies in inter leaved execution :
detail?
Ans :
Inter leaved transactions result into
abnormal conditions when the actions are on same Serializability:
abiect, which involves at least one write action. Serializability is the classical concurrency
There could be three conflicts. scheme. It ensures that a schedule for executing
Write - Read Confict (WR) concurrent tran sactions is equivalent to on that
(i)
Read- Write Conflict (RW) executes the transactions serially in sorne order (or)
serializability is a standard that ensures the
() Write - Write Conflict (WW) consistency of a schedule. A schedule is consistent
()
Write -Read Conflict (WR): if and only if it is seriazable. A schedule is
OReading Uncommitted Data: Atransaction T2 serializable if it is interleaved transactions produce
could read a database object a that has bèen theresult which is equivalent to the result,produced
modihed by another transaction T1, which has byexecuting individual transaction separately.
not yet been committed such a read is called a The two different types of serializabilty are
dity read. Consider the following schedule (1) Conflict serializability
T1 T2 (2) View serializabilty
RA) (1) Conflict serializability:
WIA) Consider aschedule S1, consisting of two
R(A) successive instructions I, and belonging
W(A) to transactions T, and T, respectively. If I,
RB) and I, refer to different data item then it is
W(B) very'easy to swap these instructions. The
Commit result of swapping these instructions,doesn't
R(B) have any impact on the remaining
W(B) instructions in the schedule. On the other
commit hand if I, and I, refer to same data item
The probiem with this schedule is a
then the following four cases must be
follows: considered.
The transaction T, may write into A that () I,= Read(x), I,= Read(x)
makes the database inconsistent. As long as (iü)
I,overwrites the value with a 'correct' value =Read(x), i,=Write(x)
of A before committing no harm is done. If (ii) =Write(x), I,=Read(x)
Tand T, run in some serial order because (iv) I,=Write(x).1,=Write(x)
T, will not see the temporary Two instructions I, and I, are said to be
inconsistency
in the database. But inter leaved conflicting if and only if.
execution
can lead to an inconsistency as show in
above (1) They represent the operations pertormed by
table. The problem with this schedule is the two different transactions on the same data
value ofa written by T, is read by T, before item.
Thas completed all its changes.
(iü) Read write conflict
(2) At least one among I, and I, is a write
(RW) Or operation.
unrepeatable reads: Consider the following schedule S,
This conflict arises when one T1 T2
transaction
modifies the object that was previously
by another transaction and is still read Read(x)
This is called unrepeatable read. executing. Write(x)
Read(x)
(iii) Write - write conflict
(WW): Wite(x)
This conflict arises when a transaction over Read(y)
writes an object which is modified by another Witely)
transaction still under processing. This is called Read(y)
blind writing. Wnte(y)
proceedings
Warning : LIABLE to face LEGAL
of this book is a CRIMINAL Act. Anyone foud guitty is
Xerox/Photocopying
Database Management Systems
(2) View Serializaiblity :
Two schedules S. and S consisting of same
2 Cascade less Schedule:
T1 T2
4.10
Set of transactions are said to be view
Read(x)
equivalent, if the following conditions are Read(y)
satisfied
(i) Write(x)
If atransaction TA in schedule S1 performs Read(x)
liie ieddopeiàtion on the initíal value of data
Write(x)
item x then the same transaction in schedule
S1, must also perform the read operation Read(x)
on the initial value of x. Transaction T, writes x that is
(ii) If atransaction TA in schedules S1 reads transaction T,. Transaction T, read
the value x, which was written by is read by transaction T writes x
Suppose at that thi
transactions TB then TA in schedule S1 must point T, fails, T, must be rolled
also read the valuex written by transaction T,is dependent on T,,T, must be back,
rolled since
ba
TB. and since T, is dependent on T,, T,must be
(iüü) If a transaction TA in schedule S1 performs rolled back.
the final write operation on data item x, the 4.7 IMPLEMENTATION OF IsoLATION
same transaction in schedule S1, must also
perform the final write operation on x. Q10. Explain lsolation Levels briefly ?
4.6 RECOVERABILITY Ans :
lsolation Levels :
9. Whatis recoverability ? Explain about
recoverable schedules and cascade less The isolation property is the most often
schedules ? relaxed ACID property in a DBMS.
Ans : This is because to maintain the highest level
Recoeverability: of isolation a DBMS usually acquires locks
on data, which may result in a loss of
Recoverability is a process where a
committed transaction fails to execute the read concurrency, or else implement multiversion
instruction on a data item written by aborted concurrency control, which may require
additional application logic to function
transaction when a transaction T, fails either due correctly.
to hardware/software failure or due to internal logic
error, then the effect of this transaction needs to There are 4 DBMS transaction levels:
be undone in order to ensure atomicity. In case of (a) Serializable read :
concurrent execution, if a single transaction is Serializable transaction assures that:
aborted, then all its dependent transaction must
even be aborted. Select queries issued during transaction
cannot read data that has been modified
(1) Recoverable Schedule: but not yet committed.
Arecoverable schedule is one where for each Other transactions cannot update/after
pair of transaction T, and T, such that if T, to data that has been read by current
readdata item previously written by T:, then transaction until current transaction
the commit operation of T, appears before complete.
the cormmit operation T.
(b) Repeatable read:
T1 T2
Read(x) Repeatable read transaction assures that:
’ Select queries cannot read data that has
Writelx)
Read(x) been modified but not committed.
Readly) Other transactions can update/alter the
data that has been read by current
Suppose after T,read (x) operation, it transaction.
commites and then some how T, fails, so
the transaction T, must be aborted so as to (c) Read Committed :
ensure atomicity. However since T, is Select queries cannot read data that ne
committed and can't be aborted. Hence a been modified but not committed.
situation arrives where it is impossible to -can be
The data read by one transcationbetween
recover. And hence its necessary that T
cormmits before T,. changed by other transaction
individual statements.
Warning : XeroxPhotocopying of this book is a CRIMINAL Act. Anyone found guity is LLABLE toface LEGAL procedi
(d) Database Management Systems
Read Uncomnnmitte d concurrently. The main purpose of using locks is
Select queries can read rows that to block other transactions from accessing the data
bv have been
modified other transaction but not yet items which are locked currently. The locks are
committed. granted to the transaction by a component of
4.8 TESTING FOR database management system called the lock
Q11. What is Testing for SERALICABILTY manager.
Explain briefly
Ans :
serializability ? Types of locks :
There aretwo types of locks namely
Testing for Serializability : (i) Shared lock
Testing for serializability is done by (ü) Exclusive lock
directed graph, called using a ()
Shared lock:
constructed from scheduleprecedence graph,
The set of edges Shared locks are placed on resources
for which one of consists of all edges T, ’T, a read operation (select) is whenever
these conditions hold shared locks can be performed. Multiple
Texecutes write (Q) before T, executes COurse simultaneously set on a re
read (Q) (i1) Exclusive lock :
(Texecutes
write (Q
read (Q) before Texecutes
Exclusive locks are placed on resour ces
() T executes write (Q) whenever
one
a write operation are
prfomed only
read (Q) before T, executes exclusive lock can be placed on a
resource at a time i.e, the first
acquires an exclusive lock will user whoto
have the sole continue
other user ownership
of the
can acquire an resource, and
( no
Sohedule 1 Schedale 2 on that resource. exclusive lock
Consider following schedule9. Q13. Explain the Lock
briefly ? Based Protocols
T
ead (A) Ans :
A=A-50 Lock Based
read (A)
temp: = A*0.1
Protocals :
Each transaction in a
a lockingsystem should follow
A A- temp a set of rules,
write (A) called
r e A) write (B) when a
the datatransaction
items. may lock protocol,
and unlockindicating
read (B)
each of
B B+50
wte B) Granting Locks:
B:B +temp When a transaction requests a lock on a data
The precedence write (B) item in a particular mode and no other
graph for schedule has a lock on same data transaction
9 is
the look can be item in a conflicting mode,
granted.
Starvation of
granting locks in transaction
following
can be avoided by
manner.
transaction T, requests a lock on When a
4.9 LocK BASED a particular mode a data item Q in
M, the
Q12. Define the PROTOCOLS concurrency
manager grants the lock provided that control
term lock.
Ans :
types of locks ? Explain various (1) There is no other transaction holding a lock
on Q in amode that conflicts
with M.
(2) There is no other transaction that is waiting for
Locks are
Integrdataity lockingof mechanism
the is a used to ensure
data
a lock on Q, and that made its lock
before T,.
users value lock.
wants to access
mechanism of
manipulating
Locks are used when Thus, a lock request will never get blocked
by a lock request that is made later.
Harring: Xerox/Photocopying a multiple
database object
of this book is a
CRIMINAL Act. Anyone found guilty is LIABLE to face LEGAL proceedings
Database Management Systems
4.10TIME STAMP BASED PROTOcOLS Q15. a) What is Thomas write rule? 4.1)
Q14. Explain the time - stamnp ordering
protocol ?
b) Advantages and disadvantages of time
stamp ordering protocol ?
Ans : Ans :
In timestamp based protocols, the system (a) Thomas write rule:
itself tries to detect possible inconsistency during
Thomas write rule modify or
concurrent execution and recovers from it or avoid
it. In it, for every transaction the system executes, basictimestamp ordering Algorithm (BTSO1 improves
the
the system gives the timestamp to that transaction According to Basic timestamp
i.e, it provides a set of timestamps to every Algorithm (BT Algorithm) ordering
transaction Ti by unique time stamp which is When transaction Ti issues READ
denoted by TS (Ti) where TSis time stamp of Ti.
(1)
() If TS(Ti) < WTS(Q), then
operation
TS(TI) : " ROOLBACK Ti
Whenever atransaction begins to execute
that is just prior to its execution it is provided a " RESTART Ti
time stamp. This timestamp may be based a system
stamp which is on () Otherwise
related actual read time
the system time or it may jkst be a counter.
allowed to executes READ operation by
transaction Tiand
R-Time stamp (RTS) and W -time stamp
(WTS): set RTS(Q) = Max(RTS(Q), TS(Ti)
shared we
For every data item which willbe (2) When transaction Ti issues WRITE operation:
have got two timestamps:
If TS(Ti) <RTS(Q), then
W- Time stamp(Q) or WTS(Q),: ()
Write timestamp of data item Q ROLLBACK Ti;
R Timestamp(Q) or RTS(Q): " RESTART Ti
Read -time stamp of data item Q If TS(Ti) < WTS(Q), then
(ü)
W. Timestamp(Q): ROLLBACK Ti
W - timestamp(Q) denotes the largest TS or
timesta mp value of any transaction that RESTART Ti
successfully executes write(Q)
(iüi) Otherwise
R-timestamp(Q):
Allowed to execute the WRITE operation by
R- timestamp(Q) denotes the largest TS or transaction Ti and
timestamp value of any. transaçtion that
successfully executes read(Q) Set WTS(Q) = TS(Ti)
Working of timestamp ordering protocol : (b) Time Stamp ordering protocol :
(1) If T, executes read(x) instru ction then the
following two cases must be considered Advantages:
between the
(i) T,(T) < RTS(x) (1) It ensures conflict serializability
T,(T)> WTS(×) schedules.
(iü)
which is easy
Case --i) T(T,) < RTS(x): (2) It results in a serial schedule
If a transaction T, wants to read initial value of to execute.
A dead lock a
some data time x that had been overwritten by (3) It guarantees freedom from
some younger transaction then, the transaction there are no transactions waiting.
T, cannot perform the read operation. Disadvantages :
Case (ii) T,(T,)e > WTS(×) : ofthe
(1) It doesn't ensure recoverability
If a transaction T, wants to read the value of schedules. restarted
data itemx,that had not been updated then created or1
the transaction can executed the read opera (2) If larger transactions are
repeatedly, due to the execution
tion. Once the value had been read, changes thelarger
occur in the read time stamp value (RTS(x)) conflicting transaction then starvation(i.e.
which is set by the largest valueof RTS(x) and transactions can suffer from
it can never be committed).
T,(T). proceedings
LEGAL
Warning : Xerox/Photocopying of this book lsa CRIMINAL Act. Anyone found guilty is LIABLE to face
4.13 Database Management Systems
4.11VAIDATION BASED PROTOcoLs Multiple Granularity :
ain Validntion Based Protocols Multiple Granularity is the hierarchically breaking up
briefly ? the database into portions which are
Ans and maintaining the track of what to lockable
Validatton Based Protocol: how much to be lock so that it can belockde
and
In optimistic concunency contol techniques, scribed very quickly either to lock a data item
also known as validation or certification or to unlock a data item
techniques, no checking is done while the Example of multiple Gramlartty :
transaction is being executing.
Alse based on Time stamp protocol. It has DB
three phases
Read phase :
During this phase. the system executes
transaction T It reads the values of various
data items and stores them in variable local P
to T
Validation phase:
Transaction T, performs a validation test to
determine whether it can copy to database Suppose a database is divided into files, files
the temporary local variables that hold the are divided
result of wTite operations without into pages, pages are
violation. a records.
causing divided into
1f there is a
Write phase: then a transaction can need to lock a record,
If transaction T, succeeds in is need to easily lock it. But if there
lock a file the
system applies actual updatesvalidation, then
to database, firstly are the records one transaction have to lock
after another, then pages
otherwise system rolls back T,. in that file and
finally the file. So there is a need
Toperform to provide a
validation test, we need to know
when various mechanism for
which is provided by multiplelocking the files also
place. phases of transaction T, took granularity
If we allow a
(1) Start (T): mechanism
only, then to locka file, the for locking records
The time when T, have to lock all records in transaction will
that file one after
(2) Validation (T,): started its execution. another, which is a wastage of time.
If we allow a
The Time when T,
finished its read phase then for a mechanism to locking file only.
for
and started
validation phase. records, it willtransaction
have
lock only
to lock the whole five
(3) Finish (T) : and therefore no other file
The time when T, able to use that file. transaction will be
’ start>:Transaction T, has
<I, X, V,, V,>: Transactionstarted. <T,start>
performed a write on data itemT,X,,hasX, <T,, C, 600>
had value V,before
V, after the write. write, and will have <T, Commit>
The state of log and database
<T, commit> :
committed. Transaction T, has to T, and T, is shown as corresponding
follows
’ <T, Log Database
aborted.abort>: Transaction T, has <T, start>
<To, A, 950>
Whenever a
log record fortransaction <T, B, 2050>
that performsa write, a
log exists, we can write is created. Once a <T,Commit>
to output the
database if that is desirable.modification A = 950
Two B= 2050
techniques that uses log to ensure
transaction <T, start>
atomicity
Deferred Database despite failure :are :
(i)
<T,, C, 600>
Thedeferred Modification
moditication
<T, Commit>
C= 600
transaction atomicity by technique ensures (iü)
database modifications in recording
the log, butall
Immediate databse Modification :
deterring
of a
the
execution of all write The immediate modification technique allows
transaction
Commits. until
transaction operations
database modifications to be output to the
partically database while the transaction is still in active
state.
Warning :
Xerox/Photocopying of this book is a
CRIMINAL Act. Anyone found guilty is LIABLE to face LEGAL proceedings
Database Management Systeme
Example: When T, partially commits; <T, 4.16
Let us consider banking system, with written to log. Finally
used to actually execute the
are read i
the log records
and
commit>
previously
transactions T, andT,, executed in the order
followed by T,. The portion of log
writes. During recovery after a crash,
needs to be redone if and only if both
a deferioedn
tr<T,ansact
containing the relevant information
concerning these two transactions appears
and <T, commit> are there in the log.
transaction T,(redo T) sets the yalue of
sta rt
Redoiall ng
a
>
in following figure. items updated by the transactions to
crashes can occur while. the new data values
<T, start>
<T, A, 1000, 950> The transaction is executing the origin
updates or
<T, B, 2000, 2050> While recovery action is being taken
<T,Commit> Example transactions T, and (To executes
<T, start> before T1)
<T,,C, 700, 600> T,: read(A) T,;read(c)
<T, Commit> A = A-50 C:=C-100
The one possible order in which actual write (c)
outputs took place in both the log and Read(b)
database system as a result of execution of B;=B+50
T, and T, shown as follows. Write (B)
Log Database
In the belowtable we showthe log as it
<T,start> appears at three instances of time
<T,, A, 1000, 950>
A B C
<T, B, 2000, 2050>
<ToStart> < To,Start> < To,Start>
A = 950
<To,A,950> < To,A,950> <ToA,950>
B = 2050 < To,B,2050> < To.B,2050>
<To,B,2050>
<I, Commit> <To Commit> < ToCommit>
<T, start> <T1, Start> <TI, Start>
<T,, C, 700,600> <T, C,600> <T,C,600>
<T commits>
C= 600
<T, Commit> (ii) Immediate Database Modification :
4.15 RECOVERY WITH CONCURRENT The immediate database modification
TRANSACTIONS scheme allows database updates of an
uncommitted transaction to be made as thewrites
Q23. Discuss in detail how we can achieve re are issued. Update log record must be written before
covery with concurrent transactions ? database item is written.
Ans :
Q24. Write a detailed note on buffer man
There are two techniques for ensuring atomicity in agements and explain the different buft
database they are ering techniques used for implementing
(i) Deferred database modification the crash recovery scheme ?
(iü) Immediate database modification Ans :
(i) Deferred database modification : Buffer Management :
The deferred database modification scheme The buffer is the part of MM available tor
records all modifications to be log; but defers all storage of copies of disk blocks, The subsysteni
the writes to after partial commit assume that responsible for the allocation of bufer space b
transactions execute serially transaction starts by called the buffer management. The buffer manage
writing <T, Start> record to log. A write(x) handles allrequests for blocks of the database. I
operation results in a log record <T,X, V> being the block is already in MM, the address in MMB
written where V is the new value of xthe write is given to the requestor.
not perfomed on x at this time, but is deferred. The buffer manager must use some sophisticated
techniques in order to provide good service.
Warning: Xerox/Photocopying of this book ls a CRIMINAL Act. Anyone found guilty is LIABLE to face LEGAL proceeal
4.17 Database Management Systems
Replacement Strategy :
When there is no room left in the buffer, some
block must be removed to make way for the
new one typical operating system memnory
management schemes use a "Least recentlu
used" (LRU) method. This can be improved
upon for database applications
Pinned Blocks :
For the database to be able to revover from
crashes, we need to restrict times when a
block may be written back to disk it block
not allowed to bewritten is said to be pinned.
Many operating systems do not provide
support for pinned blocks, and such a feature
is essential if database is to be "crash
resistance"
Warning :
Xerox/Photocopying of this book is a CRIMINAL Act. Anyone found guilty is LIABLE to face LEGAL proceedings