查看: 13986|回复: 4

[精华] 请问数据库crash recovery的问题

[复制链接]
论坛徽章:
9
授权会员
日期:2006-06-15 15:15:15会员2007贡献徽章
日期:2007-09-26 18:42:10ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44铁扇公主
日期:2007-10-26 16:08:48生肖徽章2007版:鼠
日期:2008-01-02 17:35:532008新春纪念徽章
日期:2008-02-13 12:43:03奥运会纪念徽章:田径
日期:2008-08-19 09:59:402010广州亚运会纪念徽章:高尔夫球
日期:2010-11-22 15:29:49优秀写手
日期:2014-02-28 06:00:13
跳转到指定楼层
1#
发表于 2006-5-9 11:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
请问一下为什么db2 在crash recovery要先前滚,然后在回滚.
论坛徽章:
9
授权会员
日期:2006-06-15 15:15:15会员2007贡献徽章
日期:2007-09-26 18:42:10ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44铁扇公主
日期:2007-10-26 16:08:48生肖徽章2007版:鼠
日期:2008-01-02 17:35:532008新春纪念徽章
日期:2008-02-13 12:43:03奥运会纪念徽章:田径
日期:2008-08-19 09:59:402010广州亚运会纪念徽章:高尔夫球
日期:2010-11-22 15:29:49优秀写手
日期:2014-02-28 06:00:13
2#
 楼主| 发表于 2006-5-9 16:22 | 只看该作者
怎么没有人回答我啊

使用道具 举报

回复
招聘 : c/c++研发
论坛徽章:
45
技术图书徽章
日期:2014-03-10 14:09:192012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-01-04 11:51:22ITPUB十周年纪念徽章
日期:2011-11-01 16:21:15现任管理团队成员
日期:2011-05-07 01:45:082011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:50
3#
发表于 2006-5-10 05:46 | 只看该作者
let me take over this problem

before understanding forward phase and backward phase, we need to understand the background of recovery.

there are two LSN are important: MinBuffLSN and LowTranLSN:
minbufflsn
LSN of the log record that is the oldest change made to a data page that is still in the buffer pool (ie. the change has not been written to disk yet, and if the database crash now, the change, and any subsequent changes on that page, will be lost).  It moves up when that page is written to disk, either by page cleaner or by agent when the bufferpool memory need to be used to store another data page (ie. page stealing).

lowtranlsn
LSN of the first log record written by the oldest uncommitted transaction.  It only moves up when the oldest transaction commits/aborts.  Oldest is is ordered by the time transactions write their first log records, not the UOW start time reported by database monitor.

----(Log Control Data on Disk)-----------Oldest Changed Page (minbufflsn)------Oldest Uncommitted Transaction(lowtranlsn)------CRASH!!!!!------->

note: lowtranlsn may siting before minbufflsn

at the time of a failure, such as a loss of power, there may be a number of changes to the database which have updated data in the bufferpool. This data may:
1) not have been written to disk and not have been committed.
2) note have been written to disk but have been commiteted.
3) have been written to disk and have been commiteted.

when db2 is restarted, the db2 log files are used to perform a crash recovery of the database. the crash recovery ensures that the database is brought back to a consistent state. All committed transactions are applied to the database, and all uncommitted transaction are not applied to the database.

By taking the lower of lowtranlsn and minbufflsn, db2 can determine where to start processing (by LSN) with in the log files after crash. all records before this point have been commiteted (log record written) and have had their data pages written to disk aslo, and will not need to be processed. db2 will then read all records from this point forward in the log files and reapply each change.

this is refrerred to as the "REDO" phase of recovery. (forward phase)

once all of the log records have been reapplied, all uncommitted transactions are rolled back. this is referred as the "UNDO" phase of recovery. (backward phase)

at this point the database is consistent: all transactions that completed before crash have been redone, and all active transactions have been rolled back.

i hope this can help you a bit
good luck

使用道具 举报

回复
论坛徽章:
9
授权会员
日期:2006-06-15 15:15:15会员2007贡献徽章
日期:2007-09-26 18:42:10ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44铁扇公主
日期:2007-10-26 16:08:48生肖徽章2007版:鼠
日期:2008-01-02 17:35:532008新春纪念徽章
日期:2008-02-13 12:43:03奥运会纪念徽章:田径
日期:2008-08-19 09:59:402010广州亚运会纪念徽章:高尔夫球
日期:2010-11-22 15:29:49优秀写手
日期:2014-02-28 06:00:13
4#
 楼主| 发表于 2006-5-10 08:54 | 只看该作者
thanks a lot!!

使用道具 举报

回复
论坛徽章:
111
ITPUB9周年纪念徽章
日期:2010-10-08 09:34:03马上有房
日期:2014-02-18 16:42:02马上有车
日期:2014-03-20 10:09:22马上有钱
日期:2014-03-20 15:53:11马上有车
日期:2014-03-20 16:13:24马上有房
日期:2014-03-20 16:14:11马上有钱
日期:2014-03-20 16:14:11马上有对象
日期:2014-03-20 16:14:11马上加薪
日期:2014-03-20 16:14:11技术图书徽章
日期:2014-03-27 09:30:56
5#
发表于 2014-2-27 06:57 | 只看该作者
wangzhonnew 发表于 2006-5-10 05:46
let me take over this problem

before understanding forward phase and backward phase, we need t ...

经典...........

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表