Bug #93197 MySQL logs error when performing TCP health checks
Submitted: 14 Nov 2018 19:34 Modified: 7 May 2019 9:30
Reporter: Daniele Lisi Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Connection Handling Severity:S3 (Non-critical)
Version:5.7.24 OS:Linux
Assigned to: CPU Architecture:x86
Tags: consul, health check, packets error, tcp

[14 Nov 2018 19:34] Daniele Lisi
Description:
In the latest version of MySQL 5.7.24, performing TCP health checks results in packet errors being logged in `error.log`.

I am using `consul` to perform service health checks on my database on port 3306. Since I updated to 5.7.24, my `error.log` gets flooded with `[Note] Got an error reading communication packets` every time `consul` performs the check (5s in this case).

I don't see this issue with previous version on MySQL. I tested it on 5.7.23 and 5.7.22

How to repeat:
This assume you can access the database via `127.0.0.1` on port `3306`. Error logsinn default path `/var/log/mysql/error.log`

1. Start `mysql` service
2. execute `nc -vz 127.0.0.1 3306`
3. Check your error logs at `/var/log/mysql/error.log` and you will see the message `Got an error reading communication packets` for every TCP connection issued by `nc`.

Suggested fix:
Reduce `log_error_verbosity` to 2 which discards `Note` logs.

SET GLOBAL log_error_verbosity=2;
[16 Nov 2018 16:51] MySQL Verification Team
Hi,

We do not have nor use that program named `consul`.

Hence, should the usage of `nc` be enough or not ???

Thanks in advance.
[16 Nov 2018 16:58] Daniele Lisi
Yes, 'nc' would be enough to reproduce the issue.
[19 Nov 2018 15:57] MySQL Verification Team
Hi,

Indeed, when I have run that `nc` command 100 times I got a plethora of :

8-11-19T15:55:03.493890Z 3 [Note] Got an error reading communication packets
2018-11-19T15:55:04.747845Z 4 [Note] Got an error reading communication packets
2018-11-19T15:55:06.217617Z 5 [Note] Got an error reading communication packets
2018-11-19T15:55:07.284145Z 6 [Note] Got an error reading communication packets
2018-11-19T15:55:09.131607Z 7 [Note] Got an error reading communication packets
2018-11-19T15:55:10.260825Z 8 [Note] Got an error reading communication packets
2018-11-19T15:55:11.292859Z 9 [Note] Got an error reading communication packets

Verified as reported.
[7 May 2019 9:30] Erlend Dahl
Posted by developer: Jens Even Blomsoy

Not sure we can fix this in any way.

Reason:
In this bug, we are passing -z option to Netcat, which means Netcat should
just scan for listening daemons, without sending any data to them. For every
connection, server tries to read packets from the connection during
handshake. In this case, we are not giving any data for the handshake to
pass. Server tries to read packets, there are no packets. Hence error. You
can actually verify this. Pass any other option to netcat which actually
sends data and send the data. The error wont be logged.
[7 May 2019 13:11] MySQL Verification Team
Erlend,

Thank you very much for your diagnosis.