New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL 5.7 Aborted Connection - Got an error reading communication packets #556

Closed
kyluke opened this Issue Mar 23, 2017 · 18 comments

Comments

Projects
None yet
7 participants
@kyluke
Copy link

kyluke commented Mar 23, 2017

Issue description

The connection to MySQL should open. However, opening this connection in Golang, results in the error (Got an error reading communication packets). Opening the MySQL connection from the cli works.

Tried:

  • Increasing the wait_time
  • Increasing the connection_time
  • Increasing the max packet size

Example code

func open_mysql(Host *string, Username *string, Password *string, Database *string, parameters string) *sql.DB {
	open, err := sql.Open("mysql", *Username+":"+*Password+"@tcp("+*Host+")/"+*Database+parameters)

	if err != nil {
		log.Printf("%s\n", err)
	}
	return open
}

Error log

[Note] Aborted connection 13086 to db: '<redacted>' user: '<redacted>' host: '<redacted but not localhost, outside network connection>' (Got an error reading communication packets)

Configuration

Driver version (or git SHA):
latest pull from go get -u github.com/go-sql-driver/mysql as of today.

Go version:
go version go1.7.5 darwin/amd64
AND
go version go1.8 darwin/amd64

Server version:
Server version: 5.7.17-0ubuntu0.16.04.1 (Ubuntu)

Server OS:
Ubuntu 16.04.1

@kyluke

This comment has been minimized.

Copy link

kyluke commented Mar 23, 2017

Tested it with go version go1.7.3 darwin/amd64

Still fails.

@methane

This comment has been minimized.

Copy link
Contributor

methane commented Mar 23, 2017

What is "error log"? Is it MySQL server's error log?
If so, would you try increase log verbosity and paste logs before the line?
What log.Printf("%s\n", err) shows?

@kyluke

This comment has been minimized.

Copy link

kyluke commented Mar 23, 2017

[Note] Aborted connection 13086 to db: '<redacted>' user: '<redacted>' host: '<redacted but not localhost, outside network connection>' (Got an error reading communication packets)

Is from /var/log/mysql/error.log
I'll try with a more verbose output.

The curious thing is, log.Printf("%s\n", err) doesn't report any errors.

@methane

This comment has been minimized.

Copy link
Contributor

methane commented Mar 23, 2017

Actually, sql.Open() doesn't create any connection.
sql.Exec("SELECT 1+1") may create connection (and make error).

@kyluke

This comment has been minimized.

Copy link

kyluke commented Mar 23, 2017

I've tried to increase the verbosity of the MySQL logs using

SET GLOBAL log_warnings=3;

and have also tried to print out any errors from the sql query directly using

stmt, queryErr := db.Query(sqlQuery.String())
log.Printf("error: %s\n", queryErr.Error())
log.Printf("stmt error: %s\n", stmt.Err())

But no luck yet. Running the SQL query (which I unfortunately cannot share here) within the mysql cli client, works 100%.

@kyluke

This comment has been minimized.

Copy link

kyluke commented Mar 23, 2017

Any ideas? This has totally broken our binaries. They cannot connect to a MySQL database, whether it's local nor remote.

I've tried different versions of MySQL and different versions of golang (1.7.3 upwards).

I've also built this on a linux machine with a fresh installed copy of github.com/go-sql-driver/mysql with no positive result.

Any pointers that you guys may have to fix this are much appreciated.

@julienschmidt

This comment has been minimized.

Copy link
Member

julienschmidt commented Mar 23, 2017

Got an error reading communication packets suggests that something went wrong while MySQL was waiting for a packet. You could use Wireshark or tcpdump to further inspect what exactly is going e.g. after which packet it aborts

@methane

This comment has been minimized.

Copy link
Contributor

methane commented Mar 23, 2017

What "but no lock yet" means?
MySQL server doesn't log anything when increased log level?

@kyluke

This comment has been minimized.

Copy link

kyluke commented Mar 23, 2017

@methane switching log level from 2 to 3 didn't yield any more information.

@julienschmidt I'll try that now and see if I can get anywhere with that.

@methane

This comment has been minimized.

Copy link
Contributor

methane commented Mar 23, 2017

I've tried different versions of MySQL and different versions of golang (1.7.3 upwards).

Do you mean same problem happened on MySQL 5.6 too?

Your report lacks detail information about "what you tried and what you got."

Many users uses this with MySQL 5.7. You is the only person reporting issue.
This issue is very likely caused by your environment. Please report more complete information.

@kyluke

