What happens to MySQL when the disk space is full? How should we deal with it?

When the disk space is full, MySQL can no longer write any data, including the writing of table data, and files such as binlog and binlog-index.

Of course, because InnoDB can put dirty data in memory first, it will not immediately show that it cannot be written. Unless binlog is turned on, write requests will be blocked.

When MySQL detects that the disk space is full, it will:

Every minute: Check whether the space is freed so that new data can be written. When it finds that there is free space, it will continue to write data, and everything will be business as usual.

Every ten minutes : If there is still no free space, it will write a record in the log and report that the disk space is full (only a few bytes are enough at this time).

What to do

So, when we find that the disk space is full, what should we do? Suggestions:

Increase the frequency of monitoring system detection to prevent recurrence;

Delete unused files in time to free up space;

If a thread is blocked due to the problem of full disk, it can be killed first, and it may work normally when it is rechecked in the next minute;

It is possible that some threads are blocked because the disk is full, and other threads are blocked. The blocking thread can be killed, and other blocked threads can continue to work.

There is an exception:

When REPAIR TABLE or OPTIMIZE TABLE operations are performed, or when indexes are updated in batches after LOAD DATA INFILE or ALTER TABLE is performed, these operations will create temporary files. When performing these operations, mysqld finds that the disk space is full.

It will mark the involved table as crashed and delete the temporary file (except for the ALTER TABLE operation, MySQL will abandon the operation being performed, delete the temporary file, and release the disk space).

 

 

In addition, if you want to better improve your programming ability, learn C language and C++ programming! Overtaking in a curve, one step faster! I may be able to help you here~

UP has uploaded some video tutorials on learning C/C++ programming on the homepage. Those who are interested or are learning must go and take a look! It will be helpful to you~

Sharing (source code, actual project video, project notes, basic introductory tutorial)

Welcome partners who change careers and learn programming, use more information to learn and grow faster than thinking about it yourself!

Programming learning:

Programming learning:

 

Guess you like

Origin blog.csdn.net/weixin_45713725/article/details/115127698