We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
upgrade_check fails db version check
**Apache Airflow version**: 1.10.14 with AWS RDS mysql 5.7.26 as metastore db


**Kubernetes version (if you are using kubernetes)** (use `kubectl version`): v1.16.15

**Environment**: DEV

- **Cloud provider or hardware configuration**: AWS
- **OS** (e.g. from /etc/os-release): Debian GNU/Linux 10 (buster)
- **Kernel** (e.g. `uname -a`): Linux airflow-scheduler-765f664c56-4bsfq 4.14.186-146.268.amzn2.x86_64 #1 SMP Tue Jul 14 18:16:52 UTC 2020 x86_64 GNU/Linux
- **Install tools**: 
- **Others**: Running on K8S as docker container with apache/airflow:1.10.14 as base

**What happened**: Running `airflow upgrade_check` returns the following error:
```
airflow@airflow-web-54d6577c8b-g9vcn:/opt/airflow$ airflow upgrade_check

==================================================== STATUS ====================================================
Check for latest versions of apache-airflow and checker...............................................SUCCESS
Remove airflow.AirflowMacroPlugin class...............................................................SUCCESS
/home/airflow/.local/lib/python3.6/site-packages/airflow/utils/helpers.py:442: DeprecationWarning: Importing 'DummyOperator' directly from 'airflow.operators' has been deprecated. Please import from 'airflow.operators.[operator_module]' instead. Support for direct imports will be dropped entirely in Airflow 2.0.
  DeprecationWarning)
Ensure users are not using custom metaclasses in custom operators.....................................SUCCESS
Chain between DAG and operator not allowed............................................................SUCCESS
Connection.conn_type is not nullable..................................................................SUCCESS
Custom Executors now require full path................................................................SUCCESS
Traceback (most recent call last):
  File "/home/airflow/.local/bin/airflow", line 37, in <module>
    args.func(args)
  File "/home/airflow/.local/lib/python3.6/site-packages/airflow/upgrade/checker.py", line 118, in run
    all_problems = check_upgrade(formatter, rules)
  File "/home/airflow/.local/lib/python3.6/site-packages/airflow/upgrade/checker.py", line 38, in check_upgrade
    rule_status = RuleStatus.from_rule(rule)
  File "/home/airflow/.local/lib/python3.6/site-packages/airflow/upgrade/problem.py", line 44, in from_rule
    result = rule.check()
  File "/home/airflow/.local/lib/python3.6/site-packages/airflow/utils/db.py", line 74, in wrapper
    return func(*args, **kwargs)
  File "/home/airflow/.local/lib/python3.6/site-packages/airflow/upgrade/rules/postgres_mysql_sqlite_version_upgrade_check.py", line 56, in check
    installed_mysql_version = Version(session.execute('SELECT VERSION();').scalar())
  File "/home/airflow/.local/lib/python3.6/site-packages/packaging/version.py", line 298, in __init__
    raise InvalidVersion("Invalid version: '{0}'".format(version))
packaging.version.InvalidVersion: Invalid version: '5.7.26-log'
airflow@airflow-web-54d6577c8b-g9vcn:/opt/airflow$
```

**What you expected to happen**: commands runs through and prints helpful messages

<!-- What do you think went wrong? -->
Running `SELECT VERSION();').scalar()` against the metastore db returns "5.7.26-log' which is possibly not a valid value for Version class `__init__` function because of the "-log" ending?

```
mysql> select VERSION();
+------------+
| VERSION()  |
+------------+
| 5.7.26-log |
+------------+
1 row in set (0.00 sec)
```

**How to reproduce it**: Run `airflow upgrade_check` again.

**Anything else we need to know**: 
Dockerfile snippet:
```
FROM apache/airflow:1.10.14
...
USER ${AIRFLOW_UID}
RUN pip install --user \
    airflow-kubernetes-job-operator \
    apache-airflow-backport-providers-cncf-kubernetes \
    apache-airflow-backport-providers-ssh \
    apache-airflow-upgrade-check
```

