Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#30928 closed Cleanup/optimization (fixed)

Update documentation about MariaDB and MySQL support for nowait and skip_locked arguments.

Reported by: Par Andersson Owned by: Kolawole Nafiu Erinoso
Component: Documentation Version: 2.2
Severity: Normal Keywords: mysql mariadb
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The documentation incorrectly claims that NOWAIT & SKIP LOCKED is not supported by MySQL:

https://docs.djangoproject.com/en/dev/ref/models/querysets/#select-for-update

Currently, the postgresql, oracle, and mysql database backends support select_for_update(). However, MySQL doesn’t support the nowait, skip_locked, and of arguments.

Passing nowait=True, skip_locked=True, or of to select_for_update() using database backends that do not support these options, such as MySQL, raises a NotSupportedError. This prevents code from unexpectedly blocking.

However MySQL added support for nowait and skip locked since version 8, as documented here:
https://dev.mysql.com/doc/refman/8.0/en/innodb-locking-reads.html

Change History (9)

comment:1 by Mariusz Felisiak, 5 years ago

Keywords: mariadb added
Summary: documentation of select_for_update is incorrect regarding MySQLUpdate documentation about MariaDB and MySQL support for nowait and skip_locked arguments.
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Thanks, good catch. We should also update row-locking-with-queryset-select-for-update and it will be good to mention MariaDB in the select_for_update() documentation. Please remember that both don't support the of argument.

comment:2 by Kolawole Nafiu Erinoso, 5 years ago

Owner: changed from nobody to Kolawole Nafiu Erinoso
Status: newassigned

comment:3 by Kolawole Nafiu Erinoso, 5 years ago

The changes for the fix reside in this branch https://github.com/kola-er/django/tree/ticket_30928_2_2.

Note that the changes do not include MariaDB because the documentation as a whole specifically listed the supported database backends (PostgreSQL, MySQL, Oracle and SQLite) without the mention of it even though it's a variant of MySQL. In addition, there's an explicit omission of MariaDB backend done within the codebase here https://github.com/django/django/blob/stable/2.2.x/django/db/backends/mysql/features.py#L94 for the options.

comment:4 by Kolawole Nafiu Erinoso, 5 years ago

Here's the PR https://github.com/django/django/pull/12015 ready for review.

comment:5 by Carlos_Mir_de_Souza, 5 years ago

The PR is closed, please update the PR to an open one.

comment:6 by Kolawole Nafiu Erinoso, 5 years ago

Here's the new PR https://github.com/django/django/pull/12018 ready for review.

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In a5b4a909:

[3.0.x] Fixed #30928 -- Clarified MySQL/MariaDB support of QuerySet.select_for_update() options.

Thanks Par Andersson for reporting the issue.

Backport of d94d7b113c21d7a0fd802fadb1adbbec8155e880 from master

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In d94d7b11:

Fixed #30928 -- Clarified MySQL/MariaDB support of QuerySet.select_for_update() options.

Thanks Par Andersson for reporting the issue.

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 22466f91:

[2.2.x] Fixed #30928 -- Clarified MySQL/MariaDB support of QuerySet.select_for_update() options.

Thanks Par Andersson for reporting the issue.

Backport of d94d7b113c21d7a0fd802fadb1adbbec8155e880 from master

Note: See TracTickets for help on using tickets.
Back to Top