Bug #103535 show warnings non empty after Lost connection to MySQL server during query.
Submitted: 29 Apr 2021 13:57 Modified: 30 Apr 2021 6:36
Reporter: Jean-François Gagné Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.7.34, 8.0.24 OS:Any
Assigned to: CPU Architecture:Any

[29 Apr 2021 13:57] Jean-François Gagné
Description:
Hi,

I was very surprised to have show warnings being non-empty after a Lost connection to MySQL server during query on one of my production server (see below).  At first, I thought these were leaked warnings from another thread reused by the thread-cache, but it ends-up this is more simple.

mysql> show warnings;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    _connection_id_
Current database: _removed_

+-------+------+--------------[...]------+
| Level | Code | Message      [...]      |
+-------+------+--------------[...]------+
[...]
+-------+------+--------------[...]------+
14 rows in set (0.00 sec)

I was able to trace this back to Bug#93607, but I am still opening this bug as the behavior of the mysql client is non-consistent when being launched and when a reconnection is happening.  See How to repeat for details.

Note that the How to repeat is with 8.0.24, but a similar behavior can be observed with 5.7.34.

Many thanks for looking into this,

Jean-François Gagné

How to repeat:
# Create a sandbox.
$ dbdeployer deploy single mysql_8.0.24

# Initialize the standbox.
$ ./use <<< "create database test_jfg; create table test_jfg.t(id int)"

# Connecting to the sandbox does not cause warnings.
$ ./use test_jfg
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.24 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql [localhost:8024] {msandbox} (test_jfg) > show warnings;
Empty set (0.00 sec)

# Killing the above session in another terminal.
$ ./use <<< "kill 10"

# And back in the killed session, we have warnings after the reconnection.
mysql [localhost:8024] {msandbox} (test_jfg) > show warnings;
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
Connection id:    12
Current database: test_jfg

+---------+------+------------------------------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                                                |
+---------+------+------------------------------------------------------------------------------------------------------------------------+
| Warning | 1287 | 'COM_FIELD_LIST' is deprecated and will be removed in a future release. Please use SHOW COLUMNS FROM statement instead |
+---------+------+------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Suggested fix:
It looks something is hiding warnings when starting the MySQL client.  The same should be done after a reconnection (and after the use command for fixing Bug#93607).
[30 Apr 2021 6:36] MySQL Verification Team
Hello Jean-François,

Thank you for the report and test case.
Verified as described.

regards,
Umesh