Intermittent Mysql Connection error in ROR app

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Intermittent Mysql Connection error in ROR app

Loganathan Sellapa
Hi Everyone, 

I'm getting the below error randomly in my Ruby On Rails application whenever the number of requests increases to the server.


Mysql2::Error::ConnectionError (Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)):

I'm not sure whether it is because of my server memory or is it something to do with mysql2 gem. Any help would be really appreciated, thanks in advance.

Ruby '2.5.0'
Rails '5.2.0
Mysql2 0.5.2
Phusion Passenger 5.3.4
Server version: Apache/2.4.6 (CentOS)
RAM SIZE: 1.5GB
MySQL Community Server (GPL): 5.6.41
Regards,
Loganathan

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3f2416a7-1ba8-44c3-81e6-17384309af43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Intermittent Mysql Connection error in ROR app

unni.tallman
Hi

You can try the following:

1. In your database.yml, increase the `pool` size. 
2. In database.yml, pass `reconnect: true`
3. Make sure `max_connections` in your Mysql server configuration is a number big enough to support the pool size you are setting.

Unni

On Thu, 11 Apr 2019 at 10:51, Loganathan Sellappa <[hidden email]> wrote:
Hi Everyone, 

I'm getting the below error randomly in my Ruby On Rails application whenever the number of requests increases to the server.


Mysql2::Error::ConnectionError (Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)):

I'm not sure whether it is because of my server memory or is it something to do with mysql2 gem. Any help would be really appreciated, thanks in advance.

Ruby '2.5.0'
Rails '5.2.0
Mysql2 0.5.2
Phusion Passenger 5.3.4
Server version: Apache/2.4.6 (CentOS)
RAM SIZE: 1.5GB
MySQL Community Server (GPL): 5.6.41
Regards,
Loganathan

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3f2416a7-1ba8-44c3-81e6-17384309af43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Unni

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAK7OhfZd_URiSUSXyJD8H0owxRiF%2BWvhavh69-JqgkA2bY%2Bg6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Intermittent Mysql Connection error in ROR app

Sasha Boginsky
In reply to this post by Loganathan Sellapa
Hi, 

I get this error in Homebrew sometimes. I think it means it doesn't recognize you as a local user, not sure! 
This workflow for me always fixes it. Maybe it will help you figure out how to fix it using the MYSQL Community Server, they have similar issues:

$ mysql.server stop

// unset the tmp directory
$ echo $TMPDIR
$ unset TMPDIR
$ echo $TMPDIR

// validate this using echo then set it
$ echo mysqld -initialize --verbose --user=$(whoami) --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
$ mysqld -initialize --verbose --user=$(whoami) --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

$ mysql.server restart
$ mysql -u root -p

From there I access the mysql command line shell, set myself as root, run $flush privileges, exit mysql command line, run the login command, and error goes away


On Thu, Apr 11, 2019 at 1:20 AM Loganathan Sellappa <[hidden email]> wrote:
Hi Everyone, 

I'm getting the below error randomly in my Ruby On Rails application whenever the number of requests increases to the server.


Mysql2::Error::ConnectionError (Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)):

I'm not sure whether it is because of my server memory or is it something to do with mysql2 gem. Any help would be really appreciated, thanks in advance.

Ruby '2.5.0'
Rails '5.2.0
Mysql2 0.5.2
Phusion Passenger 5.3.4
Server version: Apache/2.4.6 (CentOS)
RAM SIZE: 1.5GB
MySQL Community Server (GPL): 5.6.41
Regards,
Loganathan

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3f2416a7-1ba8-44c3-81e6-17384309af43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Sasha Boginsky
BBA Class of 2017
Emory Goizueta Business School
646.241.5756

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CALD0ZKmN3Ysb5u78GKorbkRkoo_b7xjJobTv5m2A-UEybQ6rXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Intermittent Mysql Connection error in ROR app

Fatih Orhan
In reply to this post by Loganathan Sellapa
Error number 2 means file not found. This is likely a MySQL server problem.
I suggest checking system logs, MySQL logs and auth log.
This guy found the reason to be hackers trying to get in: http://forums.devshed.com/mysql-help-4/intermittent-cant-connect-mysql-socket-937298.html

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5878c294-3d45-4217-ac81-0bdd17dd09b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Intermittent Mysql Connection error in ROR app

Loganathan Sellapa
Hi All,

The issue gotbredolved after I increase the RAM size to 4GB from 1GB.

On Fri, Apr 19, 2019 at 7:38 PM Fatih Orhan <[hidden email]> wrote:
Error number 2 means file not found. This is likely a MySQL server problem.
I suggest checking system logs, MySQL logs and auth log.
This guy found the reason to be hackers trying to get in: http://forums.devshed.com/mysql-help-4/intermittent-cant-connect-mysql-socket-937298.html

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5878c294-3d45-4217-ac81-0bdd17dd09b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
regards,
Loganathan

Sent from handheld device.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAD_i5MGU3bmvrK0ZojAQmGzuaRQNvBr6wfMO8MKwdmDif28o6g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.