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
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:
- 3311474-fatal-error-on
changes, plain diff MR !2802
Comments
Comment #4
immaculatexavier commentedCommitted with MR in accordance to the proposed resolution
Comment #5
cilefen commentedComment #6
mmjvb commentedAs 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.
Comment #7
mmjvb commentedFor 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'.
Comment #8
mmjvb commentedConfirm 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.
Comment #9
cilefen commentedA WSOD is major.
Comment #10
mmjvb commentedConsidered 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
Comment #11
daffie commented@mmjvb: Do you have a link to the documentation where we ca check your finding?
Comment #12
mmjvb commentedFound it here: https://dev.mysql.com/doc/refman/8.0/en/added-deprecated-removed.html first.
Also mentioned in the release notes: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-3.html
Comment #13
daffie commentedI 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!
Comment #14
daffie commentedWe can add a unit test with a provider method to test for different versions of MySQL.
Comment #15
mmjvb commentedWould prefer the early stage approach as mentioned as refactor in Remaining tasks.
There is no need for conditionals on MySQL version:
When you insist on documentation suggest to add a line: Retrieve transaction_isolation with fallback on tx_isolation.
Comment #16
wim leers#2733675: Warning when mysql is not set to READ-COMMITTED introduced this, and that got committed to
9.5.xand10.0.x.This hence is a net regression in those two versions.
Comment #18
ravi.shankar commentedMade changes as per comment #13.
Comment #19
daffie commentedI 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.
Comment #20
mmjvb commentedProvided the refactor in #15
Comment #21
longwave@mmjvb what if MySQL (or MariaDB, etc) adds some other
%_isolationvariable 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.Comment #22
ravi.shankar commentedMade changes as per suggestion on MR, please review.
Comment #23
mmjvb commented@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.
Comment #24
mmjvb commentedComment #25
daffie commentedI 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.
Comment #26
mmjvb commentedIn 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.
Comment #27
longwave@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.
Comment #28
mmjvb commentedIt is clear I am wasting my time here. Already provided the code, happily using it.
Comment #29
alexpottCommitted 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