Bug #86115 Reconnect to the previous schema when connection is lost
Submitted: 27 Apr 2017 16:18 Modified: 22 Feb 2018 15:30
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Shell General / Core Client Severity:S3 (Non-critical)
Version:1.0.9 OS:Any
Assigned to: CPU Architecture:Any

[27 Apr 2017 16:18] Daniël van Eeden
Description:
With mysql:
mysql [localhost] {msandbox} (performance_schema) > select *, @@global.innodb_io_capacity from variables_info where variable_name='innodb_io_capacity'\G
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    5
Current database: performance_schema

*************************** 1. row ***************************
              VARIABLE_NAME: innodb_io_capacity
            VARIABLE_SOURCE: COMPILED
              VARIABLE_PATH: 
                  MIN_VALUE: 100
                  MAX_VALUE: 18446744073709551615
                   SET_TIME: 2017-04-27 09:11:58
                   SET_USER: 
                   SET_HOST: 
@@global.innodb_io_capacity: 123
1 row in set (0.17 sec)

With mysqlsh:
mysql-sql> select *, @@global.innodb_io_capacity from variables_info where variable_name='innodb_io_capacity'\G
ERROR: 5166: MySQL server has gone away
The global session got disconnected.
Attempting to reconnect to 'msandbox@localhost:33060'..
The global session was successfully reconnected.
mysql-sql> select *, @@global.innodb_io_capacity from variables_info where variable_name='innodb_io_capacity'\G
ERROR: 1046: No database selected

No actually executing the query after reconnect might be a good decision (e.g. when sql_log_bin session variable is reset). But it would be nice if it could reconnect to the schema it was connected to before. Not sure if this is a bug or feature request.

How to repeat:
See description
[27 Apr 2017 18:08] Daniël van Eeden
Happens with both 'use <schema>' and '\use <schema>'
[28 Apr 2017 12:23] MySQL Verification Team
Hello Daniël,

Thank you for the report.
Verified as described.

Thanks,
Umesh
[22 Feb 2018 15:30] Margaret Fisher
Posted by developer:
 
Changelog entry added for 8.0.5:

In the event of a disconnection, MySQL Shell did not reconnect to the schema that was in use before the connection was lost. The last active schema set by the user is now restored during the automatic reconnection process, and during a manually triggered reconnection using the \reconnect command.