发布时间:2022-02-24 文章分类:数据库知识 投稿人:优优 字号: 默认 | | 超大 打印

364

1、redo log操作:保证已提交事务影响的最新数据刷到数据页里。

2、undo log操作:保证未提交事务影响的数据页回滚。

3、写缓冲(change buffer)合并。

4、purge操作。

InnoDB的一种垃圾收集机制,使用单独的后台线程周期性处理索引中标记删除的数据。

实例

/*LookforMLOG_CHECKPOINT.*/
recv_group_scan_log_recs(group,&contiguous_lsn,false);
/*Thefirstscanshouldnothavestoredorappliedanyrecords.*/
ut_ad(recv_sys->n_addrs==0);
ut_ad(!recv_sys->found_corrupt_fs);

if(recv_sys->found_corrupt_log&&!srv_force_recovery){
log_mutex_exit();
return(DB_ERROR);


if(recv_sys->mlog_checkpoint_lsn==0){
if(!srv_read_only_mode
&&group->scanned_lsn!=checkpoint_lsn){
ib::error()<<"Ignoringtheredologduetomissing"
"MLOG_CHECKPOINTbetweenthecheckpoint"
<<checkpoint_lsn<<"andtheend"
<<group->scanned_lsn<<".";
if(srv_force_recovery<SRV_FORCE_NO_LOG_REDO){
log_mutex_exit();
return(DB_ERROR);



group->scanned_lsn=checkpoint_lsn;
rescan=false;
else{
contiguous_lsn=checkpoint_lsn;
rescan=recv_group_scan_log_recs(
group,&contiguous_lsn,false);

if((recv_sys->found_corrupt_log&&!srv_force_recovery)
||recv_sys->found_corrupt_fs){
log_mutex_exit();
return(DB_ERROR);



/*NOTE:wealwaysdoa'recovery'atstartup,butonlyif
thereissomethingwrongwewillprintamessagetothe
useraboutrecovery:*/

if(checkpoint_lsn!=flush_lsn){

if(checkpoint_lsn+SIZE_OF_MLOG_CHECKPOINT<flush_lsn){
ib::warn()<<"Areyousureyouareusingthe"
"rightib_logfilestostartupthedatabase?"
"Logsequencenumberintheib_logfilesis"
<<checkpoint_lsn<<",lessthanthe"
"logsequencenumberinthefirstsystem"
"tablespacefileheader,"<<flush_lsn<<".";


if(!recv_needed_recovery){

ib::info()<<"Thelogsequencenumber"<<flush_lsn
<<"inthesystemtablespacedoesnotmatch"
"thelogsequencenumber"<<checkpoint_lsn
<<"intheib_logfiles!";

if(srv_read_only_mode){
ib::error()<<"Can'tinitiatedatabase"
"recovery,runninginread-only-mode.";
log_mutex_exit();
return(DB_READ_ONLY);


recv_init_crash_recovery();



log_sys->lsn=recv_sys->recovered_lsn;

if(recv_needed_recovery){
err=recv_init_crash_recovery_spaces();

if(err!=DB_SUCCESS){
log_mutex_exit();
return(err);


if(rescan){
contiguous_lsn=checkpoint_lsn;
recv_group_scan_log_recs(group,&contiguous_lsn,true);

if((recv_sys->found_corrupt_log
&&!srv_force_recovery)
||recv_sys->found_corrupt_fs){
log_mutex_exit();
return(DB_ERROR);


else{
ut_ad(!rescan||recv_sys->n_addrs==0);

以上就是mysql InnoDB的崩溃恢复过程,希望对大家有所帮助。更多mysql学习指路:MySQL