自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(51)
  • 资源 (2)
  • 收藏
  • 关注

原创 mysql源码-innodb mvcc原理与源码解析

原理图解说1 在innodb中,保存了一个全局事务链表,记录了活跃事务,即还未完成的事务2 t2 时刻活跃的事务id为104~111,其中107已经完成3 在t2时刻,读事务A查询数据,在查询范围内的事务id为100~114,需要判断事务id100~114那些是否可 见的首先,先把当前活跃事务复制到自己空间,创建自己的readview,活跃的事务id有104~111,不包含107,107已经完成。最后,读取数据,读到事务id100~103,通过判断事务id<m_up_limit_id(1.

2021-01-01 13:25:07 519

原创 mysql8.0 redo日志无锁优化-架构图

流程简要说明1 应用线程并发从自己的mtr内存空间写入到log buffer,通过linkbuf 和预分配内存方式,实现并发下,此处不详细写应用线程在commit提交时阻塞等待,根据 innodb_flush_log_at_trx_commit 的值 等待不通过的触发信号2 log_writer 线程通过遍历linkbuf ,得到连续的内存的,即从上次写入的最小lsn到一直连续的最大lsn,即图中用大括号包含的部分,前面白色的方块表示后面的lsn已经不连续,说明还有没有写完的内存3 log_wri.

2020-12-08 17:23:38 271

原创 mysql8.0源码解析 InnoDB redo log日志 写 write ahead 巧用pageCache实现高效写

pageCache背景当往磁盘上写文件时,如果文件内容还没有被缓存或者被置换出去了,在内存里不存在对应的page cache,则需要先将对应page的内容从磁盘上读到内存里,修改要写入的数据,然后在将整个page写回到磁盘;在这种情况下,会有一次额外的读IO开销,IO的性能会有一定的损失。mysql的整体性能高度依赖redo log写IO的性能,InnoDB对对redo日志的写做了优化,redo log写入是追加写的模式(append write),引入了write ahead方法。巧用一个8192字节

2020-12-04 20:52:23 782

原创 mysql源码片段 innodb启动checkpoint flush脏页 lsn几个关键点检查过程整理

mysql 如何判断进程是正常停止(shutdown停止)还是异常停止(crash 或者 被kill 或者主机宕机导致的进程停止)呢?是如何判断的呢

2020-11-29 11:59:31 1622 2

原创 mysql5.7 group commit 关于binlog文件切换(rotate)的笔记

@[TOC](mysql5.7 group commit 关于binlog文件切换(rotate)的笔记)在组提交的过程进入orderred_commit 函数 对binlog文件切换(rotate)的记录有事务提交完成此函数判断增加with_xid 确定为true,在写binglog 中写入 binary_log::XID_EVENTint binlog_cache_data::write_event(THD *thd, Log_event *ev)if (ev->get_type_cod

2020-05-13 17:59:24 314

原创 Semi 流程异常分析

正常流程1 在图中(1) 完成binlog 写入文件的pageCache2 在图中(2) 完成binlog sync 的磁盘binlog 文件3 在图中(3) 完成binlog 的异步发送,把binlog 发送到备库(等待sync完成,更新binlog updte pos,sync_binlog=1的流程)4 在图中(4) 完成binlog 发送完成的确认信息(此处可以完全确认binlog已经发送到从库)5 在图中(5) 用户线程被激活,完成第三阶段的事务提交异常流程分析1 在图中.

2021-07-15 11:53:13 195

原创 mysql 半同步 semi-sync 源码整理

用户线程事务提交MYSQL_BIN_LOG::ordered_commit 一阶段 flush binlog 后,执行semi插件 调用repl_semi_report_binlog_update file_name_ptr: binlog 文件名 flush_end_pos: flush binlog时的大小 -> if (RUN_HOOK(binlog_storage, after_flush,(thd, file_name_ptr, flush_end_pos)))

2021-07-10 15:56:56 270

原创 semi流程

Semi-sync 流程概况Semi-sync 利用原有的异步模式,通过嵌入等待从库ack binlog pos的模式,实现事务同步等待,保证事务提交前完成binlog redo 发送到slave节点问题After_sync 确认为ack应答为group commit 阶段的第三阶段开始,如果在收到应答之前宕机,会出现主从不一致的情况。1 sync_binlog 为1 时 发送binlog的时机为binlog sync 之后,在宕机的瞬间无法确定从库是否收到binlog1>从库未收到bi

2021-07-07 23:52:03 417

原创 数据更新 mysql redo 磁盘空间不足时

#0 log_checkpoint (sync=false, write_always=false) at /data/mysql-boost-5.7.32/mysql-5.7.32/storage/innobase/log/log0log.cc:1786#1 0x000000000196c74a in log_checkpoint_margin () at /data/mysql-boost-5.7.32/mysql-5.7.32/storage/innobase/log/log0log.cc:19

2021-06-21 11:41:38 202

原创 mysql非正常停止(宕机、crash) binlog的恢复过程

通过binlog 回滚 已sync的redo日志 #0 trx_undo_set_state_at_prepare (trx=0x7fffed2d5478, undo=0xfad8cd8, rollback=true, mtr=0x7fffffffc640) at /mysql-boost-5.7.32/mysql-5.7.32/storage/innobase/trx/trx0undo.cc:1904#1 0x0000000001ab981f in trx_rollback_low (trx=0x

2021-05-24 10:28:20 254

原创 mysql 数据更新 检查 redo日志空间是否充足log_free_check

#0 0x00007fda905cfe9d in nanosleep () from /lib64/libpthread.so.0#1 0x0000000000f77ce0 in os_thread_sleep (tm=tm@entry=10000) at /root/mysql5.7.32/mysql-5.7.32/storage/innobase/os/os0thread.cc:287#2 0x00000000010d166d in buf_flush_wait_flushed (new_ol

2021-05-11 18:06:20 336

原创 fsync操作

/*update 需要刷磁盘的操作*/#0 os_file_fsync_posix (file=20) at /data/mysql-boost-5.7.32/mysql-5.7.32/storage/innobase/os/os0file.cc:3081#1 0x000000000198c562 in os_file_flush_func (file=20) at /data/mysql-boost-5.7.32/mysql-5.7.32/storage/innobase/os/os0file.c

2021-04-28 19:23:36 3370 2

原创 binlog 切换时,调用流程

/* 关闭文件前写入数据,写入binlog的数据*/(gdb) where#0 Rotate_log_event::write (this=0x7fff92fa7d50, file=0x2d114e8 <mysql_bin_log+840>) at /root/mysql-boost-5.7.32/mysql-5.7.32/sql/log_event.cc:6625#1 0x00000000017eb6ce in MYSQL_BIN_LOG::new_file_impl (this=0

2021-04-27 14:01:31 145

原创 ha_flush_logs 在server层调用流程

#0 log_write_up_to (lsn=13521449, flush_to_disk=true) at /root/mysql-boost-5.7.32/mysql-5.7.32/storage/innobase/log/log0log.cc:1227#1 0x00000000019701a0 in log_buffer_flush_to_disk (sync=true) at /root/mysql-boost-5.7.32/mysql-5.7.32/storage/innobase/lo

2021-04-27 11:26:36 128

原创 mysql收到tcp连接请求的过程

/*在请求的情况下,mysql 监听在此处*/0 Mysqld_socket_listener::listen_for_connection_event (this=0x6888a60) at sql/conn_handler/socket_connection.cc:866#1 0x0000000000ec0151 in Connection_acceptor<Mysqld_socket_listener>::connection_event_loop (this=0x6884e40

2021-03-23 15:33:15 154

原创 mysql5.7创建thd 的过程

/*一个tcp连接创建爱你thd的过程*/#0 THD::THD (this=0x7fff48000bc0, enable_plugins=true) at sql/sql_class.cc:1206#1 0x0000000001785ddd in Channel_info::create_thd (this=0x6966540) at sql/conn_handler/channel_info.cc:39#2 0x0000000001677a3f in Channel_info_local

2021-03-23 11:23:17 302

原创 mysql5.7 事务提交innodb记录binlog的文件名及偏移

#0 trx_sys_update_mysql_binlog_offset (file_name=0x2d23222 <mysql_bin_log+130> "mysql-bin.000026", offset=226, field=15384, mtr=0x7fff92fa7a80) at storage/innobase/trx/trx0sys.cc:225#1 0x0000000001af4989 in trx_write_serialisation_history (trx=0x7

2021-03-19 16:30:48 204 1

原创 mysql5.7异常崩溃后binlog的恢复过程

/*异常恢复时对undo日志的修改*/#0 trx_write_serialisation_history (trx=0x7fffd78cf480, mtr=0x7fffffffc6c0) at storage/innobase/trx/trx0trx.cc:1583#1 0x0000000001af5bbb in trx_commit_low (trx=0x7fffd78cf480, mtr=0x7fffffffc6c0) at storage/innobase/trx/trx0trx.cc:21

2021-03-19 15:33:24 132

原创 mysql5.7 将undo log加入到history list上

/*================ UNDO LOG HISTORY LIST =============================*/ 318| 319| /********************************************************************//** 320| Adds the update undo log as the first log in the history list. Removes the 321| update un.

2021-03-19 15:18:52 131

原创 mysql5.7undo 日志purge 流程

/*purge 线程清理undo 日志*/#0 trx_purge_remove_log_hdr (rseg_hdr=0x7fffcf908026 "\377\377\377\376", log_hdr=0x7fffa5878199 "", mtr=0x7fff8a727700) at storage/innobase/trx/trx0purge.cc:423#1 0x0000000001acf89d in trx_purge_truncate_rseg_history (rseg=0x7b690

2021-03-19 14:55:01 333

原创 mysql update 写undo日志的 加锁

/* If object is temporary, disable REDO logging that is done to track1922| changes done to UNDO logs. This is feasible given that temporary tables1923| are not restored on restart. */1924| mtr_start(&mtr);1925+> di

2021-03-18 17:56:48 156

原创 mysql5.7 在写数据大于cache大小时处理流程

/*此函数确定当前的cache是否已经写了临时文件 如果已经写过临时文件了,在把cache中的数据全部写入磁盘,cache清空,等待下次读取时用*/7812| if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0)) 7813| { 7814| DBUG_EXECUTE_IF("simulate_tmpdir_partition_full", 7815| { 7816|

2021-03-12 20:47:35 108

原创 mysql5.7insert 执行一条语句,在提交前各个阶段生成binlog的流程

#0 my_b_safe_write (info=0x7ff48400c020, Buffer=0x7fffec035e1f "\021RHK`\036@\001", Count=1) at mysys/mf_iocache.c:1447#1 0x00000000017a7765 in Log_event::wrapper_my_b_safe_write (this=0x7ff48400c3c0, file=0x7ff48400c020, buf=0x7fffec035e1f "\021RHK`\03

2021-03-12 20:03:41 221

原创 mysql5.7 在启动时创建pageCache write head 过程

#0 MYSQL_BIN_LOG::open (this=0x2d9af00 <mysql_bin_log>, log_file_key=2, log_name=0x2f172f0 "mysql-bin", new_name=0x0) at sql/binlog.cc:3809#1 0x0000000001809938 in MYSQL_BIN_LOG::open_binlog (this=0x2d9af00 <mysql_bin_log>, log_name=0x2f172f

2021-03-10 11:33:08 108

原创 mysql 新连接接入创建binlog缓存的过程

#0 init_io_cache (info=0x7fffec492650, file=-1, cachesize=32768, type=WRITE_CACHE, seek_offset=0, use_async_io=0 '\000', cache_myflags=20) at mysys/mf_iocache.c:299#1 0x0000000001883244 in open_cached_file (cache=0x7fffec492650, dir=0x2e49ba0 "/data/kin

2021-03-09 20:24:33 114

原创 mysql 一个事务中形成binlog大于当前线程缓存大小的执行流程

(gdb) where#0 _my_b_write (info=0x7ffe6c24d910, Buffer=0x7ffe6c0b1a00 "", Count=51358) at /root/mysql-5.7.27_edit_malloc_log/mysys/mf_iocache.c:1313#1 0x000000000188764c in my_b_safe_write (info=0x7ffe6c24d910, Buffer=0x7ffe6c0b1a00 "", Count=51358) at

2021-03-09 10:47:13 133

原创 mysql insert json 大数据写redo日志的流程

0 mlog_write_string (ptr=0x7fff8cedc02e "", str=0x7ffe781df860 "", len=16330, mtr=0x7fffec491790) at storage/innobase/mtr/mtr0log.cc:322#1 0x0000000001b66943 in btr_store_big_rec_extern_fields (pcur=0x7fffec491df0, upd=0x0, offsets=0x7fffec4924c0, big_r

2021-03-05 10:55:48 167 1

原创 mysql 写redo日志大字段的处理方式

#0 mtr_t::Command::prepare_write (this=0x7fffec491140) at storage/innobase/mtr/mtr0mtr.cc:825#1 0x00000000019b14e0 in mtr_t::Command::execute (this=0x7fffec491140) at storage/innobase/mtr/mtr0mtr.cc:958#2 0x00000000019b0016 in mtr_t::commit (this=0x7f

2021-03-04 21:01:35 238 1

原创 mysql启动时通过binlog index 文件查找最新的binlog文件

do 8459| { 8460| strmake(log_name, log_info.log_file_name, sizeof(log_name)-1); 8461+> } while (!(error= find_next_log(&log_info, true/*need_lock_index=true*/)));/*启动时*/#0 MYSQL_BIN_LOG::find_next_log (this=0x2d9af00 &...

2021-03-02 21:18:26 697

原创 mysql 写binlog 大字段流程

/*当写binlog大于8192既IO_CACHE 的大小时,不写IO_CACHE 直接写入文件pageCache 当IO_CACHE 剩余空间无法写入当前binlog时,则先把IO_CACHE 里的内容写入直接写入文件pageCache */#0 _my_b_write (info=0x2d9b248 <mysql_bin_log+840>, Buffer=0x7ffe801f7487 "p", Count=51372) at /mysys/mf_iocache.c:1311#1

2021-03-02 10:48:18 164

原创 mysql commit提交写binlog的流程

/*mysql commit提交写binlog的流程*/#0 inline_mysql_file_write (src_file=0x2249420 "/mysys/mf_iocache.c", src_line=1566, file=35, buffer=0xfbf4d60 "/\277<`!@\001", count=264, flags=52) at /include/mysql/psi/mysql_file.h:1138#1 0x0000000001887b95 in my_b_flu

2021-03-01 19:41:30 617

原创 mysql redo日志类型

文件 mtr0types.h/** @name Log item typesThe log items are declared 'byte' so that the compiler can warn if valand type parameters are switched in a call to mlog_write_ulint. NOTE!For 1 - 8 bytes, the flag value must give the length also! @{ */enum mlog_

2021-03-01 11:00:18 138

原创 mysql更新事务创建trx->id 的流程

#0 trx_sys_get_new_trx_id () at storage/innobase/include/trx0sys.ic:437#1 0x0000000001b183a7 in trx_start_low (trx=0x7fffed7ce170, read_write=true) at storage/innobase/trx/trx0trx.cc:1407#2 0x0000000001b1c1ca in trx_start_if_not_started_xa_low (trx=0x

2021-02-26 17:42:29 436

原创 mysql5.7 import 对记录的操作

/** Update the BLOB refrences and write UNDO log entries for1773| rows that can't be purged optimistically.1774| @param block block to update1775| @retval DB_SUCCESS or error code */1776| dberr_t1777| PageConverter::update_records(1778| buf_b

2021-02-26 15:03:50 91

原创 mysql5.7.27import 数据文件流程

/*遍历ibd文件的分支*/#0 FetchIndexRootPages::operator() (this=0x7fffec4d7020, offset=0, block=0x7ffe90987958) at storage/innobase/row/row0import.cc:697#1 0x0000000001c1e577 in fil_iterate (iter=..., block=0x7ffe90987958, callback=...) at storage/innobase/fil/

2021-02-26 11:51:40 132

原创 mysql5.7.27 binglog 写入流程及大字段写入流程

2021-02-19 10:54:16 103

原创 mysql5.7 dml 语句记录binlog 与redo日志

//写redo日志,和 生成binlog的代码 int handler::ha_write_row(uchar *buf){ int error; Log_func *log_func= Write_rows_log_event::binlog_row_logging_function; DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || m_lock_type == F_WRLCK); DBUG

2021-02-19 10:34:01 149

原创 show global status 申请2M(根据tmp_table_size 参数设置有关)内存的过程

#0 my_malloc (key=297, size=2094080, flags=16) at mysys/my_malloc.c:57#1 0x00000000018e230d in hp_get_new_block (block=0x7ff4c40a7730, alloc_length=0x7fffec215c28) at storage/heap/hp_block.c:80#2 0x00000000018e19b2 in next_free_record_pos (info=0x7ff4

2021-01-26 15:25:03 68

原创 buffer_pool 初始化,malloc 内存,每个page 创建os_event_create ,申请内存的过程

buffer_pool 初始化,malloc 内存,每个page 创建os_event_create ,申请内存的过程#0 ut_allocator::allocate_trace (this=0x7fffec214338, size=144, file=0x2288888 “storage/innobase/os/os0event.cc”, pfx=0x7ff4c496b900) at storage/innobase/include/ut0new.h:728#1 0x00000000019112

2021-01-26 15:22:06 151

原创 mysql set global 环境变量设置

客户端执行 set global global_sleep_time=100;调用堆栈信息#0 set_tmp_open_sleep (self=0x2d8e5c0 <Sys_tmp_sleep_time>, thd=0x7ff4c4000b70, type=OPT_GLOBAL) at /root/mysql-5.7.27_edit_malloc_log/sql/sys_vars.cc:3916#1 0x00000000014a869f in sys_var::update (thi

2021-01-20 18:18:36 3650

nginx slab内存管理精简源码及注释

通过把nginx slab的精简,把需要的头文件单独整理出来,增加了main方法,可以单独运行,代码包含了大量的中文注释,方便了了解和学习slab的运行机制 int main(int argc, char **argv) { ngx_log_t log; ngx_shm_t shm; ngx_slab_pool_t *shpool; char *ssl_session[10]; int n; ngx_pid = ngx_getpid(); memset(&log;, 0, sizeof(ngx_log_t)); memset(&shm;, 0, sizeof(ngx_shm_t)); shm.size = 512000; ngx_pagesize_shift = 0; ngx_pagesize = getpagesize(); for (n = ngx_pagesize; n >>= 1; ngx_pagesize_shift++) { /* void */ } printf("--%d\n", 1 << ngx_pagesize_shift); if (ngx_shm_alloc(&shm;) != NGX_OK) { return 1; } if (ngx_init_zone_pool(&log;, &shm;)) { return 1; } shpool = (ngx_slab_pool_t *) shm.addr; ssl_session[0] = (char *) ngx_slab_alloc_locked(shpool, 12); ssl_session[0] = (char *) ngx_slab_calloc(shpool, 56); ssl_session[1] = (char *) ngx_slab_alloc_locked(shpool, 14); ssl_session[2] = (char *) ngx_slab_alloc_locked(shpool, 11); ngx_slab_free(shpool, ssl_session[2]); ngx_slab_free(shpool, ssl_session[0]); ssl_session[2] = (char *) ngx_slab_alloc_locked(shpool, 65); return 0; } nginx的slab的内存管理方式,这种方式的内存管理在nginx中,主要是与nginx 的共享内存协同使用的。nginx的slab管理与linux的slab管理相同的地方在于均是利用了内存 的缓存与对齐机制,slab内存管理中一些设计相当巧妙的地方,也有一些地方个人感觉设计 不是很完美,或许是作为nginx设计综合考虑的结果。 nginx slab实现中的一大特色就是大量的位操作,这部分操作很多是与slot分级数组相关的。 为方便描述下面做一些说明: 1.将整个slab的管理结构称slab pool. 2.将slab pool前部的ngx_slab_pool_t结构称slab header. 3.将管理内存分级的ngx_slab_page_t结构称slot分级数组. 4.将管理page页使用的ngx_slab_page_t结构称slab page管理结构. 5.将具体page页的存放位置称pages数组. 6.将把page分成的各个小块称为chunk. 7.将标记chunk使用的位图结构称为bitmap.

2019-05-18

TCP.IP协议的首部.docx

高清文字版 1. 网络专家W. Richard Stevens的传世之作。 2. TCP/IP领域的经典。 3. 任何TCP/IP领域技术人员不可或缺的案头书。 《TCP/IP详解》是已故网络专家、技术作家W. Richard Stevens的传世之作,内容详尽,被誉为TCP/IP领域的不朽名著。 本书是《TCP/IP详解》三卷本的第1卷,主要讲述TCP/IP协议,并结合大量实例讲述TCP/IP协议族的定义原因,以及在各种不同操作系统中的应用及工作方式。本书的显著特点是,不仅仅描述协议及其功能,而且用一种流行的诊断工具动态地监视协议,通过观察协议在不同环境下的运行情况,读者可以轻松掌握TCP/IP的知识。本书中的每一个示例都是在实际网络中运行过的,而且几乎每章都提供精选的习题,并在附录中提供了部分习题的答案。 《TCP/IP详解》对于网络应用的开发人员、网络管理员以及任何想了解TCP/IP协议运行原理的人员来说,都是极好的参考书。无论是初学者还是功底深厚的网络领域高手,这套书都应是案头大作。

2019-05-18

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除