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

Fixed #27683 -- Made MySQL default to the read committed isolation level. #7978

Merged
merged 1 commit into from Feb 1, 2017

Conversation

Projects
None yet
4 participants
@timgraham

This comment has been minimized.

Show comment
Hide comment
@timgraham

timgraham Jan 28, 2017

Member

MySQL expert advice on the test failure appreciated! Perhaps it should be skipped or modified based on the transaction level.

Member

timgraham commented Jan 28, 2017

MySQL expert advice on the test failure appreciated! Perhaps it should be skipped or modified based on the transaction level.

@adamchainz

You know you can @ me :) There's no good way I know of auto-subscribing to django pr's featuring 'mysql' 🤔

Show outdated Hide outdated docs/ref/databases.txt
Show outdated Hide outdated tests/backends/test_mysql.py
@adamchainz

This comment has been minimized.

Show comment
Hide comment
@adamchainz

adamchainz Jan 28, 2017

Member

The test fails now because the semantics for the locks used for the insert/update statements have slightly changed and now MySQL can report the duplication on the unique index earlier. This isn't a classic way of creating a deadlock, it's probably better to change the example. There's a good example in this blog post I found from the inimitable Baron Schwartz: https://www.xaprb.com/blog/2006/08/08/how-to-deliberately-cause-a-deadlock-in-mysql/ (The second one; the first relies on serializable). Afraid I don't have time to try it right now.

Member

adamchainz commented Jan 28, 2017

The test fails now because the semantics for the locks used for the insert/update statements have slightly changed and now MySQL can report the duplication on the unique index earlier. This isn't a classic way of creating a deadlock, it's probably better to change the example. There's a good example in this blog post I found from the inimitable Baron Schwartz: https://www.xaprb.com/blog/2006/08/08/how-to-deliberately-cause-a-deadlock-in-mysql/ (The second one; the first relies on serializable). Afraid I don't have time to try it right now.

@shaib

This comment has been minimized.

Show comment
Hide comment
@shaib

shaib Jan 28, 2017

Member

DIdn't we want to also add a compatibility check?

Member

shaib commented Jan 28, 2017

DIdn't we want to also add a compatibility check?

@adamchainz

This comment has been minimized.

Show comment
Hide comment
@adamchainz

adamchainz Jan 29, 2017

Member

I don't know if the check would be useful now we're just changing the default in one version. Potentially we could add one to warn users that are on 'repeatable read', but they'd be setting it manually then and it might be safer to assume they know what they're doing?

Member

adamchainz commented Jan 29, 2017

I don't know if the check would be useful now we're just changing the default in one version. Potentially we could add one to warn users that are on 'repeatable read', but they'd be setting it manually then and it might be safer to assume they know what they're doing?

@timgraham

This comment has been minimized.

Show comment
Hide comment
@timgraham

timgraham Jan 30, 2017

Member

I tried to fix the test as suggested but the deadlock now happens in "other_thread" rather than the main thread. I'm taking a break on it for now.

Member

timgraham commented Jan 30, 2017

I tried to fix the test as suggested but the deadlock now happens in "other_thread" rather than the main thread. I'm taking a break on it for now.

@shaib

This comment has been minimized.

Show comment
Hide comment
@shaib

shaib Jan 31, 2017

Member

@timgraham I don't see a reason for any deadlock there at all now. I think the fix should be to add .select_for_update() in the list(Reporter.objects.filter(id=...)) lines.

Member

shaib commented Jan 31, 2017

@timgraham I don't see a reason for any deadlock there at all now. I think the fix should be to add .select_for_update() in the list(Reporter.objects.filter(id=...)) lines.

@shaib

This comment has been minimized.

Show comment
Hide comment
@shaib

shaib Jan 31, 2017

Member

@adamchainz The compatibility check was supposed to warn people that the default isolation level has changed; so it is supposed to trigger not based on the actual isolation level, but based on the absence of an isolation-level setting in DATABASES[...]['OPTIONS'].

Member

shaib commented Jan 31, 2017

