Skip to content

Conversation

@grooverdan
Copy link
Contributor

MariaDB versioning created a mess with regarding testing
features based on version. We sidestep the problem here
by assuming the extensions are present, and if a syntax
error occurs with a SQL mode TRANS_START_READ_WRITE |
TRANS_START_READ_ONLY enabled, then output the same
warning as before.

Test MDEV-23141.php

?php

$db = new mysqli("localhost", "root", "", "test");
$db->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);

$v = $db->server_version;
print "server version $v\n";

$db = new mysqli("127.0.0.1", "dan", "bob", "test", 3306);
$db->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);

$v = $db->server_version;
print "server version $v\n";

Test with dbdeployer mysql-5.5.62 on /tmp/mysql_sandbox5562.sock and MariaDB-10.4.13 (fc32 package) on 3306.

./configure --enable-debug --with-mysqli=mysqlnd --with-mysql-sock=/tmp/mysql_sandbox5562.sock
..

$ ./sapi/cli/php  ../MDEV-23141.php
Warning: mysqli::begin_transaction(): This server version doesn't support 'READ WRITE' and 'READ ONLY'. Minimum 5.6.5 is required in /home/dan/repos/MDEV-23141.php on line 5
server version 50562
server version 100413
$ make distclean
$ ./configure --enable-debug --with-mysqli --with-mysql-sock=/tmp/mysql_sandbox5562.sock

checking whether to enable mysqlnd... no
checking whether to disable compressed protocol support in mysqlnd... yes.
..
$ ./sapi/cli/php  ../MDEV-23141.php

Warning: mysqli::begin_transaction(): This server version doesn't support 'READ WRITE' and 'READ ONLY'. Minimum 5.6.5 is required in /home/dan/repos/MDEV-23141.php on line 5
server version 50562
server version 100413

So successfully starts a transaction on MariaDb-10.4 and generates the same warning on MySQL-5.5.62

@grooverdan
Copy link
Contributor Author

Hi, can I get a review of this PR please.

@cmb69
Copy link
Member

cmb69 commented Aug 21, 2020

MariaDB versioning created a mess with regarding testing features based on version.

Well, testing for featured based on version is generally not the best solution, in my opinion. Your changes look plausible to me, but I'm not really an mysqli expert, and wouldn't be able to test with any libmysql-client (I'm working on Windows).

Anyhow, I wonder whether that bug hasn't been fixed already; while Andrey closed the ticket as WONTFIX, and said he'd going to revert my commit, he apparently did not. :/

@grooverdan
Copy link
Contributor Author

Thanks for the endorsement. There is a libmysql-client for Windows.

I tested it a bit more and it looks still to be fixed without this (I've asked the original reporter to explain https://jira.mariadb.org/browse/MDEV-23141 to check). Maybe its in mysqli rather than mysqlnd? The 5.5.5 hack is still in the mariadb code base. The only other php ext uses of mysql_get_server_version are against a 5.0 version.

Well at least this alternate code is here if a revert gets decided upon.

@cmb69
Copy link
Member

cmb69 commented Aug 22, 2020

Thanks for the link to the Windows libmysql-client; the other part of the problem is, however, that there isn't any support for building against libmysql-client for Windows. I may have a look at this sometime.

Well at least this alternate code is here if a revert gets decided upon.

I'm not happy with the version hack in PHP myself. And even without the need for any hack, version comparisons won't really work anymore due to having different systems with individual versioning now.

Anyhow, @andreyhristov, what do you think? Should we still remove the MariaDB version detection hack? Or keep it, but apply this PR anyway?

@andreyhristov
Copy link

Hi,
I never really liked the hack and was against it being incorporated but it was incorporated. mysqlnd is a library for the MySQL C/S protocol and the reference implementation is in MySQL / libmysql. If MariaDB needs to hack this, they are free to write a mysqlnd plugin that make the needed changes and distribute it from PECL or some other channel.

@cmb69
Copy link
Member

cmb69 commented Aug 28, 2020

I don't like that version hack either, and I'm not against moving it to a PECL hosted mysqlnd plugin. However, even if we do so, version checks can't really work in the long run, since MariaDB apparently does not conform to MySQL versioning, so we either should replace the version checks with more general feature detection (or in this case, as done in this PR), or we should document that mysqlnd doesn't fully support MariaDB.

@grooverdan
Copy link
Contributor Author

Hi,

I regret the revisited trauma of mentioning this versioning trauma again. I don't think anyone saw it as a good solution, only one needed for MariaDB to maintain/claim some replication compatibility with MySQL.

I've managed to reproduce the original problem identified by bug reporter in MDEV-23141 by compiling php against the minimal tarball of mysql with ./configure --enable-debug --with-mysqli=/usr/local/mysql-8.0.21-linux-glibc2.17-x86_64-minimal/bin/mysql_config --with-pdo-mysql=/usr/local/mysql-8.0.21-linux-glibc2.17-x86_64-minimal/ --with-mysql-sock=/tmp/s.sock) (along with a few php mysqli patches needed avoid compiling against the server interfaces(I'll clean these up and submit them separately)).

