Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the MySQL transaction isolation level (Fixes #4281) #4339

Merged
merged 2 commits into from Oct 28, 2022

Conversation

tyler36
Copy link
Collaborator

@tyler36 tyler36 commented Oct 27, 2022

The Problem/Issue/Bug:

This resolves the issue of #4281 which requires MySQL tranaction isolation level setting.

How this PR Solves The Problem:

Add the required line to 'mysql' driver configurations.

  • Note: I added it on a Drupal 10 Postgres system too which appeared to load correctly, but am unaware of any side affects under "normal" usage.

Manual Testing Instructions:

Comment out line in a Drupal 10 install and a warning appears on /admin/reports/status

Related Issue Link(s):

Fixes #4281

Setting the MySQL transaction isolation level
Suggestion for: (3285800) Setting the MySQL transaction isolation level

@tyler36 tyler36 marked this pull request as ready for review October 27, 2022 01:46
@github-actions
Copy link

github-actions bot commented Oct 27, 2022

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Thanks for this. I think we should do it for Drupal 9 as well. In fact, @rpkoller, is this also absolutely required by drupal 9.5.x?

@tyler36
Copy link
Collaborator Author

tyler36 commented Oct 28, 2022

Add to Drupal 9 and rebased.

@rfay
Copy link
Member

rfay commented Oct 28, 2022

I'm going to take a look too and see if there's any way we can do this with extra config, that would represent what would be done in the real world. I imagine what we have here is what will work out easiest and best though.

@rpkoller
Copy link
Collaborator

rpkoller commented Oct 28, 2022

here is the change record about the mysql isolation level and the warning if it isn't using READ COMMITTED: https://www.drupal.org/node/3269885 . according to the CR will be introduced in 9.5.0. and i notice it is not only the docs page but the CR also has the recommendations with SET GLOBAL. so the issue is broader (in regards of the drupal documentation and the according issue that we filed).

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

When making a PR, try to change only the things that are relevant to the topic of the PR. If you want to make other changes (if "TRUE" should be "true" due to change in style preferences?) then make those changes in another PR that is style-related.

I'm pretty sure the changes to the go templating here introducing the spaces between members of the go template is unnatural, not sure if it's a syntax error. But that again is something that shouldn't be introduced if not related to the goal of the PR.

Overall, though, since this approach is currently recommended in the Drupal Change Notice, I think this approach will be fine.

@@ -8,14 +9,14 @@
*/

$host = "{{ $config.DatabaseHost }}";
$port = {{ $config.DatabasePort }};
Copy link
Member

Choose a reason for hiding this comment

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

These aren't correct alterations AFAIK. Did your editor do this? These are golang template instructions, I haven't seen the spaces like this before.

$settings['hash_salt'] = '{{ $config.HashSalt }}';

// This will prevent Drupal from setting read-only permissions on sites/default.
$settings['skip_permissions_hardening'] = TRUE;
$settings['skip_permissions_hardening'] = true;
Copy link
Member

Choose a reason for hiding this comment

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

Is this a change in PHP preferences? If not, let's not change here.

@tyler36
Copy link
Collaborator Author

tyler36 commented Oct 28, 2022

Sorry, Vscode tried to format on save.

I thought the following setting was suppose to prevent that but it doesn't appear to be working.

"editor.formatOnSaveMode": "modifications",

@rfay
Copy link
Member

rfay commented Oct 28, 2022

Those EVIL editors! Sometimes they can help so much... and other times not so much.

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

I tested this on Drupal 9.4, drupal9.5 and Drupal 10 and it behaved as expected. Thanks! Tried mariadb:10.4 and mysql:8.0

I'm a bit reluctant, as discussed before, I don't think the Drupal recommendations are correct, that the config change should be in the mysql config, not done like this. But I'm good with this because it's the Drupal-recommended way and it's also the easiest for us to do.

When I look at the postgres database requirement I'll be thinking about this.

@rfay rfay requested a review from rpkoller October 28, 2022 16:06
@rfay
Copy link
Member

rfay commented Oct 28, 2022

When @rpkoller approves we're good to go.

Copy link
Collaborator

@rpkoller rpkoller left a comment

Choose a reason for hiding this comment

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

hm i am not really qualified for reviewing that. ;) but i've manually tested and added the snippet to one of my existing sites (removed the cnf file beforehand and restarted). adding the according lines set the transaction isolation level and commenting it out set the level back to REPEATABLE-READ.

the only detail i wonder is, does it have certain performance implications to set the level on the drupal settings level - that way isn't it set on every request? with the cnf solution it would be set once on startup on the database level instead?

but as @rfay said it is still the current Drupal-recommended best practice therefore a plus one from me. but talking of still, have to see who best to ping and ask on the drupal end about the underlaying issue. cuz since yesterday when i've learned searching for the change record the issue isnt just limited to the docs page but also the change record itself. there the recommendation is used as well. maybe the best place might be the d10readiness meetings?

p.s. first added the comment to the general conversation until i found where to approve changes. haven't expected that a comment is required there as well. therefore deleted the comment in the general conversation and readded it here.

@rfay
Copy link
Member

rfay commented Oct 28, 2022

In the future we have two options:

  1. Add a post-start action like is done for pg_trgm, Add pg_trgm extension on postgres for Drupal9+, fixes #4341, fixes #3584, fixes #3653 #4347 (which would implement the other drupal-recommended approach)
  2. Add per-project-type database configuration (my.cnf) which hasn't been necessary up to now, but maybe it's coming.

@rfay rfay merged commit 82c07c4 into ddev:master Oct 28, 2022
@rfay
Copy link
Member

rfay commented Oct 28, 2022

Thanks for making this happen @tyler36 and thanks for all the informed direction on it @rpkoller .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drupal 9/10 & Mysql: "MySQL transaction isolation level"
3 participants