SlideShare a Scribd company logo
Transaction Manager
Software is like entropy.
It is difficult to grasp,
weighs nothing,
and obeys the Second Law of Thermodynamics;
i.e., it always increases.
Norman Augstine
9:00
11:00
1:30
3:30
7:00
Overview
Faults
Tolerance
T Models
Party
TP mons
Lock Theory
Lock Techniq
Queues
Workflow
Log+RM
TM
CICS & Inet
Adv TM
Cyberbrick
Files &Buffers
COM+
Corba
Replication
Party
B-tree
Access Paths
Groupware
Benchmark
Mon Tue Wed Thur Fri
When Everything Works
Normally, no resorce manager fails, and the
system is up.The TM receives the following
calls:
Begin_Work(),
Save_Work(),
Prepare_Work(),
Commit_Work(),
Rollback_Work(),
Read_ Context().
Other “Normal” Calls
Normally, no resorce manager fails, and the
system is up.The TM receives the following
calls:
Leave_Transaction(),
Resume_Transaction(),
Status_Transaction(),
Identify(),
Join_Work().
The TM And Context
With each type of savepoint, the TM can
record context information for the transaction.
Context is provided by a resource manager and
can be reestablished when the transaction
returns to that savepoint.
For the TM, context is only a string of bytes.
The “meaning” of context is only understood
by the subsystem that created it. The context
established by a database system is different
from the one provided by a transactional GUI.
Transaction Identifiers
TRIDs must be created at high rates at each
node in a distributed system. TRIDs must be
unique in time and space.
This is the structure of a TRID:
typedef struct {TIMESTAMP BirhtdayOf TM;
RMID IDofTM;
long LocalSqncNo;
char FutureUse[2];
} TRID;
name
TMid
next_transid
birthday
RM_list
tran_list
Transaction Manager Anchor
name
rmid
up?
low_water_lsn
checkpoint_lsn
transid
status
next_savepoint
savepoint
save point lsn
rm_list
max_lsn
min_lsn
lock_list
session_list
rmid
savepoint lsn
vote
Maintained by Log Manager
Maintained by Lock Manager
session name
polarity
remote_TM_name
birthday
stuff
Locks
Log Records
Resource Manager Entries
Resource Managers
Joined to This Transaction
Transaction Descriptors
TM_anchor
RMCB
TransCB
SECB
RMTranCB
The TM´s
Data
Structures
What the TM Knows About RMs
typedef struct
{ RMCB * NextRMCB;
char RMName[BIG];
RMID IDofRM;
Boolean RMisUP;
LSN OldestLogRecForREDO;
LSN CheckpointLSN;
} RMCB;
What the TM Knows About Transactions
typedef struct
{ TransCB * NextTranCBt;
TRID TRIDofTran;
tran_status StatusOfTran;
long NextSaveptNo;
long CurrentSaveptNo;
LSN LSNofCurrentSavept;
LSN MostRecentLSNofTran;
LSN FirstLSNofTran;
to be continued ...
RMTranCB * RMsAttachedToTran;
SECB * SessionsAttachedToTran;
pointer LocksHeldByTran;
pointer LockTranWaitsFor;
long TimeoutForLockWaits;
TransCB * ForDeadlockDetector;
} TransCB;
. . . Knows About Transactions
Some Simple Addressing Functions
TRID MyTrid(void);
Returns transaction identifier of caller’s process.
TransCB MyTrans(void);
Returns a copy of caller’s transaction CB.
TransCB * MyTransP(void);
Returns pointer to caller’s transaction CB.
Implementation of MyTrid
TRID MyTrid(void)
/*return curr. TRID of calling process*/
{ TransCB * mytranp = MyTransP();
/*pointer to caller’s TA CB */
if ( mytranp != NULL )
return mytranp->trid;
/*return his trid if he has one*/
else return NULLTrid;}
/*no trid if caller has no control blk*/
Savepoints
There are seven basic types of savepoints:
Begin
Save
Prepare
Rollback
Commit
Abort
Complete
The TM Savepoint Log Record
typedef struct
{ SAVE_PT_TYPE RecordType;
long SaveptNum;
tran_status Status;
Boolean SoftOrPersistent;
long NumRMs;
RMTransCB RM[NumRMs];
long NumSess;
SECB Session[NumSess];
context ContextData;
} TM_savepoint;
Implementation of Begin_Work
TRID Begin_Work(context * it, Boolean soft)
{TransCB * trans; /*the transaction’s descriptor */
TRID him; /*the newTRID */
TM_savepoint save; /*the savept record*/
if (MyTrid() != NULLTrid) return(NULLTrid);
him = TM_anchor.next_trid; /*give nextTRID */
TM_anchor.next_trid.sequence++;
(MyProcessP())->trid = him;
trans = malloc(sizeof(TransCB));
trans->next = TM_anchor.tran_list;
TM_anchor.tran_list = trans;
trans->trid = him
Implementation of Begin_Work
trans->status = ACTIVE;
trans->save_pt = 1; trans->next_save_pt = 2;
trans->RM_list = trans->lock_list =
trans->ses_list = NULL;
save.record_type = begin;
save.save_pt_num= 1; save.soft = soft;
save.num_RM = save.sessions = 0;
copy(save.it, it, it.length);
trans->save_pt_lsn = log_insert( save, sizeof(save));
if (!soft) log_flush(trans->max_lsn,FALSE);
return(him);
};
Implementation of Commit_Work
Boolean Commit_Work(context * it, Boolean lazy)
{ TransCB * trans = MyTransP();
TM_savepoint save;
long save_num
Boolean vote;
RMTransCB * rm;
SECB * session;
if (MyTrid() == NULLTrid) return(0);
for each rm in trans->RM_list
{rm->prepared =rmid.Prepare(&rm->save_pt_lsn))
if (!rm->prepared)
{ Abort_Work();
return FALSE;};}
Implementation of Commit_Work
for each outgoing session in trans->ses_list
{vote = TM.Prepare(void);
if (! vote or timeout)
{ Abort_Work();
return FALSE;};};
trans->status = PREPARED;
save_num = trans->save_pt ++;
save.record_type = commit;
save.soft = FALSE;
save.save_pt_num = save_num;
copy(save, trans->RM_list);
copy(save, trans->ses_list);
copy(save.it, it);
Implementation of Commit_Work
trans->save_pt_lsn = log_insert( save, sizeof(save));
log_flush(trans->max_lsn, lazy);
trans->status = COMMITTING;
for each rm in trans->RM_list
{ if ( rmid.Commit( ))
{ deallocate rmid from transaction;};
else {rm_commit(&rm);};};
for each outgoing session in trans->ses_list
{ TM.Commit();
if (! timeout) { free session; }
else {session_failure(&session);};};
Implementation of Commit_Work
if ( trans->RM_list == NULL &&
trans->ses_list == NULL)
{ trans->status = COMMITTED;
save.record_type = commit_complete;
log_insert( save, sizeof(header)+sizeof(record_type));
dequeue and free trans structure;}
(MyProcessP())->trid = NULLTrid;
return TRUE;
};
Data Flow at Commit
Savepoint
Rollback
Prepare
Commit /
Abort
From Application or
Remote Transaction
Manager
Local
Transaction
Manager
Joined
Resource
Managers
Outgoing Sessions
Remote
Transaction
Managers
and Servers
Handling a Session Failure
void session_failure(SECB * session)
{ TransCB * trans = MyTransP();
Boolean timeout = TRUE;
TM_savepoint save;
RMID TM= session->him;
while( timeout) { TM.Commit( );};
free session;
if ( trans->RM_list == NULL &&
trans->ses_list == NULL)
{ trans->status = COMMITTED;
save.record_type = commit_complete;
log_insert( save, sizeof(save));
dequeue and free trans structure;};
exit(); };
Distributed Commit
Ø1
Ø2
Ø1
Ø2
Ø1
Ø2
Ø1
Ø2
root
participant participant
participant
participant
Communications
Manager
TM.Prepare()
TM. Commit()
Ø1
Ø2
participant
Local TM
callbacks
Ø1
Ø2
Coordinator Failure
void coordinator_failure(SECB * session)
tran_status outcome = prepared;
RMID TM= session->him;
while( outcome not in {committing, aborting})
{ outcome=TM.Status_Transaction(MyTrid());};
switch (outcome)
{ aborting: Abort(); break;
committing:Commit( ); break;
}
exit();
};
Savepoint Logic
RM 1
Save Point
Log Record
RM 2
Save Point
Log Record
Transaction
Manager's
Save Point
Log Record
Transaction's Log
Records Increassing LSNs
In the TM´s savepoint record, the LSNs of the
participating resource managers are recored, so
they can be reestablished later on.
Savepoint Implementation
int Save_Work(context * it, Boolean soft)
{TransCB * trans = MyTransP();
TM_savepoint save;
long save_num;
RMTransCB * rm;
SECB * session;
Boolean vote;
if (MyTrid() == NULLTrid) return(0);
save_num = trans->next_save_pt + +;
for each rm in trans->RM_list
if( ! vote = rmid.Savepoint(&rm->save_pt_lsn )))
{ Abort_Work(); return 0;};
Savepoint Implementation
for each session in trans->ses_list
{ vote = TM.Savepoint(save_num);
if (timeout || ! vote ) { Abort_Work();
return 0;};};
trans->save_pt = trans->next_save_pt++;
save.record_type = save;
save.save_pt_num = save_num; save.soft = soft;
copy(save, trans->RM_list);
copy(save, trans->ses_list);
copy(save.it, it);
trans->save_pt_lsn = log_insert( save, sizeof(save));
if (!soft) log_flush(trans->max_lsn, soft);
return save_num; };
The UNDO of Savepoints
void UNDO(LSN lsn)
{TransCB * trans = MyTransP();
TM_savepoint save;
TRID him =MyTrid();
RMID rmid;
RMTransCB * rm;
SECB * session;
log_record_header header;
Boolean vote=TRUE;
log_read(lsn,&header,save,sizeof(save));
trans->save_pt = save.save_pt_num;
The UNDO of Savepoints
for each rm in trans->RM_list
{ if ( rm is in save )
rm->save_pt_lsn = save.RM.save_pt_lsn;
else rm->save_pt_lsn = NULLlsn;.
vote= vote ||
rmid.UNDO_Savepoint(rm->save_pt_lsn);}
for each session in trans->ses_list
vote = vote || TM.UNDO_Savepoint(trans->save_pt);
if ( vote )
{ trans->max_lsn = header.tran_prev_lsn;
trans->save_pt_lsn =
log_insert(save,sizeof(save));}
return;};
Rollback Log Records
Begin
Do
Do
Do
Save
Do
Do
Do
UnDo
Rollback
UnDo
UnDo
UnDo
Do
Do
Do
Compensation log records
System Restart
R E D O T r a n s a c t io n M a n a g e r
C h e c k p o in t C h e c k p o in t
U N D O
C h e c k p o in t
C o m p e n s a t io n L o g R e c o r d s
G e n e r a t e d B y U n d o S c a n
L o g a t R e s t a r t : R E D O s c a n f o r w a r d f r o m la s t c h e c k p o in t
L o g u n c h a n g e d : U N D O s c a n b a c k f r o m e n d o f lo g a lo n g t r a n p r e v ls n
U N D O s c a n g e n e r a t e d c o m p e n s a t io n r e c o r d s ( u n d o lo g g in g )
A t e n d o f U N D O s c a n , c h e c k p o in t a n d m a r k r e s o u r c e m a n a g e r a s u p
I d e n t if y ( R M I D )
R E D O f r o m t h a t R M I D lo w w a t e r ls n R E D O c a llb a c k s
U N D O c a llb a c k s
R e t u r n f r o m I d e n t if y ( )
N o w T r a n s a c t io n M a n a g e r is " u p "
T M ( c h k p _ ls n )
Transaction States at Restart
b e g in
d o
d o
d o
b e g in
d o
c o m m it
c o m p le te
b e g in
d o
d o
r o llb a c k
u n d o
u n d o
a b o r t
c o m p le te
b e g in
d o
d o
c o m m it
b e g in
d o
d o
r o llb a c k
u n d o
u n d o
a b o r t
b e g in
d o
d o
p e r s is te n t s a v e
b e g in
d o
d o
p r e p a r e
C o m p le t e dC o m p le t in g
P e r s is te n t
b e g in
d o
d o
p e r s is te n t s a v e
d o
d o
A c t iv e
F a ilu r e & R e s t a r t R E D O in
p e r s is te n t s to r a g e
R E D O in p e r s is te n t s to r a g e
te ll e a c h r e s o u r c e m a n a g e r
th e n w r ite c o m p le tio n r e c o r d
R E D O in p e r s is te n t s to r a g e
te ll e a c h r e s o u r c e m a n a g e r
to b e p r e p a r e d
R E D O in p e r s is te n t s to r a g e
U N D O to p e r s is te n t s a v e
if n o n e , d o a b o r t lo g ic
Resource Manager at Restart
Identify()
TM_Startup()
UNDO()
REDO()
Commit()
Abort()
He'sup!
Transaction
Manager
Resource
Manager
REDOscan
UNDOscan
resolution
Using Two Checkpoints For Restart
One scan for ALL RMs
REDO
Checkpoint Checkpoint
UNDO
Checkpoint
CompensationLog
Records
GeneratedBy UndoScan
Logat Restart: REDOscanforwardfrom2ndtolast checkpoint
Logunchanged: UNDOscanbackfromendof logalongtran prevlsn
UNDOscangeneratedcompensationrecords (undologging)
At endof UNDOscan, checkpoint andallownewtransactions tobegin
Why Restart Works
A case analysis of the restart state of a transaction’s outcome,
its log record and the state of the page in persistent memory.
Transacti
on
Log
record
Persistent
Page
Why Recovery Works
1 committe
d
volatile old impossible: force-log -
at-commit
2 new impossible:
WAL +force-log-at -
commit
3 durable old REDO makes it new
4 new REDO idempotence
5 aborted volatile old no record at restart
(implicit UNDO).
6 new impossible: WAL
7 durable old REDO then UNDO
8 new REDO idempotence +
UNDO