This comment has been minimized.

Copy link

kyluke commented Mar 23, 2017

@methane Will do.

@kyluke

This comment has been minimized.

Copy link

kyluke commented Mar 23, 2017

Problem resolved.

I'm not sure how though. Recompiled the code a bunch of times with certain sections commented out. Then pushed versions with specific lines uncommented again until I found the culprit. Unfortunately, I uncommented everything one by one and it ended up working. No changes to the code.

Really annoying. Thank you guys for your input and your help. @julienschmidt your idea to monitor tcpdumps was incredibly useful, thanks.

@kyluke kyluke closed this Mar 23, 2017

@faisalburhanudin

This comment has been minimized.

Copy link

faisalburhanudin commented Aug 24, 2017

I know this is old issue, but when I search this problem, this issue appear in search result
In my case, the problem appear because I forgot to close connection.

so just don't forget to close your connection db.Close()

@deddu

This comment has been minimized.

Copy link

deddu commented Sep 22, 2017

I've been having the exact same problem. Code works with mysql 5.6 and fails with 5.7.
Even more curiously, in msyql5.7 a select x,y from points limit 10 works. but with larger limits it fails with the Got an error reading communication packets.
I've attempted changing the mysqld config parameter max_allowed_packet as I expected that to be related but without success.

@methane

This comment has been minimized.

Copy link
Contributor

methane commented Sep 22, 2017

I have no trouble with MySQL 5.7.
How to reproduce? code? mysql config?

@julienschmidt

This comment has been minimized.

Copy link
Member

julienschmidt commented Sep 29, 2017

I'm not sure if it was the OS upgrade (macOS 10.13) or the MariaDB upgrade (10.2.9-MariaDB Homebrew), but I can reproduce this bug now.

The cause seems to be our beloved strict mode.
If I disable it, everything works fine.

@julienschmidt julienschmidt reopened this Sep 29, 2017

@julienschmidt julienschmidt added the bug label Sep 29, 2017

@julienschmidt julienschmidt self-assigned this Sep 29, 2017

@julienschmidt julienschmidt added this to the v1.4 milestone Sep 29, 2017

julienschmidt added a commit that referenced this issue Sep 29, 2017

Remove strict mode
Fixes #556 #602 #635
Closes #609

@julienschmidt julienschmidt referenced this issue Sep 29, 2017

Merged

Remove strict mode #676

5 of 5 tasks complete
@BhavaniShankarReddy

This comment has been minimized.

Copy link

BhavaniShankarReddy commented May 29, 2018

I solve this issue by commenting on the values of wait_timeout, interactive_timeout, connect_timeout on my mysql.sock. My warning message is stopped after commenting this lines.
By default, wait_time and interactive_timeout will be 28800, when installing MySQL 5.7 in my production server, MySQL added this lines, after commenting this 3 lines it worked without showing a warning message:
"
[Note] Aborted connection to db: '-----' user: '----' host: 'localhost' (Got timeout reading communication packets)"

@dorinionescu

This comment has been minimized.

Copy link

dorinionescu commented Sep 6, 2018

Same error with a java connection from Eclipse to MySql 5.7 on windows 10.
I found the mysql57 service down and I have to restart it manually
After 2 hours of working it stops again
2018-09-06T12:22:59.135348Z 62 [Note] Aborted connection 62 to db: 'compute_pin_teh' user: 'compute_pin_teh' host: 'localhost' (Got an error reading communication packets) 2018-09-06T12:22:59.145322Z 63 [Note] Aborted connection 63 to db: 'compute_pin_teh' user: 'compute_pin_teh' host: 'localhost' (Got an error reading communication packets) 2018-09-06T12:23:18.526921Z 65 [ERROR] InnoDB: Operating system error number 21 in a file operation. 2018-09-06T12:23:18.527918Z 65 [Note] InnoDB: Some operating system error numbers are described at http://dev.mysql.com/doc/refman/5.7/en/operating-system-error-codes.html 2018-09-06T12:23:18.527918Z 65 [ERROR] InnoDB: File f:\mysql\tables\compute_pin_teh\photo_resell.ibd: 'Windows aio' returned OS error 121. Cannot continue operation 2018-09-06T12:23:18.528914Z 65 [ERROR] InnoDB: Cannot continue operation. 2018-09-06T12:23:20.924476Z 0 [Note] InnoDB: FTS optimize thread exiting. 2018-09-06T12:24:59.184704Z 65 [Warning] InnoDB: 13 threads created by InnoDB had not exited at shutdown!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment