Page MenuHomePhabricator

MediaWiki 1.41 misidentifies SQL server type and version when a gateway is in use
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Use Azure hosted MariaDB service for MediaWiki

What happens?:

  • Updater fails with MySQL 5.7.0 or later is required. You have 5.6.47.0.
  • Special:Version gives wrong information: MySQL 5.6.47.0

What should have happened instead?:

  • Give correct information: MariaDB 10.3.23

Software version (skip for WMF-hosted wikis like Wikipedia):

1.41 (it used to work on 1.40)

Other information (browser name/version, screenshots, etc.):

https://learn.microsoft.com/en-us/azure/mysql/single-server/concepts-connect-to-a-gateway-node describes that there is a gateway client. MediaWiki is picking up the gateway's version instead of the real version.

Event Timeline

Reedy subscribed.

rMWa4da386e6a8a: installer: Check MariaDB version in updater/installer was new in 1.41 for T237898: Add MariaDB version check in wikimedia/rdbms (separate from MySQL) . Not guaranteed to be at fault, but seems possibly related.

What is the full string your setup gives for SELECT VERSION(); or similar?

It wouldn't surprise me if the checking now looking for MariaDB is giving a false positive or something here..

	public static function meetsMinimumRequirement( IDatabase $conn ) {
		$type = str_contains( $conn->getSoftwareLink(), 'MariaDB' ) ? 'MariaDB' : 'MySQL';
		self::$minimumVersion = self::MIN_VERSIONS[$type];
		// Used messages: config-mysql-old, config-mariadb-old
		self::$notMinimumVersionMessage = 'config-' . strtolower( $type ) . '-old';
		return parent::meetsMinimumRequirement( $conn );
	}
$ php /data/mediawiki/workdir/maintenance/mysql.php 

*******************************************************************************
NOTE: Do not run maintenance scripts directly, use maintenance/run.php instead!
      Running scripts directly has been deprecated in MediaWiki 1.40.
      It may not work for some (or any) scripts in the future.
*******************************************************************************

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 63409
Server version: 5.6.47.0 MariaDB Server

Copyright (c) 2000, 2024, 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> select @@version;
+---------------------+
| @@version           |
+---------------------+
| 10.3.23-MariaDB-log |
+---------------------+
1 row in set (0.00 sec)

mysql> select version();
+---------------------+
| version()           |
+---------------------+
| 10.3.23-MariaDB-log |
+---------------------+
1 row in set (0.00 sec)

https://gerrit.wikimedia.org/r/q/Ie4853e90a7c8ea655feff2b7bd6402d587c08d50 was backported to older releases, so I think if that would have been the cause, I would have noticed it on an earlier version.

So rMWebadcf1cca74: rdbms: Avoid making a db query when getting MySQL/MariaDB version seems possibly relevant then, as it wasn't backported.

Per the extended commit message

To get the version, you don't actually need to call "SELECT VERSION()"

The PDO provides that value for free and from reading the source code,
It's provided during the handshake:
https://github.com/php/php-src/blob/cb927e0fc043cb454ee58b7485cbce191df5d512/ext/mysqlnd/mysqlnd.h#L136

Which would explain the behaviour, as Server version: 5.6.47.0 MariaDB Server is in the connection header you posted.

If the proxy is returning a different version and still calling it "Server version"... Is this necessarily a MW bug? Is the proxy supposed to be changing that version? I could understand it if it was inserting its own prefix/suffix, or even a "Proxy version"... Or is the MySQL client somewhere picking that up incorrectly from some header it is presented with?

https://learn.microsoft.com/en-us/azure/mysql/single-server/concepts-connect-to-a-gateway-node

In the Single Server deployment option, a gateway is used to redirect the connections to server instances. After the connection is established, the MySQL client displays the version of MySQL set in the gateway, not the actual version running on your MySQL server instance. To determine the version of your MySQL server instance, use the SELECT VERSION(); command at the MySQL prompt.

It's working as MS intends, sure..

As Azure Database for MySQL supports major version v5.7 and v8.0, the default port 3306 to connect to Azure Database for MySQL runs MySQL client version 5.6 (least common denominator) to support connections to servers of all 2 supported major versions. However, if your application has a requirement to connect to specific major version say v5.7 or v8.0, you can do so by changing the port in your server connection string.

In Azure Database for MySQL Service, gateway nodes listens on port 3308 for v5.7 clients and port 3309 for v8.0 clients. In other words, if you would like to connect to v5.7 gateway client, you should use your fully qualified server name and port 3308 to connect to your server from client application. Similarly, if you would like to connect to v8.0 gateway client, you can use your fully qualified server name and port 3309 to connect to your server. Check the following example for further clarity.

I’ve an idea for a fallback/partial revert. Will post a patch later

  NODES
HOME 1
Idea 1
idea 1
Note 2
os 11
server 19
web 2