More Related Content

Similar to 11 tm

Introduction to ATS plugins
Introduction to ATS pluginsIntroduction to ATS plugins
Introduction to ATS pluginsPSUdaemon
 
Code GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersCode GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limiters
Marina Kolpakova
 
How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012
Connor McDonald
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
Gagan Deep
 
1230 Rtf Final
1230 Rtf Final1230 Rtf Final
1230 Rtf Final
luisotaviomedici
 
Transaction Timestamping in Temporal Databases
Transaction Timestamping in Temporal DatabasesTransaction Timestamping in Temporal Databases
Transaction Timestamping in Temporal DatabasesGera Shegalov
 
Contiki introduction I.
Contiki introduction I.Contiki introduction I.
Contiki introduction I.
Dingxin Xu
 
Learning Greenplum Distributed Transaction
Learning Greenplum Distributed TransactionLearning Greenplum Distributed Transaction
Learning Greenplum Distributed Transaction
Chen Wang
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ code
PVS-Studio LLC
 
Sysprog 12
Sysprog 12Sysprog 12
Sysprog 12
Ahmed Mekkawy
 
Show innodb status
Show innodb statusShow innodb status
Show innodb status
justlooks
 
13 tm adv
13 tm adv13 tm adv
13 tm adv
ashish61_scs
 