As such, only the mysqli section of this PR is needed to expose the transaction capabilities of MariaDB and the mysqlnd changes are unnecessary (though they look good from a consistency point of view and are covered by existing test cases, you're call however, I'm happy to remove the mysqlnd changes).

To ensure that no regressions are caused by MariaDB server against the current php mysqli/mysqlnd drivers I've started this project to integrate into the mariadb.org bb system such that server incompatibilities get detected pre-release and the php project doesn't get asked to account for MariaDB differences. Regardless if we need to produce our own plugin/PECL maintaining existing compatibility for our common user base is a good first goal.

Please hold off on merging this for now, I'm pretty sure its right but won't know until mysqli corrections have been made more reliable (SEGV in mysql_server_end that needs to be corrected/avoided).

@andreyhristov
Copy link

andreyhristov commented Aug 29, 2020 via email

@grooverdan
Copy link
Contributor Author

Or maybe MariaDB should stop advertising as drop-in replacement :) Andrey

I totally agree and the removal of that now obsolete, incorrect, byline has been going on for a while. Still a few places to remove it from however.

MariaDB versioning created a mess with regarding testing
features based on version. We sidestep the problem here
by assuming the extensions are present, and if a syntax
error occurs with a SQL mode TRANS_START_READ_WRITE |
TRANS_START_READ_ONLY enabled, then output the same
warning as before.
@grooverdan grooverdan force-pushed the 7.3-bug-78179-mariadb-version-start-transaction branch from 794c05f to 113b691 Compare September 17, 2020 20:14
@grooverdan
Copy link
Contributor Author

with #6126 merged, thanks @nikic, there's now a more functional mysqli native client implementation to work this on.

After a rebase just pushed, testing against MySQL-5.6, 5.7 and 8.0 do pass the mysqli_begin_transaction.phpt test exercised by this change - https://travis-ci.org/github/grooverdan/php-src/builds/728129550

The mysqlnd also passes this test, though as mentioned earlier, the mysqlnd changes in this PR aren't strictly necessary, though it does add to a consistent implementation.

With MySQL-5.5 ending its extended support 18 months ago, those that run supportable systems will already be running on a server that supports TRANS_START_READ_{ONLY|WRITE}. Those running older versions won't be intentionally hitting this error message. So we're reducing a server version check from the processing chain for the majority of users.

Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me, thanks!

@nikic
Copy link
Member

nikic commented Sep 18, 2020

Merged as 740f0f6.

@nikic nikic closed this Sep 18, 2020
@grooverdan
Copy link
Contributor Author

Thanks @nikic

@grooverdan grooverdan deleted the 7.3-bug-78179-mariadb-version-start-transaction branch September 24, 2020 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants