Search code examples
google-app-enginegoogle-cloud-platformgoogle-cloud-sql

Does GAE Python3 Standard Environment + Cloud SQL MySQL 2nd Gen use Cloud SQL Proxy?


I am having a number of errors reported in logs from Cloud SQL such as the following in a GAE Standard Python3 app connecting to Cloud SQL MySQL 2nd gen:

textPayload: "2019-02-19 485 [Note] Aborted connection 485 to db: 'my_database' user: 'root' host: 'cloudsqlproxy~74.125.xx.xxx' (Got an error reading communication packets)"

Does GAE Python3 even use Cloud SQL Proxy under the hood? How can I avoid these issues?


Solution

  • Yes, GAE Standard uses the Cloud SQL Proxy to communicate with the Cloud SQL instance (if you are accessing using the instance name, but not necessary if accessing by public IP). Also, the error message may not be an issue.

    "Aborted connection xxx to db: 'db_name' user: 'sql_user' host: 'ip_address'"

    This 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(like when instances scale down and get terminated) or networking problem between the server and the client, but not because of the server.

    This may affect your SQL instance when connecting from GCE or GAE if long-lived idle connections are common for your use case. To rectify: