Wednesday, June 5, 2019

[google-cloud-sql-discuss] Re: Timeout Errors connecting to a Google Cloud SQL instance from a webpage

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.


On Friday, May 31, 2019 at 3:19:09 PM UTC-4, Sam (Google Cloud Support) wrote:
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

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/fa06f6c1-f9ae-4698-96f9-db447dbaeb1e%40googlegroups.com.

No comments:

Post a Comment