Friday, January 24, 2020

[google-cloud-sql-discuss] Re: Got an error reading communication packets and Net packets out of order error

Hi, Albert. 

Actually, the Link could no longer be accessible publicly as project-specific private information were shared on the link. However, the information shared on the link by the CloudSQL Specialist are details about how and why the Aborted Connection errors may be reported. Please view the comment below: 

=====

"Aborted connection nnnn to db:" error message is triggered when an existing connection is not terminated properly, 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 and this should be fine when your app hits production.
- implement incremental backoff in your code to handle connections when the DB is temporarily unavailable.

Using exponential backoff prevents your application from sending an unhealthy number of connection requests when it can't connect to the database.

I hope this helps. 

[1] https://cloud.google.com/sql/docs/mysql/diagnose-issues#connection
[2] https://dev.mysql.com/doc/refman/8.0/en/communication-errors.html
[3] https://www.percona.com/blog/2016/05/16/mysql-got-an-error-reading-communication-packet-errors/

--
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/e5f4f7cf-9970-43f2-8361-84ecfd72bf7b%40googlegroups.com.

No comments:

Post a Comment