So what happens when mysqld runs out of disk space?
The answer is: It depends
- It might start to wait until disk space becomes available.
- It might crash intentionally after a 'long semaphore wait'
- It might return an error to the client (e.g. 'table full')
- It might skip writing to the binlog (see
binlog_error_action
)
Fixing the disk space issue can be done by adding more space or cleaning up some space. The later can often be done without help of the administrator of the system.
So I wanted to change the behaviour so that it MySQL wouldn't crash or stop to respond to read queries. And to also make it possible for a user of the system to cleanup data to get back to a normal state.
So I wrote a audit plugin which does this:
- The DBA sets the maxdiskusage_minfree variable to a threshold for the minimum amount of MB free.
- If the amount of free disk space goes under this threshold:
- Allow everything for users with the SUPER privilege
- Allow SELECT and DELETE
- Disallow INSERT
- If the amount of free space goes back to normal: Allow everything again
Note that DELETE can actually increase disk usage because of binlogs, undo, etc.
The code is available on github: https://github.com/dveeden/mysql_maxdiskusage
No comments:
Post a Comment