In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you "from the MySQL source code to see what are the reasons for the failure of log commands", the content is easy to understand, well-organized, I hope to help you solve your doubts, the following let the editor lead you to study and learn the reasons for the failure of log commands from MySQL source code.
Today, reading the database kernel monthly report, I found an interesting problem, that is, there was no result in show binary logs. The reason for this problem is very simple, but the process of analyzing the problem is arduous, and we need to find that positive result among all kinds of potential possibilities. Of course, the greatest benefit of this problem is not to solve the problem, but through this problem we can change the way of thinking to analyze, for example, through the source code to understand more details.
I downloaded the source code of recent versions of MySQL on my computer, which I seldom read at ordinary times, but the environment was basically configured, so I waited for some practical and quick cases.
First of all, repeat the problem. The version I tested is 5.6. when I use show binary logs to view the information of binlog, the results are as follows:
Mysql > show binary logs
Empty set (0.00 sec)
In fact, there is a binlog in this environment, and there is no doubt that binlog is open.
We can see these binlog at the system level.
As you can see from the binlog.index file, these binlog do exist.
Because I know the answer to the question, so from the point of view of the doubt inside, the index file above looks strange, why the first line is empty.
So following this line of thinking, we can see if it is caused by this problem.
Ali's classmates in the article http://mysql.taobao.org/monthly/2017/09/03/
The reference file is given, which is rpl_master.cc, and the simple translation belongs to the replication part, the master side. The implementation details of the command show master status or reset master we use on the masterside are all in this file, so let's cite an example. There is another file that is rpl_slave, reset_slave, start slave,stop slave,show slave status, etc., all in this file.
Let's take a look at the file rpl_master.cc file to see the implementation part. If you look at it in the way of eclipse, you can see some detailed information through several dimensions, the left is the hierarchical structure of the code, the middle is the specified function, such as the implementation of show binary logs, and the right is some overview, such as variables, methods and so on.
Of course, there is a huge difference in the amount of code between rpl_master and rpl_slave, and rpl_slave adds a part of GTID, and you can see a lot of comments.
In rpl_master, we can quickly see the following logic. If it is a blank line or the end of EOF will be regarded as the end of the file, the above line is called the index file to get a list of information.
So if you understand the reason for this problem, it will be very easy to fix it. Just delete the blank line and refresh the log again.
Delete the spaces, and then refresh the log, as shown below.
So according to this idea, we can find what we want in rpl_slave, such as the meaning of Seconds_Behind_Master, and there is a golden house in the code. The pseudo-code is even given in the comments, which describes the calculation process in detail.
The explanation of the code in it is still very detailed, and it feels like reading the document.
Of course, it is also very clear that Seconds_Behind_Master can not be trusted, and sometimes it is not allowed.
After reading the code for a while, I found that there are still some imperfections in the implementation of request_dump. The code also looks very helpless and can only be fixed later.
The above is all the contents of this article "what are the reasons for the failure of the log command from the MySQL source code?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.