2
votes

I setup an old Django app on a new GCE instance on Sunday and pointed it to a new CloudSQL instance with imported data there. This code and data has successfully run over the past few years on a variety of dedicated hosting setups, on EC2 and on EC2+RDS.

Since Sunday I have had intermittent reports of 2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 0" from the App. In particular today it happened in two bursts of 3 separated by about 7 hours.

I panicked in the earlier outages and restarted both the app and the CloudSQL instance which did the trick. However the latter ones today righted themselves after a few minutes.

I've never encountered this error before working with MySQL and any searching on the error gives results related to people who have general access problems to the DB.

On the GCE side the only difference I can think of from previous setups is that it is using Google's out-of-the-box Debian image instead of Ubuntu 12.04. On the MySQL side I have no idea as I've successfully run this on both MySQL 5.x and MariaDB.

Is there any way of figuring out why this is happening and fixing it?

Thanks.

2
I am having the same exact issue but with PHP apps, everything was running without a problem until three hours ago, I have the same initial communication packet errorMohammad Abu Musa

2 Answers

1
votes

Have you tried changing keep alive settings for TCP connections? GCE has a firewall rules that drops idle TCP connections after 10 mins:

https://cloud.google.com/compute/docs/troubleshooting#communicatewithinternet

You can check current value of 'tcp_keepalive_time':

cat /proc/sys/net/ipv4/tcp_keepalive_time 

And change it to 60 seconds:

vi /etc/sysctl.conf
# Add this line
net.ipv4.tcp_keepalive_time = 60
# Reload Sysctl interface
sudo /sbin/sysctl   --load=/etc/sysctl.conf 

You might need to restart Django server to pick new keep alive settings.

Note: If this problem was limited to yesterday (18/11/2014) and your Cloud SQL instances are located in EU, you might have been affected by this:

https://groups.google.com/forum/#!topic/google-cloud-sql-announce/k5raPT48hc0

0
votes

It seems there is an issue with the firewall, preventing incoming connections, just change the location from the server to another mirror things suppose to go fine. It worked for me