Moodle 3.10 wrongly identifies MariaDB version...

Moodle 3.10 wrongly identifies MariaDB version...

by Peter Eliyahu Kornfeld -
Number of replies: 16
Picture of Core developers Picture of Plugin developers

Hi,

I'm trying to install Moodle on Azure resources.

I have my MariaDB and an App Service running PHP...

When going with the installation process Moodle informs me that the MariaDB version is not correct and stops...

databasemariadb (5.6.47.0)

Azure states that the DB is version 10.3, and when connecting from MySQL Workbench it reports version 10.3.23...

Average of ratings: -
In reply to Peter Eliyahu Kornfeld

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Peter Eliyahu Kornfeld -
Picture of Core developers Picture of Plugin developers
While checking via HeidiSQL (that too reports version 10.3.23) I saw, that one of the previous steps DID create the database on the server... So it seems as a bug with the version identification...
In reply to Peter Eliyahu Kornfeld

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

I've tried a couple of tests for this and the only explanation I can suggest is that Moodle really is connecting to a MySQL instance. Otherwise where is "5.6.47.0" coming from? 5.6.47 really is a MySQL version and surely neither MariaDB nor Moodle are inadvertently obtaining this. That said, the version HeidiSQL reports would contradict this conclusion.

During install the MariaDB version is read from the server_info property in the PHP MySQLi extension. On my server server_info is "5.5.5-10.3.22-MariaDB", lib/dml/mariadb_native_moodle_database.php:mariadb_native_moodle_database->get_server_info() then uses a regex to extract the 10.3.22 part.

You could use a small PHP script to see the version the MySQLi extension is reporting, use your Moodle site's $CFG->dbhost, $CFG->dbuser and $CFG->dbpass for the three parameters passed to new mysqli(…):

<?php
$mysqli = new mysqli("<your_dbhost>, "<your_dbuser>", "<your_dbpass>");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

/* print server version */
printf("Server version: %s\n", $mysqli->server_info);

/* close connection */
$mysqli->close();

In reply to Peter Eliyahu Kornfeld

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

I should also ask which operating system the Moodle web server and database server are running on? I've seen a comment saying the version information is reported differently on Microsoft Windows but I've just tried it and it appears to the the same format as Linux, "5.5.5-10.3.27-MariaDB" in my test.

In reply to Leon Stringer

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Peter Eliyahu Kornfeld -
Picture of Core developers Picture of Plugin developers
Thank you for your response...

First some info about the MOODLE server... I checked on different OSes
1. Local Ubuntu
2. Local Windows 10
3. Web service on AZURE (Ubuntu also) - this should be the final...

I tried your small snippet and it returns: Server version: 5.6.47.0
Shouldn't we use some more mariadb related object instead of mysqli?

As for your thoughts about actually connecting mysql - I have no mysql on my AZURE account... Have some MS SQL and this new mariadb...
These links may help:
https://rashim-moodle.azurewebsites.net/phpinfo.php
https://rashim-moodle.azurewebsites.net/db_check.php
In reply to Peter Eliyahu Kornfeld

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Peter Eliyahu Kornfeld -
Picture of Core developers Picture of Plugin developers
Just out of curiosity, changed the dbtype in the config to mysqli (without actually changing the db of course) and now it is ready to go on as the version fits...
```
database mysql (5.6.47.0) version 5.6 is required and you are running 5.6.47.0 OK
```
Wonder if it would work that way...
In reply to Peter Eliyahu Kornfeld

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Peter Eliyahu Kornfeld -
Picture of Core developers Picture of Plugin developers
One more check - I also tried MOODLE 3.9 and had the same issues...
It is something with the combination of AZURE hosted MariaDB and MOODLE...
In reply to Peter Eliyahu Kornfeld

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Peter Eliyahu Kornfeld -
Picture of Core developers Picture of Plugin developers
Sorry, but my boss told we have no time to wait to figure out what's wrong with the MariaDB and I move over to MySQL... Which works without problems on the SQL part at least...
In reply to Peter Eliyahu Kornfeld

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

I tried your small snippet and it returns: Server version: 5.6.47.0

…changed the dbtype in the config to mysqli (without actually changing the db of course) and now it is ready to go…

The above strengthens my thinking that this is a MySQL – not MariaDB – database. The version reported by the snippet will end -MariaDB for MariaDB but show a number only for MySQL. There isn't a 5.6.47.0 version of MariaDB, it went from 5.5.x to 10.0.x.

Moodle reads the version that the database is reporting to PHP, it's not a problem in Moodle. Because this is a strange problem I would start consider edge cases, e.g. the database instance is containerised and the instance being connected to isn't the one expected. Or that this MariaDB has been modified to report its version differently. Using the command line shell or checking the database logs may help get to the bottom of this. Maybe there'll be time for this in the future.

Shouldn't we use some more mariadb related object instead of mysqli?

There is only MySQLi in PHP, this is used to connect to both MySQL and MariaDB databases.

In reply to Leon Stringer

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Peter Eliyahu Kornfeld -
Picture of Core developers Picture of Plugin developers
It seems that the MariaDB in Azure is fishy...
I opened a issue about it on Azure , hope for an answer (a rare thing to happen)...
In any case, a huge Thank you for your time!!!
In reply to Peter Eliyahu Kornfeld

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Ken Task -
Picture of Particularly helpful Moodlers

Pardon ... difference ... Azure is your virtualization.  It host a Ubuntu linux which should be running a distro for Azure .. not other Ubuntu generic distro's.

To make things more confusing - PHP - the php folks, any distro, don't have a driver for mariadb ... matter of fact, MariaDB began it's life by a former employee of MySQL ... who is now owned by Oracle.  Fear of Oracle pulling the plug on MySQL has led many linux distro's to 'favor' MariaDB.  So the php driver is really the same one as for MySQL ... that's why setting moodle to use mysqli works. 

In your ubuntu, one can see this claimed drop in replacement by the command line utilities for MariaDB ... like to make a dump of your database for moodle ... will use mysqldump command.

There is no mariadbdump command.   The command to connect to the mariadb server is mysql.

Ubuntu itself now has a special distro for running under Azure.

So going Azure route means 'special considerations' .... and I'll be so bold as to say not very many hosting providers offer Azure for customers.

So your comment ... "hope for an answer (a rare thing to happen)" is probably very accurate.

And, in going forward, community support forums (these forums) will have fewer folks who run your combo - choice of poison.

At any rate, you will have to concentrate your efforts *IN* the guest OS - Ubuntu ... and not necessarily in Azure alone!   Having said all that ...

https://ubuntu.com/azure

https://ubuntu.com/azure/pro

https://docs.microsoft.com/en-us/azure/virtual-machines/linux/endorsed-distros

Good luck going forward! smile

'SoS', Ken



In reply to Ken Task

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Peter Eliyahu Kornfeld -
Picture of Core developers Picture of Plugin developers
It is obvious that the problem is only when the DB hosted on AZURE...
I just realized that event for the new MySQL 5.7.29, MOODLE gets version 5.6.47 (which passes only by chance)...
The interesting thing is that other applications are returning the right version... So, even AZURE holds a lot of special issues itself it is still seems to be a problem of MOODLE (PHP?)
In reply to Peter Eliyahu Kornfeld

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Peter Eliyahu Kornfeld -
Picture of Core developers Picture of Plugin developers
Checking via cloud-shell (using bash) these are the answers:
Linux cc-d6e9ef83-c9656f79d-zk88j 4.15.0-1100-azure #111~16.04.1-Ubuntu SMP Thu Nov 19 06:49:21 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
mysql Ver 14.14 Distrib 5.7.30, for Linux (x86_64) using EditLine wrapper
In reply to Peter Eliyahu Kornfeld

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

That second line looks like it's reporting the version of the database shell client which may be different to the database server. If you use this client to connect to the database server using the connection details – $CFG->dbhost, $CFG->dbname and $CFG->dbpass – from config.php, e.g.:

$ mysql -u your_dbuser -p -h your_dbhost

You should be prompted for the password and then connect. You should then see version information, e.g. for MariaDB:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4158
Server version: 10.3.22-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> 

Or for MySQL:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.30 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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>
In reply to Leon Stringer

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Peter Eliyahu Kornfeld -
Picture of Core developers Picture of Plugin developers
On server the MySQL/MariaDB version is correct... Only via PHP's mysqli it comes out wrong...
In reply to Peter Eliyahu Kornfeld

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Peter Eliyahu Kornfeld -
Picture of Core developers Picture of Plugin developers
Current known issues
MySQL server instance displays the wrong server version after connection is established. To get the correct server instance engine version, use the select version(); command.
Average of ratings: Useful (1)
In reply to Peter Eliyahu Kornfeld

Re: Moodle 3.10 wrongly identifies MariaDB version...

by Peter Eliyahu Kornfeld -
Picture of Core developers Picture of Plugin developers
For all who has the same problem...

First of all - I found that it is a Azure related problem...
https://docs.microsoft.com/en-us/azure/mysql/concepts-limits

Current known issues
MySQL server instance displays the wrong server version after connection is established. To get the correct server instance engine version, use the select version(); command.

And finally to resolve it I changed the get_server_info method in lib/dml/mysqli_native_moodle_database.php to look like this:

public function get_server_info() { 

    $res = $this->mysqli->query("SELECT VERSION() AS VERSION;"); 

    $res->data_seek(0); 

    $data = $res->fetch_array(); 

    return array('description'=>$data["VERSION"], 'version'=>$data["VERSION"]); 

}

Average of ratings: Useful (3)