Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL: the API for simply recording and deleting binary log

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Welcome to my "in-depth understanding of MySQL Master and Slave principle 32", as follows:

! [image.png] (https://upload-images.jianshu.io/upload_images/7398834-0ffa3bdc078cddf4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

If the picture cannot be displayed, please see the following link:

Https://www.jianshu.com/p/d636215d767f

Stack frame # 0 my_delete (name=0x7ffff0fa0490 ". / binlog.000005", MyFlags=0) at / root/softm/percona-server-5.7.22-22/mysys/my_delete.c:25#1 0x000000000186416f in inline_mysql_file_delete (key=2, src_file=0x2293340 "/ root/softm/percona-server-5.7.22-22/sql/binlog.cc", src_line=6735, name=0x7ffff0fa0490 ". / binlog.000005" Flags=0) at / root/softm/percona-server-5.7.22-22/include/mysql/psi/mysql_file.h:1331#2 0x0000000001871497 in MYSQL_BIN_LOG::purge_index_entry (this=0x2e39c40, thd=0x7fffa4000b70, decrease_log_space=0x0, need_lock_index=false) at / root/softm/percona-server-5.7.22-22/sql/binlog.cc:6735#3 0x0000000001870b35 in MYSQL_BIN_LOG::purge_logs (this=0x2e39c40, to_log=0x7ffff0fa0a80 ". / binlog.000007", included=false, need_lock_index=true Need_update_threads=true, decrease_log_space=0x0, auto_purge=false) at / root/softm/percona-server-5.7.22-22/sql/binlog.cc:6495#4 0x0000000001868839 in purge_master_logs (thd=0x7fffa4000b70, to_log=0x7fffa4006570 "binlog.000007") at / root/softm/percona-server-5.7.22-22/sql/binlog.cc:3127#5 0x00000000015b7874 in mysql_execute_command (thd=0x7fffa4000b70 First_level=true) at / root/softm/percona-server-5.7.22-22/sql/sql_parse.cc:2989#6 0x00000000015c0362 in mysql_parse (thd=0x7fffa4000b70, parser_state=0x7ffff0fa2600) at / root/softm/percona-server-5.7.22-22/sql/sql_parse.cc:5901#7 0x00000000015b3ef6 in dispatch_command (thd=0x7fffa4000b70, com_data=0x7ffff0fa2d70 Command=COM_QUERY) at / root/softm/percona-server-5.7.22-22/sql/sql_parse.cc:1490#8 0x00000000015b2c83 in do_command (thd=0x7fffa4000b70) at / root/softm/percona-server-5.7.22-22/sql/sql_parse.cc:1021#9 0x00000000016fb8fc in handle_connection (arg=0x38f2910) at / root/softm/percona-server-5.7.22-22/sql/conn_handler/connection_handler_per_thread.cc:312#10 0x0000000001932112 in pfs _ spawn_thread (arg=0x3860a50) at / root/softm/percona-server-5.7.22-22/storage/perfschema/pfs.cc:2190#11 0x00007ffff7bc6aa1 in start_thread () from / lib64/libpthread.so.0#12 0x00007ffff6719bcd in clone () from / lib64/libc.so.6 II, Approximate process

The whole deletion process is about:

First extract the binary log records that need to be deleted into a temporary index file, binlog.~rec~. Store the binary log file that you need to keep in a file called binlog.index_crash_safe. Delete the original binlog.index and rename the binlog.index_crash_safe to binlog.index.

The following is a list of files for the intermediate moment.

-rw-r- 1 root root 80 Jun 26 10:25 binlog.index-rw-r- 1 root root 32 Jun 26 10:38 binlog.~rec~-rw-r- 1 root root 48 Jun 26 10:39 binlog.index_crash_safe and then delete the binary log file from the binlog.~rec~ record. Finally, delete the binlog.~rec~ file. The whole process focuses on.

In the function MYSQL_BIN_LOG::purge_logs, we can easily see this process by setting the breakpoint on the my_delete function.

Here is a portion of my debug:

In (gdb) p purge_index_file- > file$6 = 61OS, we can see that the file descriptor is 61-> / root/softm/percona-server-5.7.22-22.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report