数据库课后答案.pdf
CHAPTER16
RecoverySystem
PracticeExercises
16.1Explainwhylogrecordsfortransactionsontheundo-listmustbepro-
cessedinreverseorder,whereasredoisperformedinaforwarddirection.
Answer:Withinasingletransactioninundo-list,supposeadataitem
isupdatedmorethanonce,sayfrom1to2,andthenfrom2to3.Ifthe
undologrecordsareprocessedinforwardorder,thefinalvalueofthe
dataitemwouldbeincorrectlysetto2,whereasbyprocessingthemin
reverseorder,thevalueissetto1.Thesamelogicalsoholdsfordataitems
updatedbymorethanonetransactiononundo-list.
Usingthesameexampleasabove,butassumingthetransactioncommit-
ted,itiseasytoseethatifredoprocessingprocessestherecordsinforward
order,thefinalvalueissetcorrectlyto3,butifdoneinreverseorder,the
finalvaluewouldbesetincorrectlyto2.
16.2Explainthepurposeofthecheckpointmechanism.Howoftenshould
checkpointsbeperformed?Howdoesthefrequencyofcheckpointsaffect:
•Systemperformancewhennofailureoccurs?
•Thetimeittakestorecoverfromasystemcrash?
•Thetimeittakestorecoverfromamedia(disk)failure?
Answer:Checkpointingisdonewithlog-basedrecoveryschemestore-
ducethetimerequiredforrecoveryash.Ifthereisnocheckpoint-
ing,thentheentirelogmustbesearchedash,andalltransactions
undone/redonefromthelog.Ifcheckpointinghadbeenperformed,then
mostofth