Lập trình C
Lập trình CLập trình C
Lập trình C
Viet NguyenHoang
 
Eff Plsql
Eff PlsqlEff Plsql
Eff Plsqlafa reg
 
Autonomous transaction
Autonomous transactionAutonomous transaction
Autonomous transaction
Rajeev Rastogi (KRR)
 

Similar to 11 tm (20)

Introduction to ATS plugins
Introduction to ATS pluginsIntroduction to ATS plugins
Introduction to ATS plugins
 
Code GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersCode GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limiters
 
How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
 
Run time
Run timeRun time
Run time
 
Run time
Run timeRun time
Run time
 
1230 Rtf Final
1230 Rtf Final1230 Rtf Final
1230 Rtf Final
 
Transaction Timestamping in Temporal Databases
Transaction Timestamping in Temporal DatabasesTransaction Timestamping in Temporal Databases
Transaction Timestamping in Temporal Databases
 
Contiki introduction I.
Contiki introduction I.Contiki introduction I.
Contiki introduction I.
 
Learning Greenplum Distributed Transaction
Learning Greenplum Distributed TransactionLearning Greenplum Distributed Transaction
Learning Greenplum Distributed Transaction
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ code
 
Sysprog 12
Sysprog 12Sysprog 12
Sysprog 12
 
Sysprog 12
Sysprog 12Sysprog 12
Sysprog 12
 
Show innodb status
Show innodb statusShow innodb status
Show innodb status
 
13 tm adv
13 tm adv13 tm adv
13 tm adv
 
File mngm
File mngmFile mngm
File mngm
 
Lập trình C
Lập trình CLập trình C
Lập trình C
 
Eff Plsql
Eff PlsqlEff Plsql
Eff Plsql
 
Sql transacation
Sql transacationSql transacation
Sql transacation
 
Autonomous transaction
Autonomous transactionAutonomous transaction
Autonomous transaction
 

More from ashish61_scs

7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwo
ashish61_scs
 
Transactions
TransactionsTransactions
Transactions
ashish61_scs
 
22 levine
22 levine22 levine
22 levine
ashish61_scs
 
21 domino mohan-1
21 domino mohan-121 domino mohan-1
21 domino mohan-1
ashish61_scs
 
20 access paths
20 access paths20 access paths
20 access paths
ashish61_scs
 
19 structured files
19 structured files19 structured files
19 structured files
ashish61_scs
 
17 wics99 harkey
17 wics99 harkey17 wics99 harkey
17 wics99 harkey
ashish61_scs
 
16 greg hope_com_wics
16 greg hope_com_wics16 greg hope_com_wics
16 greg hope_com_wics
ashish61_scs
 
15 bufferand records
15 bufferand records15 bufferand records
15 bufferand records
ashish61_scs
 
14 scaleabilty wics
14 scaleabilty wics14 scaleabilty wics
14 scaleabilty wics
ashish61_scs
 
10a log
10a log10a log
10a log
ashish61_scs
 
08 message and_queues_dieter_gawlick
08 message and_queues_dieter_gawlick08 message and_queues_dieter_gawlick
08 message and_queues_dieter_gawlick
ashish61_scs
 
06 07 lock
06 07 lock06 07 lock
06 07 lock
ashish61_scs
 
05 tp mon_orbs
05 tp mon_orbs05 tp mon_orbs
05 tp mon_orbs
ashish61_scs
 
04 transaction models
04 transaction models04 transaction models
04 transaction models
ashish61_scs
 
03 fault model
03 fault model03 fault model
03 fault model
ashish61_scs
 
01 whirlwind tour
01 whirlwind tour01 whirlwind tour
01 whirlwind tour
ashish61_scs
 

More from ashish61_scs (20)

7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwo
 
Transactions
TransactionsTransactions
Transactions
 
22 levine
22 levine22 levine
22 levine
 
21 domino mohan-1
21 domino mohan-121 domino mohan-1
21 domino mohan-1
 
20 access paths
20 access paths20 access paths
20 access paths
 
19 structured files
19 structured files19 structured files
19 structured files
 
17 wics99 harkey
17 wics99 harkey17 wics99 harkey
17 wics99 harkey
 
16 greg hope_com_wics
16 greg hope_com_wics16 greg hope_com_wics
16 greg hope_com_wics
 
15 bufferand records
15 bufferand records15 bufferand records
15 bufferand records
 
14 scaleabilty wics
14 scaleabilty wics14 scaleabilty wics
14 scaleabilty wics
 
10a log
10a log10a log
10a log
 
08 message and_queues_dieter_gawlick
08 message and_queues_dieter_gawlick08 message and_queues_dieter_gawlick
08 message and_queues_dieter_gawlick
 
06 07 lock
06 07 lock06 07 lock
06 07 lock
 
05 tp mon_orbs
05 tp mon_orbs05 tp mon_orbs
05 tp mon_orbs
 
04 transaction models
04 transaction models04 transaction models
04 transaction models
 
03 fault model
03 fault model03 fault model
03 fault model
 
01 whirlwind tour
01 whirlwind tour01 whirlwind tour
01 whirlwind tour
 
Solution5.2012
Solution5.2012Solution5.2012
Solution5.2012
 
Solution6.2012
Solution6.2012Solution6.2012
Solution6.2012
 
Solution7.2012
Solution7.2012Solution7.2012
Solution7.2012
 

Recently uploaded

How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 

Recently uploaded (20)

How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 

