Bug #92918 MySQL checker on 8.0.13 seems to give a useless error
Submitted: 24 Oct 2018 6:15 Modified: 2 Sep 2019 13:35
Reporter: Simon Mudd (OCA) Email Updates:
Status: Won't fix Impact on me:
None 
Category:Shell Upgrade Checker Severity:S3 (Non-critical)
Version:8.0.13 OS:MacOS
Assigned to: CPU Architecture:Any

[24 Oct 2018 6:15] Simon Mudd
Description:
MySQL upgrade checker gives unexpected error.

This looks broken. I recently installed the 8.0.13 package, and this is the 8.0.13 shell.

How to repeat:
$ mysqlsh --version
mysqlsh   Ver 8.0.13 for Darwin on x86_64 - for MySQL 8.0.13 (MySQL Community Server (GPL))
$ mysqlsh root:@localhost:3306 -e "util.checkForServerUpgrade();"
mysqlsh: [Warning] Using a password on the command line interface can be insecure.
The MySQL server at localhost:3306 will now be checked for compatibility issues for upgrade to MySQL 8.0.13...
MySQL version: 8.0.13 - MySQL Community Server - GPL
Util.checkForServerUpgrade: This tool supports MySQL server versions 5.7 to 8.0.12 (LogicError)
 at (command line):1:5
in util.checkForServerUpgrade();
        ^
$

Suggested fix:
This is the 8.0.13 shell so it should work and check against 8.0.X It should not care about 8.0.12 specifically. I suspect that there's code that expects a specific version and this does not make sense.

Do not provide a python stack trace or error. That's really unneeded. Just give an error and exit (if you want to give the error).

I'd sort of expect that the checker would say something like: " this version runs 8.0.13 and looks good and nothing needs doing" (as I guess it's expected to run against an _older_ version of MySQL but the current error makes no sense to me.
[24 Oct 2018 6:25] Simon Mudd
Given 8.0.13 incompatible changes it would be good to add an additional check  if using 8.0.X with X < 13:

Check for the following variables which are now changed, using something like:

SELECT VARIABLE_NAME FROM performance_schema.variables_info WHERE VARIABLE_SOURCE <> 'COMPILED' AND VARIABLE_NAME IN ('log_syslog_facility', 'log_syslog_include_pid', 'log_syslog_tag', 'log_syslog' )

and if present provide a hint to change the configuration setting to use the appropriate new variable name.
[24 Oct 2018 7:38] MySQL Verification Team
Hello Simon,

Thank you for the report and feedback.

regards,
Umesh
[2 Sep 2019 9:18] Konrad Olesinski
Posted by developer:
 
it is by design that Upgrade checker released in Shell version X checks only servers with older versions than X. We cannot check server version X, because we do not know what might change in version X+1 etc, so we cannot declare server "OK" for upgrade. User needs to get newer version of Shell to perform proper checking.

When it comes to error, it is printed with the stack trace because Upgrade checker is implemented as a function that throws exception when error occurs. But it can be used for example from command line where only error will be printed e.g.:

mysqlsh -- util check-for-server-upgrade root@localhost
[2 Sep 2019 13:35] Simon Mudd
Hi Konrad.

I think your comment about errors and the current behaviour is wrong. You're mixing 2 different types of errors: app errors and reporting to the user that there's "a problem".

The upgrade checker "worked" but found that it could not complete its task as the server version it was connected to was too new. That's fine. However, I really do not care, nor do I want to know which function call in python determined this. I just want to know the results of the check so output of the form

util.checkForServerUpgrade: This tool supports checking MySQL server versions 5.7 to 8.0.12. To check for an upgrade to a later version of MySQL use the same version of the MySQL shell as the server version to which you want to upgrade. (MySQLVersionTooNew)

I notice the error message and stack trace show "util" in different cases. Not sure which one is correct but given the mysql shell call used 'util....' I'd expect that to be correct. Inconsistent case looks odd.

I am not sure if the return exit code from the MySQL shell depends on the return status of this call and guess it might do. I guess that this should be handled slightly differently from a python error.
[2 Sep 2019 16:31] Konrad Olesinski
Posted by developer:
 
Hi Simon,

Actually error reporting around this changed slightly and now look like this, depending on Shell mode (JavaScript and Python):

mysql-js []> util.checkForServerUpgrade()
The MySQL server at localhost:33060, version 8.0.18-debug - Source
distribution, will now be checked for compatibility issues for upgrade to MySQL
8.0.18...
Util.checkForServerUpgrade: Detected MySQL server version is 8.0.18, but this tool supports server versions up to 8.0.17. You must upgrade MySQL Shell to the latest version to be able to check this server (LogicError)

mysql-py []> util.check_for_server_upgrade()
The MySQL server at localhost:33060, version 8.0.18-debug - Source
distribution, will now be checked for compatibility issues for upgrade to MySQL
8.0.18...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
SystemError: LogicError: Util.check_for_server_upgrade: Detected MySQL server version is 8.0.18, but this tool supports server versions up to 8.0.17. You must upgrade MySQL Shell to the latest version to be able to check this server

So if I understand correctly what you are saying, what you have problem with is the way Python Shell mode reports exceptions thrown inside Shell functions and if it were to look similar to JS mode it would be fine?

Exit code from mysqlsh depends on this exceptions to degree that it will 1 instead of 0 if any exception is thrown.
[2 Sep 2019 16:41] Konrad Olesinski
Posted by developer:
 
And one more thing, when used from command line with command line api integration, there are no confusing messages even in python mode:

./bin/mysqlsh --py -- util checkForServerUpgrade root@localhost
The MySQL server at localhost, version 8.0.18-debug - Source distribution, will
now be checked for compatibility issues for upgrade to MySQL 8.0.18...
ERROR: Util.checkForServerUpgrade: Detected MySQL server version is 8.0.18, but this tool supports server versions up to 8.0.17. You must upgrade MySQL Shell to the latest version to be able to check this server

Return code as I mentioned is 1.