In this blog post, we are going to discuss MariaDB crash issues due to out-of-memory (OOM), and how to troubleshoot them.
When you get this error, it clearly indicates that the server is running out of memory. In other words, the allocated memory to MariaDB is not enough to handle the process requirements.
If memory is insufficient, then we just have to increase RAM, right? Well, this is certainly one solution, but it is the easiest way out. Simply adding RAM is neither the ideal solution nor a cheaper way. A memory-intensive query or process can eventually eat up the added memory, and can lead to errors in a short span of time.
Common Causes of Out-Of-Memory Issues
- Non-optimal tables and queries
- MySQL Server Configuration
- Memory-intensive processes
- Poor hardware resources
- Insufficient RAM
- Lack of disk space
Here are the ways to troubleshoot
- Check Linux OS and Config
- Check /var/log/messages and /var/log/syslog. Try to find an entry where it says something like “OOM killer killed MySQL”. Once you find it, the surrounding details will give you clues.
- Check available RAM.
- free -g
- cat /proc/meminfo
- Issue “top” command to see what applications are consuming RAM.
- Run vmstat 5 5 to view if the system is swapping and if it is reading/writing via virtual memory.
- Check MariaDB. Look for possible MariaDB memory leaks
- These are the places where MariaDB allocates most of the memory:
- Table cache
- InnoDB (execute show engine innodb status, and look for buffer_pool and associated caches in the buffer pool section.
- Identify if there are temporary tables in RAM (select * from information_schema.tables where engine=’MEMORY’;)
- Prepared statements, when it is not removed from the set of resources (show global status like ‘Com_prepare_sql’; show global status like ‘Com_dealloc_sql’)
- These are the places where MariaDB allocates most of the memory:
Cheers!