11 tm

  • 1. Transaction Manager Software is like entropy. It is difficult to grasp, weighs nothing, and obeys the Second Law of Thermodynamics; i.e., it always increases. Norman Augstine 9:00 11:00 1:30 3:30 7:00 Overview Faults Tolerance T Models Party TP mons Lock Theory Lock Techniq Queues Workflow Log+RM TM CICS & Inet Adv TM Cyberbrick Files &Buffers COM+ Corba Replication Party B-tree Access Paths Groupware Benchmark Mon Tue Wed Thur Fri
  • 2. When Everything Works Normally, no resorce manager fails, and the system is up.The TM receives the following calls: Begin_Work(), Save_Work(), Prepare_Work(), Commit_Work(), Rollback_Work(), Read_ Context().
  • 3. Other “Normal” Calls Normally, no resorce manager fails, and the system is up.The TM receives the following calls: Leave_Transaction(), Resume_Transaction(), Status_Transaction(), Identify(), Join_Work().
  • 4. The TM And Context With each type of savepoint, the TM can record context information for the transaction. Context is provided by a resource manager and can be reestablished when the transaction returns to that savepoint. For the TM, context is only a string of bytes. The “meaning” of context is only understood by the subsystem that created it. The context established by a database system is different from the one provided by a transactional GUI.
  • 5. Transaction Identifiers TRIDs must be created at high rates at each node in a distributed system. TRIDs must be unique in time and space. This is the structure of a TRID: typedef struct {TIMESTAMP BirhtdayOf TM; RMID IDofTM; long LocalSqncNo; char FutureUse[2]; } TRID;
  • 6. name TMid next_transid birthday RM_list tran_list Transaction Manager Anchor name rmid up? low_water_lsn checkpoint_lsn transid status next_savepoint savepoint save point lsn rm_list max_lsn min_lsn lock_list session_list rmid savepoint lsn vote Maintained by Log Manager Maintained by Lock Manager session name polarity remote_TM_name birthday stuff Locks Log Records Resource Manager Entries Resource Managers Joined to This Transaction Transaction Descriptors TM_anchor RMCB TransCB SECB RMTranCB The TM´s Data Structures
  • 7. What the TM Knows About RMs typedef struct { RMCB * NextRMCB; char RMName[BIG]; RMID IDofRM; Boolean RMisUP; LSN OldestLogRecForREDO; LSN CheckpointLSN; } RMCB;
  • 8. What the TM Knows About Transactions typedef struct { TransCB * NextTranCBt; TRID TRIDofTran; tran_status StatusOfTran; long NextSaveptNo; long CurrentSaveptNo; LSN LSNofCurrentSavept; LSN MostRecentLSNofTran; LSN FirstLSNofTran; to be continued ...
  • 9. RMTranCB * RMsAttachedToTran; SECB * SessionsAttachedToTran; pointer LocksHeldByTran; pointer LockTranWaitsFor; long TimeoutForLockWaits; TransCB * ForDeadlockDetector; } TransCB; . . . Knows About Transactions
  • 10. Some Simple Addressing Functions TRID MyTrid(void); Returns transaction identifier of caller’s process. TransCB MyTrans(void); Returns a copy of caller’s transaction CB. TransCB * MyTransP(void); Returns pointer to caller’s transaction CB.
  • 11. Implementation of MyTrid TRID MyTrid(void) /*return curr. TRID of calling process*/ { TransCB * mytranp = MyTransP(); /*pointer to caller’s TA CB */ if ( mytranp != NULL ) return mytranp->trid; /*return his trid if he has one*/ else return NULLTrid;} /*no trid if caller has no control blk*/
  • 12. Savepoints There are seven basic types of savepoints: Begin Save Prepare Rollback Commit Abort Complete
  • 13. The TM Savepoint Log Record typedef struct { SAVE_PT_TYPE RecordType; long SaveptNum; tran_status Status; Boolean SoftOrPersistent; long NumRMs; RMTransCB RM[NumRMs]; long NumSess; SECB Session[NumSess]; context ContextData; } TM_savepoint;
  • 14. Implementation of Begin_Work TRID Begin_Work(context * it, Boolean soft) {TransCB * trans; /*the transaction’s descriptor */ TRID him; /*the newTRID */ TM_savepoint save; /*the savept record*/ if (MyTrid() != NULLTrid) return(NULLTrid); him = TM_anchor.next_trid; /*give nextTRID */ TM_anchor.next_trid.sequence++; (MyProcessP())->trid = him; trans = malloc(sizeof(TransCB)); trans->next = TM_anchor.tran_list; TM_anchor.tran_list = trans; trans->trid = him
  • 15. Implementation of Begin_Work trans->status = ACTIVE; trans->save_pt = 1; trans->next_save_pt = 2; trans->RM_list = trans->lock_list = trans->ses_list = NULL; save.record_type = begin; save.save_pt_num= 1; save.soft = soft; save.num_RM = save.sessions = 0; copy(save.it, it, it.length); trans->save_pt_lsn = log_insert( save, sizeof(save)); if (!soft) log_flush(trans->max_lsn,FALSE); return(him); };
  • 16. Implementation of Commit_Work Boolean Commit_Work(context * it, Boolean lazy) { TransCB * trans = MyTransP(); TM_savepoint save; long save_num Boolean vote; RMTransCB * rm; SECB * session; if (MyTrid() == NULLTrid) return(0); for each rm in trans->RM_list {rm->prepared =rmid.Prepare(&rm->save_pt_lsn)) if (!rm->prepared) { Abort_Work(); return FALSE;};}
  • 17. Implementation of Commit_Work for each outgoing session in trans->ses_list {vote = TM.Prepare(void); if (! vote or timeout) { Abort_Work(); return FALSE;};}; trans->status = PREPARED; save_num = trans->save_pt ++; save.record_type = commit; save.soft = FALSE; save.save_pt_num = save_num; copy(save, trans->RM_list); copy(save, trans->ses_list); copy(save.it, it);
  • 18. Implementation of Commit_Work trans->save_pt_lsn = log_insert( save, sizeof(save)); log_flush(trans->max_lsn, lazy); trans->status = COMMITTING; for each rm in trans->RM_list { if ( rmid.Commit( )) { deallocate rmid from transaction;}; else {rm_commit(&rm);};}; for each outgoing session in trans->ses_list { TM.Commit(); if (! timeout) { free session; } else {session_failure(&session);};};
  • 19. Implementation of Commit_Work if ( trans->RM_list == NULL && trans->ses_list == NULL) { trans->status = COMMITTED; save.record_type = commit_complete; log_insert( save, sizeof(header)+sizeof(record_type)); dequeue and free trans structure;} (MyProcessP())->trid = NULLTrid; return TRUE; };
  • 20. Data Flow at Commit Savepoint Rollback Prepare Commit / Abort From Application or Remote Transaction Manager Local Transaction Manager Joined Resource Managers Outgoing Sessions Remote Transaction Managers and Servers
  • 21. Handling a Session Failure void session_failure(SECB * session) { TransCB * trans = MyTransP(); Boolean timeout = TRUE; TM_savepoint save; RMID TM= session->him; while( timeout) { TM.Commit( );}; free session; if ( trans->RM_list == NULL && trans->ses_list == NULL) { trans->status = COMMITTED; save.record_type = commit_complete; log_insert( save, sizeof(save)); dequeue and free trans structure;}; exit(); };
  • 23. Coordinator Failure void coordinator_failure(SECB * session) tran_status outcome = prepared; RMID TM= session->him; while( outcome not in {committing, aborting}) { outcome=TM.Status_Transaction(MyTrid());}; switch (outcome) { aborting: Abort(); break; committing:Commit( ); break; } exit(); };
  • 24. Savepoint Logic RM 1 Save Point Log Record RM 2 Save Point Log Record Transaction Manager's Save Point Log Record Transaction's Log Records Increassing LSNs In the TM´s savepoint record, the LSNs of the participating resource managers are recored, so they can be reestablished later on.
  • 25. Savepoint Implementation int Save_Work(context * it, Boolean soft) {TransCB * trans = MyTransP(); TM_savepoint save; long save_num; RMTransCB * rm; SECB * session; Boolean vote; if (MyTrid() == NULLTrid) return(0); save_num = trans->next_save_pt + +; for each rm in trans->RM_list if( ! vote = rmid.Savepoint(&rm->save_pt_lsn ))) { Abort_Work(); return 0;};
  • 26. Savepoint Implementation for each session in trans->ses_list { vote = TM.Savepoint(save_num); if (timeout || ! vote ) { Abort_Work(); return 0;};}; trans->save_pt = trans->next_save_pt++; save.record_type = save; save.save_pt_num = save_num; save.soft = soft; copy(save, trans->RM_list); copy(save, trans->ses_list); copy(save.it, it); trans->save_pt_lsn = log_insert( save, sizeof(save)); if (!soft) log_flush(trans->max_lsn, soft); return save_num; };
  • 27. The UNDO of Savepoints void UNDO(LSN lsn) {TransCB * trans = MyTransP(); TM_savepoint save; TRID him =MyTrid(); RMID rmid; RMTransCB * rm; SECB * session; log_record_header header; Boolean vote=TRUE; log_read(lsn,&header,save,sizeof(save)); trans->save_pt = save.save_pt_num;
  • 28. The UNDO of Savepoints for each rm in trans->RM_list { if ( rm is in save ) rm->save_pt_lsn = save.RM.save_pt_lsn; else rm->save_pt_lsn = NULLlsn;. vote= vote || rmid.UNDO_Savepoint(rm->save_pt_lsn);} for each session in trans->ses_list vote = vote || TM.UNDO_Savepoint(trans->save_pt); if ( vote ) { trans->max_lsn = header.tran_prev_lsn; trans->save_pt_lsn = log_insert(save,sizeof(save));} return;};
  • 30. System Restart R E D O T r a n s a c t io n M a n a g e r C h e c k p o in t C h e c k p o in t U N D O C h e c k p o in t C o m p e n s a t io n L o g R e c o r d s G e n e r a t e d B y U n d o S c a n L o g a t R e s t a r t : R E D O s c a n f o r w a r d f r o m la s t c h e c k p o in t L o g u n c h a n g e d : U N D O s c a n b a c k f r o m e n d o f lo g a lo n g t r a n p r e v ls n U N D O s c a n g e n e r a t e d c o m p e n s a t io n r e c o r d s ( u n d o lo g g in g ) A t e n d o f U N D O s c a n , c h e c k p o in t a n d m a r k r e s o u r c e m a n a g e r a s u p I d e n t if y ( R M I D ) R E D O f r o m t h a t R M I D lo w w a t e r ls n R E D O c a llb a c k s U N D O c a llb a c k s R e t u r n f r o m I d e n t if y ( ) N o w T r a n s a c t io n M a n a g e r is " u p " T M ( c h k p _ ls n )
  • 31. Transaction States at Restart b e g in d o d o d o b e g in d o c o m m it c o m p le te b e g in d o d o r o llb a c k u n d o u n d o a b o r t c o m p le te b e g in d o d o c o m m it b e g in d o d o r o llb a c k u n d o u n d o a b o r t b e g in d o d o p e r s is te n t s a v e b e g in d o d o p r e p a r e C o m p le t e dC o m p le t in g P e r s is te n t b e g in d o d o p e r s is te n t s a v e d o d o A c t iv e F a ilu r e & R e s t a r t R E D O in p e r s is te n t s to r a g e R E D O in p e r s is te n t s to r a g e te ll e a c h r e s o u r c e m a n a g e r th e n w r ite c o m p le tio n r e c o r d R E D O in p e r s is te n t s to r a g e te ll e a c h r e s o u r c e m a n a g e r to b e p r e p a r e d R E D O in p e r s is te n t s to r a g e U N D O to p e r s is te n t s a v e if n o n e , d o a b o r t lo g ic
  • 32. Resource Manager at Restart Identify() TM_Startup() UNDO() REDO() Commit() Abort() He'sup! Transaction Manager Resource Manager REDOscan UNDOscan resolution
  • 33. Using Two Checkpoints For Restart One scan for ALL RMs REDO Checkpoint Checkpoint UNDO Checkpoint CompensationLog Records GeneratedBy UndoScan Logat Restart: REDOscanforwardfrom2ndtolast checkpoint Logunchanged: UNDOscanbackfromendof logalongtran prevlsn UNDOscangeneratedcompensationrecords (undologging) At endof UNDOscan, checkpoint andallownewtransactions tobegin
  • 34. Why Restart Works A case analysis of the restart state of a transaction’s outcome, its log record and the state of the page in persistent memory. Transacti on Log record Persistent Page Why Recovery Works 1 committe d volatile old impossible: force-log - at-commit 2 new impossible: WAL +force-log-at - commit 3 durable old REDO makes it new 4 new REDO idempotence 5 aborted volatile old no record at restart (implicit UNDO). 6 new impossible: WAL 7 durable old REDO then UNDO 8 new REDO idempotence + UNDO