MariaDB – Troubleshoot Out-of-Memory Issues

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

  1. Non-optimal tables and queries
  2. MySQL Server Configuration
  3. Memory-intensive processes
  4. Poor hardware resources
    • Insufficient RAM
    • Lack of disk space

Here are the ways to troubleshoot

  1. 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.
  2. 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’)

Cheers!

Knowledge worth sharing...Share on linkedin
Linkedin
Share on facebook
Facebook
Share on google
Google
Share on twitter
Twitter