@adamchainz The compatibility check was supposed to warn people that the default isolation level has changed; so it is supposed to trigger not based on the actual isolation level, but based on the absence of an isolation-level setting in DATABASES[...]['OPTIONS'].

@adamchainz

This comment has been minimized.

Show comment
Hide comment
@adamchainz

adamchainz Jan 31, 2017

Member

@shaib Yes I know, but that was when we were thinking of a "deprecation path" rather than just switching the default. If we add the check it will be noise to most people. It would require a change to all existing MySQL projects and since startproject defaults to sqlite3 it would need a change on all new projects too 🤔

Member

adamchainz commented Jan 31, 2017

@shaib Yes I know, but that was when we were thinking of a "deprecation path" rather than just switching the default. If we add the check it will be noise to most people. It would require a change to all existing MySQL projects and since startproject defaults to sqlite3 it would need a change on all new projects too 🤔

@timgraham

This comment has been minimized.

Show comment
Hide comment
@timgraham

timgraham Jan 31, 2017

Member

I tried your suggestion about the test Shai, but the result is the same.

Member

timgraham commented Jan 31, 2017

I tried your suggestion about the test Shai, but the result is the same.

@shaib

This comment has been minimized.

Show comment
Hide comment
@shaib

shaib Jan 31, 2017

Member

@adamchainz startproject could silence the check by default; I feel uneasy about subtly changing the transaction semantics under people's feet without telling them (and the release notes don't count).

Member

shaib commented Jan 31, 2017

@adamchainz startproject could silence the check by default; I feel uneasy about subtly changing the transaction semantics under people's feet without telling them (and the release notes don't count).

@shaib

This comment has been minimized.

Show comment
Hide comment
@shaib

shaib Jan 31, 2017

Member

@timgraham indeed adding .select_for_update() calls is necessary but not sufficient, see timgraham#10

Member

shaib commented Jan 31, 2017

@timgraham indeed adding .select_for_update() calls is necessary but not sufficient, see timgraham#10

@adamchainz

This comment has been minimized.

Show comment
Hide comment
@adamchainz

adamchainz Jan 31, 2017

Member

startproject could silence the check by default

That makes the default configuration a bit mysterious imo

indeed adding .select_for_update() calls is necessary but not sufficient, see timgraham#10

Nice one

Member

adamchainz commented Jan 31, 2017

startproject could silence the check by default

That makes the default configuration a bit mysterious imo

indeed adding .select_for_update() calls is necessary but not sufficient, see timgraham#10

Nice one

@adamchainz

This comment has been minimized.

Show comment
Hide comment
@adamchainz

adamchainz Jan 31, 2017

Member

feel uneasy about subtly changing the transaction semantics under people's feet without telling them (and the release notes don't count).

I do too still but at the same time, most users have never thought about this and will be confused by the message. It's a hard balance, maybe we should move back to the idea of a "deprecation" ?

Member

adamchainz commented Jan 31, 2017

feel uneasy about subtly changing the transaction semantics under people's feet without telling them (and the release notes don't count).

I do too still but at the same time, most users have never thought about this and will be confused by the message. It's a hard balance, maybe we should move back to the idea of a "deprecation" ?

@timgraham

This comment has been minimized.

Show comment
Hide comment
@timgraham

timgraham Jan 31, 2017

Member

My take (not as a MySQL user) given Aymeric comments, "I think there’s been little feedback because this issue is very, very far from the concerns of most Django users — aside from some very performance-sensitive websites that already worked around Django’s bugs and will add the configuration line needed to keep whatever the isolation level they chose." is that anyone running Django apps that could be affected by the change is probably careful enough to read the release notes and test their application appropriately. It doesn't seem worthwhile to nag everyone about it with a deprecation or check. Feel free to continue the discussion on the mailing list though.

Member

timgraham commented Jan 31, 2017

