Problem/Motivation

FATAL Error on database requirements on status report
With MySQL 8.0.2-dmr the requirements will request transaction_isolation from the session, while that is introduced in 8.0.3. Requesting tx_isolation resolves the issue.

Steps to reproduce

Request status report from admin having MySQL 8.0.2-dmr

Proposed resolution

Set 8.0.2 on line 29 of ./core/modules/mysql/mysql.install

Remaining tasks

Possibly a refactor:
`show session variables like '%_isolation`
Will give the variables and value. Use 'transaction_isolation' when set, use 'tx_isolation' when set. Provide requirement error based results. Mention isolation is not set when neither variables are available.

User interface changes

Now status report works as expected

API changes

NA

Data model changes

NA

Release notes snippet

NA

Issue fork drupal-3311474

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mmjvb created an issue. See original summary.

immaculatexavier made their first commit to this issue’s fork.

immaculatexavier’s picture

Status: Active » Needs review

Committed with MR in accordance to the proposed resolution

cilefen’s picture

Title: FATAL Error on database requirements on status report » The requirements test for transaction_isolation checks against a wrong version
mmjvb’s picture

Issue summary: View changes

As the change in the title loses the context, added it to the description of the problem. Hope users still find when searching for the symptom, not knowing the cause of it.

@immaculatexavier thanks for the MR, exactly what I was l was looking for.
Suspect I am not allowed to RTBC, otherwise I would.

Added possible refactor.

mmjvb’s picture

For testing you need several versions of MySQL, 8.0.0, 8.0.1, 8.0.2 and 8.0.3

You can use any version of D10 up till and including beta1. You shouldn't need dev of 10.0 or 10.1.

To test you only request the status report. Getting the report is prove it works. The message about the isolation is irrelevant. So, no need for different values. The variable names are the matter of the issue.

The proposed refactor would deal with multiple settings, preferring 'transaction_isolation'.

mmjvb’s picture

Confirm the change is correct for 8.0.0,8.0.1,8.0.2 and 8.0.3.

Faked MySQL versions by adjusting line 276 of core/modules/mysql/src/Driver/Database/mysql/Connection.php returning hardcoded values. Obviously, 8.0.3 resulted in WSOD as no transaction_isolation variable exist in 8.0.2-dmr.

cilefen’s picture

Priority: Minor » Major

A WSOD is major.

mmjvb’s picture

Considered it minor as these MySQL versions are from 2017. Currently GA 8.0.30 (2022-07-26)
See https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-30.html

daffie’s picture

@mmjvb: Do you have a link to the documentation where we ca check your finding?

mmjvb’s picture

daffie’s picture

Status: Needs review » Needs work

I am somehow not able to add a reply on the Mr, so I will do it here. Could we add a comment that "tx_transaction" was removed in MySQL 8.0.3 and add the link to the page https://dev.mysql.com/doc/refman/8.0/en/added-deprecated-removed.html. So that we know why this specific version of MySQL was used here.

@mmjvb: Thanks. Good find!

daffie’s picture

Issue tags: +Needs tests

We can add a unit test with a provider method to test for different versions of MySQL.

mmjvb’s picture

Would prefer the early stage approach as mentioned as refactor in Remaining tasks.

There is no need for conditionals on MySQL version:

    20	      $query = 'SHOW VARIABLES LIKE \'%_isolation\'';

    21	      $isolation_levels = $connection->query($query)->fetchAllKeyed();
    22	      $isolation_level = $isolation_levels['transaction_isolation'] ?? "";
    23	      if (empty($isolation_level)) {
    24		      $isolation_level = $isolation_levels['tx_isolation'] ?? "Not set";
    25	      }

When you insist on documentation suggest to add a line: Retrieve transaction_isolation with fallback on tx_isolation.

wim leers’s picture

Priority: Major » Critical
Issue tags: +9.5.0 update, +10.0.0 update
Related issues: +#2733675: Warning when mysql is not set to READ-COMMITTED

#2733675: Warning when mysql is not set to READ-COMMITTED introduced this, and that got committed to 9.5.x and 10.0.x.

This hence is a net regression in those two versions.

ravi.shankar made their first commit to this issue’s fork.

ravi.shankar’s picture

Made changes as per comment #13.

daffie’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs tests

I have tried to make a test for this issue, only I could not do it. The methods Drupal\Core\Database\Database::isActiveConnection() and Drupal\Core\Database\Database::getConnection() are used in the function to be tested and they are static and final. Which prevents them to be mocked in PHPUnit.
The current MR looks good to me.
The bugfix has a comment with why the fix is the specific version.
For me it is RTBC.

mmjvb’s picture

Status: Reviewed & tested by the community » Needs work

Provided the refactor in #15

longwave’s picture

@mmjvb what if MySQL (or MariaDB, etc) adds some other %_isolation variable in the future? I think checking the explicit ones that we know work with specific versions is probably better than looking for anything matching a pattern.

ravi.shankar’s picture

Status: Needs work » Needs review

Made changes as per suggestion on MR, please review.

mmjvb’s picture

@longwave That would be irrelevant, as you can read from the code it is checking for tx_isolation and transaction_isolation explicitly. Assuming transaction_isolation to be set, falling back to tx_isolation for the first three releases. The %_isolation is for getting these values and possibly others. In addition that way it is checking the run-time, not the theory/documentation.

Added benefit is that it is no longer MySQL specific.

mmjvb’s picture

Status: Needs review » Needs work
daffie’s picture

Status: Needs work » Reviewed & tested by the community

I am a bit worried that at some point a new database variable will be added with a name that ends with "_isolation". That will break Drupal. Therefor I agree with @longwave and we should do the current solution. Back to RTBC.

mmjvb’s picture

In that case, I can only hope you are going to be overruled by others. Hopefully, there are people that understand that your concern is ridiculous.

longwave’s picture

@mmjvb if you think it should be done a different way please provide a new patch or MR; but the patch as it stands solves the issue with the least amount of changes.

mmjvb’s picture

It is clear I am wasting my time here. Already provided the code, happily using it.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed e32f277a53 to 10.1.x and 09fa53817c to 10.0.x and 79b8681f31 to 9.5.x. Thanks!

Backported to 9.5.x as a critical bugfix.

I would note that MySQL 8.0.0, 8.0.1 and 8.0.2 are not truly supported. Mysql 8.0.3 was released in 2017-09-21... there are quite a few CVEs in the interim period... for example: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-21460

  • alexpott committed e32f277 on 10.1.x
    Issue #3311474 by ravi.shankar, immaculatexavier, mmjvb, daffie,...

  • alexpott committed 09fa538 on 10.0.x
    Issue #3311474 by ravi.shankar, immaculatexavier, mmjvb, daffie,...

  • alexpott committed 79b8681 on 9.5.x
    Issue #3311474 by ravi.shankar, immaculatexavier, mmjvb, daffie,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.