Tony Tony - 6 months ago 16
MySQL Question

Wordpress error establishing a database connection - Memory Issue

I have been running this wordpress site for a long time with no issues, however have recently been getting the error "Error establishing a database connection". If I restart mySQL the problem is temporarily fixed but will soon comes back.

After looking through the MySQL log files I believe the problem is because of some sort of memory leak, however I am having trouble tracking down the root of the problem.

I have read that the problem could be coming from a swapfile not being configured, however I have configured the swap as follows:

total used free shared buffers cached
Mem: 987 968 18 26 18 137
-/+ buffers/cache: 812 175
Swap: 255 35 220


It would be awesome if anyone could help me make sense of this log file.

MySQL Log File:

2016-03-17 06:48:45 3575 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
2016-03-17 06:48:45 3575 [Note] Plugin 'FEDERATED' is disabled.
2016-03-17 06:48:45 3575 [ERROR] Function 'innodb' already exists
2016-03-17 06:48:45 3575 [Warning] Couldn't load plugin named 'innodb' with soname 'ha_innodb.so'.
2016-03-17 06:48:45 3575 [ERROR] Function 'federated' already exists
2016-03-17 06:48:45 3575 [Warning] Couldn't load plugin named 'federated' with soname 'ha_federated.so'.
2016-03-17 06:48:45 3575 [ERROR] Function 'blackhole' already exists
2016-03-17 06:48:45 3575 [Warning] Couldn't load plugin named 'blackhole' with soname 'ha_blackhole.so'.
2016-03-17 06:48:45 3575 [ERROR] Function 'archive' already exists
2016-03-17 06:48:45 3575 [Warning] Couldn't load plugin named 'archive' with soname 'ha_archive.so'.
2016-03-17 06:48:45 3575 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-03-17 06:48:45 3575 [Note] InnoDB: The InnoDB memory heap is disabled
2016-03-17 06:48:45 3575 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-03-17 06:48:45 3575 [Note] InnoDB: Memory barrier is not used
2016-03-17 06:48:45 3575 [Note] InnoDB: Compressed tables use zlib 1.2.8
2016-03-17 06:48:45 3575 [Note] InnoDB: Using Linux native AIO
2016-03-17 06:48:45 3575 [Note] InnoDB: Using CPU crc32 instructions
2016-03-17 06:48:45 3575 [Note] InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
2016-03-17 06:48:45 3575 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2016-03-17 06:48:45 3575 [ERROR] Plugin 'InnoDB' init function returned error.
2016-03-17 06:48:45 3575 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-03-17 06:48:45 3575 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-03-17 06:48:45 3575 [ERROR] Aborting

2016-03-17 06:48:45 3575 [Note] Binlog end
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'partition'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'BLACKHOLE'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'ARCHIVE'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_METRICS'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_CMPMEM'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_CMP'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_LOCKS'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_TRX'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'CSV'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'MEMORY'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'MRG_MYISAM'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'MyISAM'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'sha256_password'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'mysql_old_password'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'mysql_native_password'
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'binlog'
2016-03-17 06:48:45 3575 [Note] /usr/sbin/mysqld: Shutdown complete

2016-03-17 06:48:46 3606 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
2016-03-17 06:48:46 3606 [Note] Plugin 'FEDERATED' is disabled.
2016-03-17 06:48:46 3606 [ERROR] Function 'innodb' already exists
2016-03-17 06:48:46 3606 [Warning] Couldn't load plugin named 'innodb' with soname 'ha_innodb.so'.
2016-03-17 06:48:46 3606 [ERROR] Function 'federated' already exists
2016-03-17 06:48:46 3606 [Warning] Couldn't load plugin named 'federated' with soname 'ha_federated.so'.
2016-03-17 06:48:46 3606 [ERROR] Function 'blackhole' already exists
2016-03-17 06:48:46 3606 [Warning] Couldn't load plugin named 'blackhole' with soname 'ha_blackhole.so'.
2016-03-17 06:48:46 3606 [ERROR] Function 'archive' already exists
2016-03-17 06:48:46 3606 [Warning] Couldn't load plugin named 'archive' with soname 'ha_archive.so'.
2016-03-17 06:48:46 3606 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-03-17 06:48:46 3606 [Note] InnoDB: The InnoDB memory heap is disabled
2016-03-17 06:48:46 3606 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-03-17 06:48:46 3606 [Note] InnoDB: Memory barrier is not used
2016-03-17 06:48:46 3606 [Note] InnoDB: Compressed tables use zlib 1.2.8
2016-03-17 06:48:46 3606 [Note] InnoDB: Using Linux native AIO
2016-03-17 06:48:46 3606 [Note] InnoDB: Using CPU crc32 instructions
2016-03-17 06:48:46 3606 [Note] InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
2016-03-17 06:48:46 3606 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2016-03-17 06:48:46 3606 [ERROR] Plugin 'InnoDB' init function returned error.
2016-03-17 06:48:46 3606 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-03-17 06:48:46 3606 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-03-17 06:48:46 3606 [ERROR] Aborting

Answer

It's problem with your server memory. From your MySQL Log File we can get that InnoDb plugin failed to start due to unable to Initializing buffer pool. So any tables with InnoDb storage cause errors.

Your workaround solution

If I restart mySQL the problem is temporarily fixed but will soon comes back.

works because you get some free memory after restarting Mysql.

2016-03-17 06:48:46 3606 [Note] InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
2016-03-17 06:48:46 3606 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2016-03-17 06:48:46 3606 [ERROR] Plugin 'InnoDB' init function returned error.
2016-03-17 06:48:46 3606 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-03-17 06:48:46 3606 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-03-17 06:48:46 3606 [ERROR] Aborting