My take (not as a MySQL user) given Aymeric comments, "I think there’s been little feedback because this issue is very, very far from the concerns of most Django users — aside from some very performance-sensitive websites that already worked around Django’s bugs and will add the configuration line needed to keep whatever the isolation level they chose." is that anyone running Django apps that could be affected by the change is probably careful enough to read the release notes and test their application appropriately. It doesn't seem worthwhile to nag everyone about it with a deprecation or check. Feel free to continue the discussion on the mailing list though.

@shaib

This comment has been minimized.

Show comment
Hide comment
@shaib

shaib Jan 31, 2017

Member

@adamchainz said:

maybe we should move back to the idea of a "deprecation" ?

So, instead of a check you can silence, a silent-by-default warning? I don't think that's much better. "People who check for deprecations" are not our target audience, IMO.

@timgraham said:

anyone running Django apps that could be affected by the change is probably careful enough to read the release notes and test their application appropriately. It doesn't seem worthwhile to nag everyone about it with a deprecation or check.

I've read over that discussion again now, and reached the same conclusion. Let's just change it.

@timgraham said:

Feel free to continue the discussion on the mailing list though.

Judging by the previous discussion, I think everybody who cares is already here 😈

Member

shaib commented Jan 31, 2017

@adamchainz said:

maybe we should move back to the idea of a "deprecation" ?

So, instead of a check you can silence, a silent-by-default warning? I don't think that's much better. "People who check for deprecations" are not our target audience, IMO.

@timgraham said:

anyone running Django apps that could be affected by the change is probably careful enough to read the release notes and test their application appropriately. It doesn't seem worthwhile to nag everyone about it with a deprecation or check.

I've read over that discussion again now, and reached the same conclusion. Let's just change it.

@timgraham said:

Feel free to continue the discussion on the mailing list though.

Judging by the previous discussion, I think everybody who cares is already here 😈

@shaib

shaib approved these changes Feb 1, 2017

LGTM

Fixed #27683 -- Made MySQL default to the read committed isolation le…
…vel.

Thanks Shai Berger for test help and Adam Johnson for review.

@timgraham timgraham merged commit 924af63 into django:master Feb 1, 2017

17 checks passed

docs Build #14815 ended
Details
flake8 Build #14924 ended
Details
isort Build #14947 succeeded in 50 sec
Details
pull-requests-javascript Build #11308 ended
Details
pull-requests-trusty/database=mysql,label=trusty-pr,python=python3.4 Build #10679 ended
Details
pull-requests-trusty/database=mysql,label=trusty-pr,python=python3.6 Build #10679 ended
Details
pull-requests-trusty/database=mysql_gis,label=trusty-pr,python=python3.4 Build #10679 ended
Details
pull-requests-trusty/database=mysql_gis,label=trusty-pr,python=python3.6 Build #10679 ended
Details
pull-requests-trusty/database=postgis,label=trusty-pr,python=python3.4 Build #10679 ended
Details
pull-requests-trusty/database=postgis,label=trusty-pr,python=python3.6 Build #10679 ended
Details
pull-requests-trusty/database=postgres,label=trusty-pr,python=python3.4 Build #10679 ended
Details
pull-requests-trusty/database=postgres,label=trusty-pr,python=python3.6 Build #10679 ended
Details
pull-requests-trusty/database=spatialite,label=trusty-pr,python=python3.4 Build #10679 ended
Details
pull-requests-trusty/database=spatialite,label=trusty-pr,python=python3.6 Build #10679 ended
Details
pull-requests-trusty/database=sqlite3,label=trusty-pr,python=python3.4 Build #10679 ended
Details
pull-requests-trusty/database=sqlite3,label=trusty-pr,python=python3.6 Build #10679 ended
Details
pull-requests-windows/database=sqlite3,label=windows,python=Python35 Build #7004 ended
Details

@timgraham timgraham deleted the timgraham:27683 branch Feb 1, 2017

@adamchainz

This comment has been minimized.

Show comment
Hide comment
@adamchainz

adamchainz Feb 1, 2017

Member

It is done! 🌈

Member

adamchainz commented Feb 1, 2017

It is done! 🌈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment