Access Mode:: 7.13 Transaction Support in SQL
Access Mode:: 7.13 Transaction Support in SQL
Access Mode:: 7.13 Transaction Support in SQL
Locking is one of the important techniques used in concurrency to overcome the anomalies due
interleaved execution. Lock is a variable associated with an object which indicates the possible
operations that can be performed on it. There can be only one lock on an object.
Following rules must be followed by every transaction to achieve concurrency control using
binary lock
1. A transaction must issue the operation LOCK (A) before it wants to read or write an object A.
2. A transaction T must issue the operation UNLOCK(A) after all read and write operations
on object A is completed.
3. A transaction Twill not issue a LOCK(A) operation if it already has the lock on object A.
4. A transaction T will not issue an UNLOCK(A) operation unless it already holds the lock on
object A.
5. The lock manager module of the DBMS can enforce the above said rules. Lock will be set
between LOCK(A) and UNLOCK(A) operations. At most one transaction can hold the lock
on a particular object at any given instance of time. Thus no two transactions can access
the' same object concurrently. For example two customers want to know the availability(
number )rooms in hotel. The schedule has two transactions Tl(user 1) and T2 (user 2) who
want to read N and check the availability
Tl T2
LOCK(N)
LOCK(N) transaction has to
wait until the completion of
Tl, since the object N has been
locked by Tl
R(N)
UNLOCK(N)
There is no lock for object N and T2 gets unblocked
and is allowed to execute
R(N)
UNLOCK(N)
j
ntage of binary locks
o,sadva
can access the object of the DB , even if the transa ction is readin g the
Mmost only one transa ction
.1 s of an object X.
w.1ue
, , Shared/exclusive lock
714 2
action of all these
This method allows more than one transa ction to access an object if the
is allow ed to
rransaction is read. If the transa ction writes an object then only one transa ction
ple transa ction
access it. This is the princi ple used in shared/exclusive lock. The reason is multi
when reads the same objec t X does not have any conflicts.
There are two types of locks that can be used
► Share d Lock ► Exclusive Lock
share d locks
Shared lock is applie d when an object from a data base has to be read. Multi ple
can be applied on the same object. Shared lock can be symbolized as 'S'.
n. Only one
Exclusive lock applie d when an object from a data base has to be writte
ction) . Exclu sive
transaction can apply an exclusive lock on an object(exclusively for that transa
lock is symbolized by 'X'.
Tl applie s
For example transa ction Tl and T2 wants to read an object A. initial ly transa ction
on objec t A and
ashared lock on objec t A, followed by transaction T2 can also apply a share d lock
then any transa ction can read the object, the schedule is as follows
Tl T2
S(A)
S(A)
R(A)
R(A)
objec t has to be
. Transaction Tl applies a shared lock on object A for readin g if the same
exclusive lock (Read
Written by transa ction T2 then transa ction T2 will not be allowed to apply
followed by write is not allow ed since it creates conflicts).
Tl T2
S(A)
X(A) Block ed
R(A)
Other actions
Transaction Tl applies a exclusive lock on object A for writing and if the same object has
to
be written by transaction T2 then transaction T2 will not be allowed to apply exclusive lock
( write
followed by read is not allowed). IfT3 wants to read the object A then the transac tion will
not be
allowed to apply shared lock also.
Tl T2 T3
X(A)
X(A) Blocked
R(A)
S(A) Blocked
W(A)
Transaction that has an exclusive lock can also read the object; an additio nal shared lock
is
not required. A transac tion that requests a lock is suspended (stopped) until the DBMS
is able to
grant the requested lock.
One of the metho d to implement shared/ exclusive lock is to keep track of the numbe r
of
transac tions holdin g read lock on an object X which is saved in lock table. The dtails of
it would
be<object_name, LOCK, No_of _reads, transaction_list> where object_name: is the object
name;
LOCK: indicates wheth er it is shared or exclusive lock; No_of_reads: this is only applica
ble for
SHARED lock & indicates the numbe r of transactions using this object as read, if it is
exclusive
lock then the value is one indicating that there is only one transaction using object as write;
and
transaction_list: contains a list of transactions if it is SHARED lock or transac tion ID of
a single
transac tion if it is EXCLUSIVE.
Unlock(X) is used to release the lock held by a transaction on object X or the locks gets
automatically released when the transaction commits. shared/ exclusive lock is used the
system
enforces the following
1. A transac tion applies shared/exclusive lock on object X before it wants to read/w
rite on an
object X.
2. A transac tion has to use exclusive lock before write action is perfor med on object
X
3. A transaction has to release the lock on an object once read/write is completed.
4. A transac tion will not apply shared lock on an object X if it has already applied
shared or
exclusive lock on the same object X.
s. A transaction will not apply exclusive lock on an object X if it has already applied shared or
exclusive lock on the same object X.
6. A transaction will apply unlock on an object X if it has been either locked as shared or
ex-
clusive lock on the object X.
7.14,3conversion
of locks
Tl T2
S(A)
S(C)
R(A)
R(C)
UNLOCK(A) a4
UNLOCK( C) as
X(C) a6
X(A) a7
R(C)
R(A)
w·cc)
W(A)
UNLOCK(C)
UNLOCK(A)
In this example Tl ot T2 will lock all the objects which is required for transaction(growing
phase) and later once the transaction has completed read/write on objects the locks gets released
at the end(shrinking phase). The above schedule hence follows 2 PL, this protocol when used
ensures Serializability of schedules( concurrent execution with no anomalies).
For example there are two transaction Tl: transferring of amount Rs 500 from account A to
account B and T2 : Adding Rs 10 as interest to account A.
Assume the initial balance of A=lS00 & B=800
Tl T2
Action 1 X(A)
Action 2 R(A) A=lS00
Action 3 W(A) A=IS00-500 =1000
Action 4 X(A) Blocked
Action 5 X(B)
Action 6 R(B) B=S00
Action 7 W(B) B=S00+ 500= 1300
Action 8 Commit Locks are release
Action 9 R(A) A-1000
Action 10 W(A) A-1000+10 -1010
Action 11 Commit Locks are released
Transa ction Tl applies an exclu · .
l f A which is d Sive 1ock sin e object A has to be written , it initiall y reads
0 1500
the va ue . k b. an deducts 500 from it. In action 4 transac tion T2 will request for
an exclusive 1ode) ~n Jee~ A , which makes the transaction T2 blocke d ( mul tiple exclusi ve
° lode
are not all owe . 1 ransac tion T 1 cont"mues, m . . .
action 5 it applies the exclusi ve lock on obJect B
since the object has to be written , reads B which is 800 and adds 500 to it Transa ction T l
comm its
and releases _all ~e locks. Transa ction T2 after action 8 gets unbloc ked & starts executing,
it reads
object A which is ~OO~ adds 10 and saves it throug h commit, Lock gets release d. The result
of this
interleaved execut ion is exactly equiva lent to serial executi on .
There are numbe r of variant s of two phase locking
7.14.5 Basic
The above mentio ned metho d is basic 2 PL
Tl T2
i
X(A)
S(B)
X(D)
W(A) I
R(B) i
Unloc king is done in betwe en
UNLO CK(B)
the transa ctio n
X(B)
I
W(D) I
COMM IT will release all locks
W( B)
C OMM IT will releas e all locks
7.14.7 Rigorous 2 PL:
. .I Iock(both shared and exclusive) until it commi ts or aborts.
In this transactron does not re ease any
Tl T2
X(A)
W(A)
X(D)
S(B)
vV(D)
are
Locks can be applied in betwee n but after the transac tion comm its/ aborts the locks
released. It has a shrink ing phase only.
Tl T2
Action I X(A)
Action 2 X(B)
Action 3 R(A) A=l50 0
Action 4 R(B) 8=800
Action 5 W(A) A-=150 0-500 =1000
Action 6 W(B) B-800 + l0 -810
Action 7 X(B) Bloc ,rd
1
To I cd lh the I cpc111cd .,hor t ~1rc~turt s, th e cau tious algorithm was propose. In this approach,
l'
1-uppnM' tl wrr 1lH' two t 1 ,lllM\Ct ion Ti and Tj. Ti is waiting for a object X which is locked by Tj. The
lollowin~ PJ)1 h)n~ ,\re applied
lf t 1.m~,H tion Tj is already blocked since it is waiting for object X in some other transaction
thrn 'I,,~ .,hortcd .
'llH.' C i'\ut iou~ Waiting is Deadlock Free because no transaction will never wait for another
hlod{(:-d t rall!,:lCt ion .
·1h,-, b th e most practi cal approach used in transactions. the system checks whether there is a any
dead lock~ among t ransaclion. lf th ey exists then some of the transactions are aborted and are
allowed to restart form the beginning.
'n1 c most simplest way lo detect deadlock is by using wait-for-graph. In wait-for graph the
follo wing steps are performe d
• A node is construct ed for each transaction.
• An edge is drawn for Ti to Tj if Ti is waiting for an object which is held by transaction Tj.
Example
Tl T2
X(A)
X(B)
W(A)
--
X_(A) get ~ hl ocked
-
For this transactio n a wait for graph can be construct ed, T2 is waiting for transactio n Tl to
complcte(it requires object A whi ch i1. held by TI).
This graph shows that it is acyclic and there is no dead lock. transaction will continue as
follows
Tl T2
X(A)
X(B)
W(A)
X(A) gets blocked
commit gets unblocked
W(B)
W(A)
Commit
Example _
Tl T2 T3
X(A)
X(B)
X(C)
W(A)
X(B) gets blocked
W(B)
X( C) gets blocked
W(C)
X(A) gets blocked
Wait for graph for the above transaction would be
d
_1s.2The timestamp ordering algorithm
7
'fhe prerequisite of th is approach is that the transaction must be given time stamp in a predefined
order. Transactions which participate in the schedule can be then serializable, and the only
transaction which is allowed to access the objects is based on the time stamp ordering and this
approach is called timestamp ordering (TO). This method uses two timestamp values for the same
object X
read_TS(X). this is the largest timestamp among all the transactions timestamp that use the
object X and have successfully read object x. then read_TS(X) = TS(T) retrieves the times tamp of
the youngest transaction that has read object X successfully.
write_TS(X). this is the largest timestamp among all the transactions timestamp that use the
object X and have successfully written object x. then write_TS(X) = TS(T) retrieves the timestamp
of the youngest transaction that has written object X successfully.
a. If timestamp value of read_TS(X) is greater than the star~ing time of transaction which
is TS(T) or if timestamp value of write_TS(X) is greater than the starting time of trans-
action TS(T), then it means some other transaction has already used the object X and
it gets rolled back.
b. If the above condition does not occur then the transaction is allowed to change the
value of object W(X) and the corresponding value of transaction timestamp is initial-
ized to write_TS(X)=TS(T).
2. Whenever a transaction T executes R(X) the following is checked
a. If transaction timestamp value is less than the time stamp of object X which is write_
TS(X) then it means that some other transaction has accessed the object X for write
and the transaction operation is rolled back.
b. Else then transaction executes the read_item(X) operation of T and set read_TS(X) to
the timestamp of transaction.
Example 1: Tl T2 T3
R(A)
R(A)
R(A)
Write and read time stamp of object A will be initialized to WRITE_TS(A)=O and RTS(A)=O .
this indicted that there are no transacti ons which have accessed object A. Let us try to execute the
above schedule
First transacti on reads the object A, the condition that will be checked is
If ts(Tl) < write time stamp of object A,( 10 <0 its not true), transacti on is allowed to access
the object A and read timestam p( read_TS(A)=0) is updated with the timestam p of transaction
Tl ( TS(Tl)= I0). After the execution of transacti on Tl the resultant read and write timestam p will
be equal to
READ_TS(A)=lO;
WRITE_TS(A)=O;
Next the third transacti on reads the object A
If ts(T3) < write time stamp of object A,( 30 <0 its not true), transacti on is allowed to
access the object A and read timestam p( READ_T S(A)=l0) is updated with the timestamp of
transacti on Tl( TS(T3)=30). After the execution of transaction T3 the resultant read and write
timestamp will be equal to
READ_TS(A)=30;
WRITE_TS(A)=O;
Next the second transacti on reads the object A
If ts(T2) < write time stamp of object A,( 20 <0 its not true), transacti on is allowed to access
the object A and read timestam p( READ_TS(A)=30) is not updated. Since the read timestamp
of object A( READ_TS(A)=30) is greater than timestamp of transacti on T2( T2=20). After the
execution of transaction T2 the resultant read and write timestam p will be equal to
READ_TS(A)=30;
WRITE_TS(A)=O;
Since all three transactions does not conflict the conditions and are executed successfully.
Example 2: Tl T2 T3
R(A)
W(A)
R(A)
E_TS (A)=O and READ _
Write and read time stamp of objec t A will be initia lized to WRIT
acces sed objec t A. Let us try to
rs(A)==O. th is i ndicted th at there are no transa ctions which have
execute the above sched ule
ed is
First trans actio n reads the objec t A, the condi tion that will be check
allow ed to acces s
If ts(Tl ) < write time stamp of objec t A,( 10 <O its not true) , trans actio n is
the object A and read times tamp ( READ _TS(A )=O) is updat ed
with the times tamp of trans actio n
TS(T l)=l0 ). After the execu tion of transa ction Tl the result ant
read and write times tamp will
Tl(
be equal to
READ _TS(A )=lO;
WRIT E_TS(A)=O;
tion must not be true
secon d trans actio n execu tes write on objec t A. The follow ing condi
for successfully execu ting write
if READ _TS(A ) > TS(T2) (10>20 its not true) &
if WRIT E_TS (A) > TS(T2) (0>20 and even this is not true)
tamp of trans actio n will
This trans actio n is allow ed to write and result ant read & write times
be equal to
READ _TS(A )=lO;
WRIT E_TS(A)=20;
tions can be check ed
Next first trans actio n once again reads objec t A. rThe follow ing condi
n Tl has to be rolled
If ts(Tl ) < write time stamp of objec t A,( 10 <30 its t true) , trans actio
back.
The meaning of object in SQL is either a table or a record or a column value also. For example the
employee table can be locked or record <111, 'Govind',1,2000> can be locked. The locking can also
be done for a specific department number also.
Row level locking can give better performance but is not guaranteed since it depends on the
query and application.
Suppose that the transaction Tl sets shared locks on all the employee rows wher dno=l and
retrieves the total salary. Let us assume there is one more Transaction T3 which tries to insert a
new employee row with dno= 1 and since it is writing exclusive lock is used. This new row affects
the total salary and hence the order of execution of Tl and T3 becomes important. The result
varies and this phenomenon is called the phantom problem. To overcome this probiem, locking
must be applied to the entire table.
Latches can be used for ensuring atomic execution of lock and unlock request. Before a lock is
applied, it is checked whether a latch exists for that memory/ object if latch is not applied then
the lock manager applies the latch and goes for either read or write. Once the read or write of the
object is completed the latch on that object is automatically released. If the latch already exists
for an object then the transaction will get blocked. The advantage of using latch is that it can be
applied for a particular duration of time.
Convoy(group/line) are long queue of transactions waiting for the lock. Lock manager
locks and unlocks the object through the scheduling process of Operating System(OS). Each
transaction can is equivalent to a process. Usually transactions (process) gets switched from one
transaction(process) to the other or else transactions may have to wait for a longer duration of
time(starvation). During the process of switching a transaction which has heavily used lock and
resuming it back, the delay incurred would be more. During this delay too many requests for the
objects may have been made, indirectly increasing the queue length of the transaction waiting.
These convoys can become long and affect the performance of both OS and DBMS.
7,18 INTR ODU CTI ON TO DATABASE RECOVERY PROTOCO
LS
7.1 s.1 Recovery concepts
Recovery process gets initia ted when there is a failure of a transa ction.
To recover and conve rt the
database from incon sisten t state to consi stent state, recovery mana
ger shoul d have saved certa in
details of transa ction. The details of transa ction are kept in the system
log. Infor mally the recov ery
process can be summ arize d as follows
If the failure is due to catast rophi c such as hard disk failure, the DB
will restor ed to the most
recent copy of the backu p.
The basic idea behin d defer red updat e is to defer or postp one
any actua l upda tes to the
database( whic h exists in disk) until the transa ction comp letes
its execu tion succe ssfull y and
reaches its comm it point .
Main Memory
Tl W (B)
Log Tl W (A ) Tl W(B)
Durin g transa ction execu tion, the updat es are recor ded only in
the log and in the cache
buffer s. After the transa ction reaches its comm it point and the log
is force -writt en to disk, the
updates are recor ded in the database. If a transa ction fails befor e reach
ing its comm it point , there
is no need to undo any opera tions becau se the transa ction has not
affected the datab ase on disk in
any way. Therefore, only REDO -type log entrie s are neede d in the
log, which is used to perfo rm
actions of transa ction which has been comm itted. Since we are using
only redo and no undo , the
algorithm is called NO_U NDO /RED O algor ithm.
Tl Data bue
TlW ~
Commit
Main Memory
Tl W(A) Database
Tl W(B) Object A modified
Object B modified
Commit
Main Memory
Fir-;t writes A on to DB
Tl W(A) Database
Tl W(B) 1-'i r~I writes Bon to DB
Object A modified
Object B modified
•Co1nn1it
First writes log information also
Log Tl W(A) Tl W(B ) I Log Tl W(A) Tl W(B)
caching of disk blocks
7.1 8.4
ps.MS mu st closely work wi th operatin g system to perform 1/0 activity. Althoug h th e buffer
cache can be rega rd ed as a memory resource, it is primari ly an 1/0 resource due to its use in
facilitating data transfer. When a user process issues a read request, the operatin g system sea rches
the buffer cache for th e request ed data. If the data is in the buffer cache, the request is sati sfied
,,ritbout accessing th e physical device. It is quite likely that data to be read is already in the buffer
cache because th e OS copies an entire block contain ing the data from disk into memory . This
allows any subsequ ent data falling within that block to be read more quickly from the cache in
111 e01 ory, rather than having
to re-access the disk. The OS also perform s read-ah ead of blocks on
the assumpt ion that most files are accessed from beginni ng to end. DBMS must have facilities
of invoking operati ng system API to copy contents of DB as pages of memor y and copying back
from main memor y to disk. Recovering can be assume in terms of disk pages manipu lation.
This in memory buffers referrin g to DB is called DBMC cache. This directly works under the
DBMS application and a reference is saved about which db(disk)is present in which buffer(DB:tvlS
cache). The entries would be <Disk_page_address, Buffer_location, ... > saved in a table for further
maintenance. When an update action is initiated initially it will checked whethe r the inform ation
is in DBMS cache, it exists then updatio n will be done. If the value does not exist then the block
which contains the value must be copied in to DBMS cache and is updated . During this process few
pages in the cache has to be remove d. It 1nay use least recently used(LS U), First in first out(FIF O)
or any specific method s similar to operatin g system can be used by DBMS.
To check whethe r the page in the cache has been modifie d a flag Dirty bit can be used.
This flag set on a page(va lue will be one: 1) indicates that the value has been modifie d. The entry
for this will be unset(v alue will be zero: O) when a new page is copied for DBMS to the main
memory. DBMS Cache has a director y which has the details of disk page address , buffer locatio n,
dirty bit, transac tion id which has changed the value of the page is recorde d. pin-un pin bit is
also used to check whethe r the changes made to the cache pages have success fully been saved
in to the disk. The value of one(l) indicates it is still not been copied and the transac tion has
committed. Two main strategy is used when copying modifie d cache pages to disk first strategy is
called in-place updatin g, in this approac h the content s will be copied back to the san1 e location
~nd indirectly overwrites the previou s data. This has only one copy of each block. second approac h
is called shadow ing, in this approac h it writes the updated block on to a differen t location . This
has multiple version of the same data.
The DB value before getting updated is refereed as before image(BFIM) and value
after updatio n is referred as after in1age(AFIM).ln shadow ing approac h both BFiivl and AFHvl
are saved.
7 .18.5 Write-ahead logging, Steal/No-Steal and Force/No-Force
We assume that in-place updatton • 1s • used wh1c· h means tl1e va lue is written back to the same
memory location. . . method recovery manager must ensure that BFIM of each object i
In tlus s
recorded on to log entry. 1111s must be flushe to th e d.1s k b efiO re BFIM value is. replaced with
· d
AFIM. Since we are writing the details of log before we actually write the obJect changes on
disk it is referred as write ahead logging. This requires UNDO algorithm in case of failure of a
transaction.
Steal/Nosteal approach
If the recovery protocol uses the following approach where updation made to the cache buffer( write
operation on object X which exists in main memory) by the transaction will not be written to disk(
DB)until transaction commits is referred as No-steal approach. The pin-unpin bit will indicate
whether the value within the cache has been copied back to the disk(DBMS) for a committed
transaction. This approach does not require Undo for recovery.
If the recovery protocol, updates the changes 1nade to the cache buffer( write operation on
object X which exists in main memory) by the transaction on to disk( DB) before transaction
commits is referred as Steal approach. Since we are copying the object value on to the DB before
the transaction commits and hence it is referred as steal.
Force approach
If the transaction changes an object in cache buffer(main memory in the form of pages) it must be
immediately changed on disk(DB), this is refereed as Force approach or else it is No-force.
Assume that a transaction Tl wants to read a data object A, but the Cache buffer(main memory)
is full with pages of other transaction. So Tl needs to clear some cache buffer memory, this is
done by moving some other page in cache buffer to disk. This can create lot of issues because we
can't be sure that what T 1 is moving to stable storage has been committed yet. This is known as
stealing.
Forcing n1eans that ever y t·Ime a trans f
to disk(DB). This is inefficient b ac Ion commits, all the affected pages will be pushed
' ecause each b
sloW the systen1 down. c page may e written by many transact ions and will
Checkpoint is a point of time at which a record is written onto the database from the DBMS cache.
· and start
· nt point
The advantage is that when th e sys t e1n eras h es we can move to some consiste
c t er recovery.
doing redo activity. This 1nethod is, used fior 1as
The two types of checkp ointing techniques are
► Consis tent checkp ointing ► Fuzzy checkpo inting
Consis tent Checkp ointing : Consist ent checkpointing creates a consiste nt image of the
entire content s which are there in the DBMS cache. The actions taken during creation of
checkp ointing are
► The transac tions which are currentl y getting executed are suspend ed tempora rily.
► All change s in DBMS cache are written onto the disk(DB).
► A "checkp oint" record is written in the transact ion log and this log is also written to
the disk.
► The suspen ded transac tions are resumed.
Fuzzy Checkp ointing : In fuzzy checkpointing, at the time of checkpo int, since all the active
transac tions and its log are written in to disk. In case of power failure, the recover y manage r
finds the most recent check point and executed the transac tion after this point to reach to a
consiste nt state.
7.18.7 No-Un do/red o recovery based on deferred update
The basic idea behind deferre d update is to defer or postpon e any actual updates to the databas e
(which exists in disk) until the transac tion completes its executi on successfully and reaches its
commit point.
During transac tion executi on, the updates are recorde d only in the log and in the cache
buffers. After the transac tion reaches its commit point and the log is force-w ritten to disk, the
updates are recorded in the database. If a transaction fails before reaching its com mit point, there
is no need to undo any operations because the transaction has not affected the database on disk in
any way. Therefore, only REDO-type log entries are needed in the log, which is used lo perform
actions of transaction which has been committed. Since we are using only redo and no undo, the
algorithm is called NO_UNDO/REDO algorithm.
Typical deferred update protocol can be explained as follows
Transaction must not change DBMS cache until it reaches its commit point.
Transaction must have written REDO-type log entries in the log and this is forcibly written
on the disk before it reaches its commit point.
Undo Operations is required for all actions of transactions which has not been commited.
Log entry details are searched which has write of an object X were old value and new value are
saved. The log entries are executed in the reverse order.
PROCEDURE RIU_S
l. System maintains two lists of transactions in the system: the committed transactions since
the last checkpoint and the active transactions within the system
2. Undo all the write_item operations on objects which contains the old value using UNDO
procedure described below.
3. Redo the transactions write_item operations which have committed and has new value in
the log.
The UNDO procedure is defined as follows:
UNDO(WRITE_OP): this accepts a log entry of write. The log is examined which has the
object old value and new value [write_item, T, X, old_value, new_value]. The DB is copied with
the old vale. This process is continued for all the log entries.
This recovery technique does not require log. In this method all the transactions are executed in
the DBMS cache which is the main memory. This is referred as shadow because the exact replica
of the DB is created. Once all the actions of transactions are completely executed then the entire
memory is copied back to the DB. This DB can have pages and shadow of the page which go t
· ma d e o f pages.
up dated is copied to the DB · For un d erstandmg
. let us assume that DB 1s
DB
2
3
4
When there is a request from user a shadow of the table in the form of pages is created and
copied on to the main memory.
shadow DB
~ Pl-22
LlliLJ P2-44
P3-88
P4-99
For the sake of understanding let us assume that the query requires only the first two pages
whose values are 22 and 44. At this instance if there is a failure then the entire shadow is lost and
the DB is still in a consistent state.
Assume there is a change in the value of P 1-22 to P 1-11 , these changes only happen to pages
in shadow.
shadow DB
Pl-11 Pl-22
P2-44 P2-44
P3-88
P4-99
Once the execution commits only the updated pages are copied to DB.
DB
Pl-11
P2-44
P3-88
P4-99
It will be updated to the database. Hence, if there is any failure in the middle of transaction, it
will not be reflected in the database. Database will be updated after all the transaction is complete.
This approach can be used when the size of the DB is small.
-
QUESTIONS