Memory is full.

Issues related to applications and software problems
Post Reply
hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Memory is full.

Post by hack3rcon » 2019/11/12 08:14:26

Hello,
On a CentOS web server I see below error:

Code: Select all

SQLSTATE[HY000] [1040] Too many connections
The MySQL config file is:

Code: Select all

# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-show-database

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Settings user and group are ignored when systemd is used (fedora >= 15).
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
user=mysql

# Semisynchronous Replication
# http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html
# uncomment next line on MASTER
;plugin-load=rpl_semi_sync_master=semisync_master.so
# uncomment next line on SLAVE
;plugin-load=rpl_semi_sync_slave=semisync_slave.so

# Others options for Semisynchronous Replication
;rpl_semi_sync_master_enabled=1
;rpl_semi_sync_master_timeout=10
;rpl_semi_sync_slave_enabled=1

# http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html
;performance_schema


[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid


#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

bind-address = 127.0.0.1
local-infile=0
And "htop" command show me:
htop.png
htop.png (182.13 KiB) Viewed 3216 times
How can I troubleshoot it?

Thanks.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Memory is full.

Post by TrevorH » 2019/11/12 12:15:33

SQLSTATE[HY000] [1040] Too many connections
Has nothing to do with memory "being full". You either don't have enough connections allowed in your mysql config (unlikely but possible) or, far more likely, you have a bug in whatever app you are using that leaks mysql connections - i.e. opens them and never closes them - so it runs until all possible connections are used up and then hits that error. Raising the connection limit on the mysql side in that case will only delay (possibly only slightly) the onset of the problem.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Re: Memory is full.

Post by hack3rcon » 2019/11/12 12:49:48

How can I estimate a good value of "max_connections"?

BShT
Posts: 584
Joined: 2019/10/09 12:31:40

Re: Memory is full.

Post by BShT » 2019/11/12 13:16:56

you can size server and max_connections according to your load

there is no magic number

here we have max_connections = 1000 and innodb_buffer_pool_size = 16G per 32vCPUx32GB node

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Memory is full.

Post by TrevorH » 2019/11/12 14:19:00

In 99% of cases, that error means your app is buggy and leaking connections. I checked a CentOS 6 mysql server that does not have "max_connections=" in my.cnf and it is set to a maximum of 151 connections. You would need to have 152 concurrent accesses to your app to make it exhaust those.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

lightman47
Posts: 1521
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: Memory is full.

Post by lightman47 » 2019/11/12 21:53:48

Is this the same machine with the 'testuser' account, or a different one?

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Memory is full.

Post by TrevorH » 2019/11/12 23:03:35

Also, since the reported symptom (Too many connections) has nothing whatsoever to do with the subject title, perhaps a pointer to http://linuxatemyram.com wouldn't go amiss...
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Re: Memory is full.

Post by hack3rcon » 2019/11/13 07:03:20

TrevorH wrote:
2019/11/12 23:03:35
Also, since the reported symptom (Too many connections) has nothing whatsoever to do with the subject title, perhaps a pointer to http://linuxatemyram.com wouldn't go amiss...
Is you mean https://www.linuxatemyram.com/play.html?

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Memory is full.

Post by jlehtone » 2019/11/13 07:33:32

It does appear that:
* There is a seriously misconfigured server (accounts, firewall)
* There are web pages with flaws (that misuse SQL)
* Current admin has insufficient knowledge
* The "web server" is "vital" (and for vital things one must allocate appropriate resources)

We can not, nor should teach the basics. For that one should seek local expert.
We can not, nor should teach how to write a web page. For that one should seek local expert.

We can explain CentOS-specific bits, if the recipient knows general principles.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Memory is full.

Post by TrevorH » 2019/11/13 07:59:41

No, I meant the thing I linked to, not what you did.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Post Reply