Innodb redo log之flush list
来源:互联网 发布:python 爬虫 抓取文字 编辑:程序博客网 时间:2024/05/05 04:41
Innodb redo log之flush list
Innodb维护一个flush list链表,保存所有的脏页。脏页按照第一次修改的时间顺序进行排序。
在mtr_commit中将redo从mtr->log中刷到redo log buffer中后,产生LSN后,通过判断LSN决定是否将该页放到flush list中。
mtr_commit
mtr_log_reserve_and_write
mtr->end_lsn = log_reserve_and_write_fast(first_data, len, &mtr->start_lsn);
if (mtr->end_lsn) {
mtr_add_dirtied_pages_to_flush_list(mtr);
return;
}
函数解析:
mtr_add_dirtied_pages_to_flush_list(mtr_t* mtr) /*!< in/out: mtr */
1、 通过log_sys->log_flush_order_mutex确保每次只有一个脏页顺序插入flush list
2、 如果没有脏页,不需要申请log_sys->log_flush_order_mutex
3、 通过mtr_memo_note_modifications将脏页插入到flush list
if (mtr->made_dirty) {
log_flush_order_mutex_enter();
}
log_release();//释放log_sys->mutex,让其他可以进行log操作
if (mtr->modifications) {
mtr_memo_note_modifications(mtr);//见下面函数解析
}
//插入flush list后释放log_sys->log_flush_order_mutex
if (mtr->made_dirty) {
log_flush_order_mutex_exit();
}
mtr_memo_note_modifications
for (const dyn_block_t* block = dyn_array_get_last_block(&mtr->memo); block; block = dyn_array_get_prev_block(&mtr->memo, block)) {
const mtr_memo_slot_t*start = reinterpret_cast<mtr_memo_slot_t*>(dyn_block_get_data(block));
mtr_memo_slot_t*slot= reinterpret_cast<mtr_memo_slot_t*>(dyn_block_get_data(block) + dyn_block_get_used(block));
while (slot-- != start) {
if (slot->object != NULL) {
mtr_memo_slot_note_modification(mtr, slot);
}
}
}
这部分待研究。。。
mtr_memo_slot_note_modification(mtr, slot);
|--buf_flush_note_modification(block, mtr);
|--block->page.newest_modification = mtr->end_lsn;
|3--if (!block->page.oldest_modification) {
buf_flush_insert_into_flush_list(buf_pool, block, mtr->start_lsn);
} else {
do nothing;
}
buf_flush_insert_into_flush_list(buf_pool, block, mtr->start_lsn);//lsn=mtr->start_lsn
block->page.oldest_modification = lsn;
UT_LIST_ADD_FIRST(list, buf_pool->flush_list, &block->page);
1、page的内存结构对象有newest_modification和oldest_modification
2、page.newest_modification = mtr->end_lsn;page.oldest_modification=mtr->start_lsn
3、根据oldest_modification将脏页插入到flush list头部
4、!block->page.oldest_modification表示第一次修改该页。只有第一次修改时才插入到flush list。否则do nothing
Innodb维护一个flush list链表,保存所有的脏页。脏页按照第一次修改的时间顺序进行排序。
在mtr_commit中将redo从mtr->log中刷到redo log buffer中后,产生LSN后,通过判断LSN决定是否将该页放到flush list中。
mtr_commit
mtr_log_reserve_and_write
mtr->end_lsn = log_reserve_and_write_fast(first_data, len, &mtr->start_lsn);
if (mtr->end_lsn) {
mtr_add_dirtied_pages_to_flush_list(mtr);
return;
}
函数解析:
mtr_add_dirtied_pages_to_flush_list(mtr_t* mtr) /*!< in/out: mtr */
1、 通过log_sys->log_flush_order_mutex确保每次只有一个脏页顺序插入flush list
2、 如果没有脏页,不需要申请log_sys->log_flush_order_mutex
3、 通过mtr_memo_note_modifications将脏页插入到flush list
if (mtr->made_dirty) {
log_flush_order_mutex_enter();
}
log_release();//释放log_sys->mutex,让其他可以进行log操作
if (mtr->modifications) {
mtr_memo_note_modifications(mtr);//见下面函数解析
}
//插入flush list后释放log_sys->log_flush_order_mutex
if (mtr->made_dirty) {
log_flush_order_mutex_exit();
}
mtr_memo_note_modifications
for (const dyn_block_t* block = dyn_array_get_last_block(&mtr->memo); block; block = dyn_array_get_prev_block(&mtr->memo, block)) {
const mtr_memo_slot_t*start = reinterpret_cast<mtr_memo_slot_t*>(dyn_block_get_data(block));
mtr_memo_slot_t*slot= reinterpret_cast<mtr_memo_slot_t*>(dyn_block_get_data(block) + dyn_block_get_used(block));
while (slot-- != start) {
if (slot->object != NULL) {
mtr_memo_slot_note_modification(mtr, slot);
}
}
}
这部分待研究。。。
mtr_memo_slot_note_modification(mtr, slot);
|--buf_flush_note_modification(block, mtr);
|--block->page.newest_modification = mtr->end_lsn;
|3--if (!block->page.oldest_modification) {
buf_flush_insert_into_flush_list(buf_pool, block, mtr->start_lsn);
} else {
do nothing;
}
buf_flush_insert_into_flush_list(buf_pool, block, mtr->start_lsn);//lsn=mtr->start_lsn
block->page.oldest_modification = lsn;
UT_LIST_ADD_FIRST(list, buf_pool->flush_list, &block->page);
1、page的内存结构对象有newest_modification和oldest_modification
2、page.newest_modification = mtr->end_lsn;page.oldest_modification=mtr->start_lsn
3、根据oldest_modification将脏页插入到flush list头部
4、!block->page.oldest_modification表示第一次修改该页。只有第一次修改时才插入到flush list。否则do nothing
0 0
- Innodb redo log之flush list
- InnoDB之Dirty page、Redo log
- mysql innodb redo log
- Innodb redo log archiving
- MySQL系列:innodb源码分析之redo log恢复
- MySQL系列:innodb源码分析之redo log恢复
- InnoDB的Redo Undo Log
- 14.2.4 InnoDB Redo Log
- 14.2.3 InnoDB Redo Log
- 14.2.3 InnoDB Redo Log
- innodb lru list、free list、flush list
- MySQL crash:InnoDB redo log error
- mysql innodb 刷数据和redo log
- Innodb redo log 与 binlog 的区别
- MySQL数据库InnoDB Undo redo Log
- InnoDB Redo Flush及脏页刷新机制深入分析
- InnoDB Redo Flush及脏页刷新机制深入分析
- innodb buffer pool管理--flush list
- linux常用命令
- 图——图的遍历——深度优先遍历DFS
- XmlJavaTypeAdapter
- 24位BMP图像RGB与YUV转换
- HDU 5310 题意 c语言代码
- Innodb redo log之flush list
- VIM学习笔记
- CentOS6.2使用yum安装LAMP及phpMyadmin
- 【Leetcode】Minimum Depth of Binary Tree
- 81.Oracle数据库SQL开发之 修改表内存——使用UPDATE语句
- 项目实战 网易彩票3
- springMVC与shiro整合与自定义验证码用户类型类
- QQ面板切换效果(web版)【实例】
- 82.Oracle数据库SQL开发之 修改表内存——RETURNING子句