How often does this problem occur? Once? Every time etc?: Every time since last week. Has worked before.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `airflow/upgrade/rules/postgres_mysql_sqlite_version_upgrade_check.py`
Content:
```
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements.  See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership.  The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License.  You may obtain a copy of the License at
8 #
9 #   http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied.  See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17 
18 from packaging.version import Version
19 
20 from airflow.configuration import conf
21 from airflow.upgrade.rules.base_rule import BaseRule
22 from airflow.utils.db import provide_session
23 
24 
25 class DatabaseVersionCheckRule(BaseRule):
26     title = "Check versions of PostgreSQL, MySQL, and SQLite to ease upgrade to Airflow 2.0"
27 
28     description = """\
29 From Airflow 2.0, the following database versions are supported:
30 PostgreSQl - 9.6, 10, 11, 12, 13;
31 MySQL - 5.7, 8;
32 SQLite - 3.15+
33     """
34 
35     @provide_session
36     def check(self, session=None):
37 
38         more_info = "See link below for more details: https://github.com/apache/airflow#requirements"
39 
40         conn_str = conf.get(section="core", key="sql_alchemy_conn")
41 
42         if "sqlite" in conn_str:
43             min_req_sqlite_version = Version('3.15')
44             installed_sqlite_version = Version(session.execute('select sqlite_version();').scalar())
45             if installed_sqlite_version < min_req_sqlite_version:
46                 return "From Airflow 2.0, SQLite version below 3.15 is no longer supported. \n" + more_info
47 
48         elif "postgres" in conn_str:
49             min_req_postgres_version = Version('9.6')
50             installed_postgres_version = Version(session.execute('SHOW server_version;').scalar())
51             if installed_postgres_version < min_req_postgres_version:
52                 return "From Airflow 2.0, PostgreSQL version below 9.6 is no longer supported. \n" + more_info
53 
54         elif "mysql" in conn_str:
55             min_req_mysql_version = Version('5.7')
56             installed_mysql_version = Version(session.execute('SELECT VERSION();').scalar())
57             if installed_mysql_version < min_req_mysql_version:
58                 return "From Airflow 2.0, MySQL version below 5.7 is no longer supported. \n" + more_info
59
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/airflow/upgrade/rules/postgres_mysql_sqlite_version_upgrade_check.py b/airflow/upgrade/rules/postgres_mysql_sqlite_version_upgrade_check.py
--- a/airflow/upgrade/rules/postgres_mysql_sqlite_version_upgrade_check.py
+++ b/airflow/upgrade/rules/postgres_mysql_sqlite_version_upgrade_check.py
@@ -43,16 +43,23 @@
             min_req_sqlite_version = Version('3.15')
             installed_sqlite_version = Version(session.execute('select sqlite_version();').scalar())
             if installed_sqlite_version < min_req_sqlite_version:
-                return "From Airflow 2.0, SQLite version below 3.15 is no longer supported. \n" + more_info
+                return "From Airflow 2.0, SQLite version below {} is no longer supported. \n{}".format(
+                    min_req_sqlite_version, more_info
+                )
 
         elif "postgres" in conn_str:
             min_req_postgres_version = Version('9.6')
             installed_postgres_version = Version(session.execute('SHOW server_version;').scalar())
             if installed_postgres_version < min_req_postgres_version:
-                return "From Airflow 2.0, PostgreSQL version below 9.6 is no longer supported. \n" + more_info
+                return "From Airflow 2.0, PostgreSQL version below {} is no longer supported. \n{}".format(
+                    min_req_postgres_version, more_info
+                )
 
         elif "mysql" in conn_str:
             min_req_mysql_version = Version('5.7')
-            installed_mysql_version = Version(session.execute('SELECT VERSION();').scalar())
+            # special treatment is needed here, because MySQL version may include a suffix like '-log'
+            installed_mysql_version = Version(session.execute('SELECT VERSION();').scalar().split('-')[0])
             if installed_mysql_version < min_req_mysql_version:
-                return "From Airflow 2.0, MySQL version below 5.7 is no longer supported. \n" + more_info
+                return "From Airflow 2.0, MySQL version below {} is no longer supported. \n{}".format(
+                    min_req_mysql_version, more_info
+                )

{"golden_diff": "diff --git a/airflow/upgrade/rules/postgres_mysql_sqlite_version_upgrade_check.py b/airflow/upgrade/rules/postgres_mysql_sqlite_version_upgrade_check.py\n--- a/airflow/upgrade/rules/postgres_mysql_sqlite_version_upgrade_check.py\n+++ b/airflow/upgrade/rules/postgres_mysql_sqlite_version_upgrade_check.py\n@@ -43,16 +43,23 @@\n             min_req_sqlite_version = Version('3.15')\n             installed_sqlite_version = Version(session.execute('select sqlite_version();').scalar())\n             if installed_sqlite_version < min_req_sqlite_version:\n-                return \"From Airflow 2.0, SQLite version below 3.15 is no longer supported. \\n\" + more_info\n+                return \"From Airflow 2.0, SQLite version below {} is no longer supported. \\n{}\".format(\n+                    min_req_sqlite_version, more_info\n+                )\n \n         elif \"postgres\" in conn_str:\n             min_req_postgres_version = Version('9.6')\n             installed_postgres_version = Version(session.execute('SHOW server_version;').scalar())\n             if installed_postgres_version < min_req_postgres_version:\n-                return \"From Airflow 2.0, PostgreSQL version below 9.6 is no longer supported. \\n\" + more_info\n+                return \"From Airflow 2.0, PostgreSQL version below {} is no longer supported. \\n{}\".format(\n+                    min_req_postgres_version, more_info\n+                )\n \n         elif \"mysql\" in conn_str:\n             min_req_mysql_version = Version('5.7')\n-            installed_mysql_version = Version(session.execute('SELECT VERSION();').scalar())\n+            # special treatment is needed here, because MySQL version may include a suffix like '-log'\n+            installed_mysql_version = Version(session.execute('SELECT VERSION();').scalar().split('-')[0])\n             if installed_mysql_version < min_req_mysql_version:\n-                return \"From Airflow 2.0, MySQL version below 5.7 is no longer supported. \\n\" + more_info\n+                return \"From Airflow 2.0, MySQL version below {} is no longer supported. \\n{}\".format(\n+                    min_req_mysql_version, more_info\n+                )\n", "issue": "upgrade_check fails db version check\n**Apache Airflow version**: 1.10.14 with AWS RDS mysql 5.7.26 as metastore db\r\n\r\n\r\n**Kubernetes version (if you are using kubernetes)** (use `kubectl version`): v1.16.15\r\n\r\n**Environment**: DEV\r\n\r\n- **Cloud provider or hardware configuration**: AWS\r\n- **OS** (e.g. from /etc/os-release): Debian GNU/Linux 10 (buster)\r\n- **Kernel** (e.g. `uname -a`): Linux airflow-scheduler-765f664c56-4bsfq 4.14.186-146.268.amzn2.x86_64 #1 SMP Tue Jul 14 18:16:52 UTC 2020 x86_64 GNU/Linux\r\n- **Install tools**: \r\n- **Others**: Running on K8S as docker container with apache/airflow:1.10.14 as base\r\n\r\n**What happened**: Running `airflow upgrade_check` returns the following error:\r\n```\r\nairflow@airflow-web-54d6577c8b-g9vcn:/opt/airflow$ airflow upgrade_check\r\n\r\n==================================================== STATUS ====================================================\r\nCheck for latest versions of apache-airflow and checker...............................................SUCCESS\r\nRemove airflow.AirflowMacroPlugin class...............................................................SUCCESS\r\n/home/airflow/.local/lib/python3.6/site-packages/airflow/utils/helpers.py:442: DeprecationWarning: Importing 'DummyOperator' directly from 'airflow.operators' has been deprecated. Please import from 'airflow.operators.[operator_module]' instead. Support for direct imports will be dropped entirely in Airflow 2.0.\r\n  DeprecationWarning)\r\nEnsure users are not using custom metaclasses in custom operators.....................................SUCCESS\r\nChain between DAG and operator not allowed............................................................SUCCESS\r\nConnection.conn_type is not nullable..................................................................SUCCESS\r\nCustom Executors now require full path................................................................SUCCESS\r\nTraceback (most recent call last):\r\n  File \"/home/airflow/.local/bin/airflow\", line 37, in <module>\r\n    args.func(args)\r\n  File \"/home/airflow/.local/lib/python3.6/site-packages/airflow/upgrade/checker.py\", line 118, in run\r\n    all_problems = check_upgrade(formatter, rules)\r\n  File \"/home/airflow/.local/lib/python3.6/site-packages/airflow/upgrade/checker.py\", line 38, in check_upgrade\r\n    rule_status = RuleStatus.from_rule(rule)\r\n  File \"/home/airflow/.local/lib/python3.6/site-packages/airflow/upgrade/problem.py\", line 44, in from_rule\r\n    result = rule.check()\r\n  File \"/home/airflow/.local/lib/python3.6/site-packages/airflow/utils/db.py\", line 74, in wrapper\r\n    return func(*args, **kwargs)\r\n  File \"/home/airflow/.local/lib/python3.6/site-packages/airflow/upgrade/rules/postgres_mysql_sqlite_version_upgrade_check.py\", line 56, in check\r\n    installed_mysql_version = Version(session.execute('SELECT VERSION();').scalar())\r\n  File \"/home/airflow/.local/lib/python3.6/site-packages/packaging/version.py\", line 298, in __init__\r\n    raise InvalidVersion(\"Invalid version: '{0}'\".format(version))\r\npackaging.version.InvalidVersion: Invalid version: '5.7.26-log'\r\nairflow@airflow-web-54d6577c8b-g9vcn:/opt/airflow$\r\n```\r\n\r\n**What you expected to happen**: commands runs through and prints helpful messages\r\n\r\n<!-- What do you think went wrong? -->\r\nRunning `SELECT VERSION();').scalar()` against the metastore db returns \"5.7.26-log' which is possibly not a valid value for Version class `__init__` function because of the \"-log\" ending?\r\n\r\n```\r\nmysql> select VERSION();\r\n+------------+\r\n| VERSION()  |\r\n+------------+\r\n| 5.7.26-log |\r\n+------------+\r\n1 row in set (0.00 sec)\r\n```\r\n\r\n**How to reproduce it**: Run `airflow upgrade_check` again.\r\n\r\n**Anything else we need to know**: \r\nDockerfile snippet:\r\n```\r\nFROM apache/airflow:1.10.14\r\n...\r\nUSER ${AIRFLOW_UID}\r\nRUN pip install --user \\\r\n    airflow-kubernetes-job-operator \\\r\n    apache-airflow-backport-providers-cncf-kubernetes \\\r\n    apache-airflow-backport-providers-ssh \\\r\n    apache-airflow-upgrade-check\r\n```\r\n\r\nHow often does this problem occur? Once? Every time etc?: Every time since last week. Has worked before.\r\n\n", "before_files": [{"content": "# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n\nfrom packaging.version import Version\n\nfrom airflow.configuration import conf\nfrom airflow.upgrade.rules.base_rule import BaseRule\nfrom airflow.utils.db import provide_session\n\n\nclass DatabaseVersionCheckRule(BaseRule):\n    title = \"Check versions of PostgreSQL, MySQL, and SQLite to ease upgrade to Airflow 2.0\"\n\n    description = \"\"\"\\\nFrom Airflow 2.0, the following database versions are supported:\nPostgreSQl - 9.6, 10, 11, 12, 13;\nMySQL - 5.7, 8;\nSQLite - 3.15+\n    \"\"\"\n\n    @provide_session\n    def check(self, session=None):\n\n        more_info = \"See link below for more details: https://github.com/apache/airflow#requirements\"\n\n        conn_str = conf.get(section=\"core\", key=\"sql_alchemy_conn\")\n\n        if \"sqlite\" in conn_str:\n            min_req_sqlite_version = Version('3.15')\n            installed_sqlite_version = Version(session.execute('select sqlite_version();').scalar())\n            if installed_sqlite_version < min_req_sqlite_version:\n                return \"From Airflow 2.0, SQLite version below 3.15 is no longer supported. \\n\" + more_info\n\n        elif \"postgres\" in conn_str:\n            min_req_postgres_version = Version('9.6')\n            installed_postgres_version = Version(session.execute('SHOW server_version;').scalar())\n            if installed_postgres_version < min_req_postgres_version:\n                return \"From Airflow 2.0, PostgreSQL version below 9.6 is no longer supported. \\n\" + more_info\n\n        elif \"mysql\" in conn_str:\n            min_req_mysql_version = Version('5.7')\n            installed_mysql_version = Version(session.execute('SELECT VERSION();').scalar())\n            if installed_mysql_version < min_req_mysql_version:\n                return \"From Airflow 2.0, MySQL version below 5.7 is no longer supported. \\n\" + more_info\n", "path": "airflow/upgrade/rules/postgres_mysql_sqlite_version_upgrade_check.py"}], "after_files": [{"content": "# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n\nfrom packaging.version import Version\n\nfrom airflow.configuration import conf\nfrom airflow.upgrade.rules.base_rule import BaseRule\nfrom airflow.utils.db import provide_session\n\n\nclass DatabaseVersionCheckRule(BaseRule):\n    title = \"Check versions of PostgreSQL, MySQL, and SQLite to ease upgrade to Airflow 2.0\"\n\n    description = \"\"\"\\\nFrom Airflow 2.0, the following database versions are supported:\nPostgreSQl - 9.6, 10, 11, 12, 13;\nMySQL - 5.7, 8;\nSQLite - 3.15+\n    \"\"\"\n\n    @provide_session\n    def check(self, session=None):\n\n        more_info = \"See link below for more details: https://github.com/apache/airflow#requirements\"\n\n        conn_str = conf.get(section=\"core\", key=\"sql_alchemy_conn\")\n\n        if \"sqlite\" in conn_str:\n            min_req_sqlite_version = Version('3.15')\n            installed_sqlite_version = Version(session.execute('select sqlite_version();').scalar())\n            if installed_sqlite_version < min_req_sqlite_version:\n                return \"From Airflow 2.0, SQLite version below {} is no longer supported. \\n{}\".format(\n                    min_req_sqlite_version, more_info\n                )\n\n        elif \"postgres\" in conn_str:\n            min_req_postgres_version = Version('9.6')\n            installed_postgres_version = Version(session.execute('SHOW server_version;').scalar())\n            if installed_postgres_version < min_req_postgres_version:\n                return \"From Airflow 2.0, PostgreSQL version below {} is no longer supported. \\n{}\".format(\n                    min_req_postgres_version, more_info\n                )\n\n        elif \"mysql\" in conn_str:\n            min_req_mysql_version = Version('5.7')\n            # special treatment is needed here, because MySQL version may include a suffix like '-log'\n            installed_mysql_version = Version(session.execute('SELECT VERSION();').scalar().split('-')[0])\n            if installed_mysql_version < min_req_mysql_version:\n                return \"From Airflow 2.0, MySQL version below {} is no longer supported. \\n{}\".format(\n                    min_req_mysql_version, more_info\n                )\n", "path": "airflow/upgrade/rules/postgres_mysql_sqlite_version_upgrade_check.py"}]}