Timeout Errors connecting to a Google Cloud SQL instance from a webpage

1,848 views
Skip to first unread message

Tommie Carter

unread,
May 29, 2019, 10:29:09 PM5/29/19
to Google Cloud SQL discuss
I am seeing a number of timeout errors from our external web application (a Question2Answer site). The errors are attached and I've tried the following items already.

Added 4 database flags related to timeouts
Verified that my user has full resource access using SequelPro client
Verified that my user can create tables, etc from the SequelPro client
Enabled access to the IP address associated with the website and an IP address found in the logs
Researched the various connection issues associated with mysql
Confirmed that I can use an alternate mysql db connection from the web application
Verified that the instance public IP accessibility is configured and working
Noted that some additional error messages appear in the logs and attached

I am hoping someone can provide additional insight on how to resolve the connectivity issue from my networksolutions hosted website to my GCS instance.


Thanks in advance,
Tom

cloudsql_database_database_id_galvanic-ward-235617%3Aontimeserver01__logs__2019-05-28T12-39.csv

Sam (Google Cloud Support)

unread,
May 31, 2019, 3:19:09 PM5/31/19
to Google Cloud SQL discuss
Hi, this "Aborted connection nnnn to db:" error message is triggered when an existing connection is terminated improperly, which may look erroneous but is actually perfectly normal. 

Aborted connections happen because of unclean closure of connection or networking problem between the server and the client, but not because of the server [1].

You should note that this error does not mean that there are problems with your Cloud SQL instance and as far as I know these types of errors in the mysql logs are harmless but seem to be useful to indicate client side behaviors because of the following:

1) It won't trigger "Aborted connection" error when mysql client closes cleanly.
2) If the proxy client is killed but didn't close mysql client --> The socket connection is still alive.
    a) manually close the socket connection at the client side
    b) OR wait until times out based "wait_timeout" in MySQL server and the connection closed --> "Aborted connection" error. 

The official MySQL documentation suggests various reasons why this could happen and some actions to take [2]. And this blog goes into more details on fixes [3].

In conclusion, if you want to reduce such errors in the logs, I'd suggest to cleanly close each connection

Tommie Carter

unread,
Jun 5, 2019, 9:29:05 AM6/5/19
to Google Cloud SQL discuss
I have resolved this issue. Here are my steps that may help other customers with this problem.

1) Temporarily enable 0.0.0.0/0 in connections to allow all access

2) Add the following settings into your local PHP file to increase the time allowed to make connections:

        ini_set('mysql.connect_timeout', 14400);
 	ini_set('default_socket_timeout', 14400);
 	ini_set('max_execution_time', 0);

3) Execute the test PHP page

4) Execute the following MySQL command on the instance to verify active connections

       SHOW PROCESSLIST;

5) Override the temporary IP address in step 1 with the permanent address associated with the desired connection and save the configuration.
Reply all
Reply to author
Forward
0 new messages