[Django] #29895: Atomic DDL statements in MySQL 8?

9 views
Skip to first unread message

Django

unread,
Oct 26, 2018, 8:14:09 PM10/26/18
to django-...@googlegroups.com
#29895: Atomic DDL statements in MySQL 8?
-----------------------------------------+------------------------
Reporter: ncknuna | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
I noticed that Django's documentation says "The atomic attribute doesn’t
have an effect on databases that don’t support DDL transactions (e.g.
MySQL, Oracle)." here: https://docs.djangoproject.com/en/2.1/howto
/writing-migrations/#non-atomic-migrations

I noticed that MySQL 8 adds support for atomic DDL statements though
(https://dev.mysql.com/doc/refman/8.0/en/atomic-ddl.html). Is this
something that Django supports when using MySQL 8 and the documentation is
imprecise (if so, consider this a bug report to clarify documentation)? or
is this not yet supported (if so, consider this a feature request)?
Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/29895>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 26, 2018, 11:22:21 PM10/26/18
to django-...@googlegroups.com
#29895: Enable atomic DDL statements on MySQL 8+
-----------------------------+------------------------------------
Reporter: Nathan Klug | Owner: nobody
Type: New feature | Status: new
Component: Migrations | Version: 2.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by Simon Charette):

* component: Uncategorized => Migrations
* type: Uncategorized => New feature
* stage: Unreviewed => Accepted


Comment:

The documentation is currently correct, the feature is disabled for all
versions of MySQL. Did you give a try at running the suite locally against
MySQL 8?

--
Ticket URL: <https://code.djangoproject.com/ticket/29895#comment:1>

Django

unread,
Oct 27, 2018, 6:27:28 PM10/27/18
to django-...@googlegroups.com
#29895: Enable atomic DDL statements on MySQL 8+
-----------------------------+------------------------------------
Reporter: Nathan Klug | Owner: nobody
Type: New feature | Status: new
Component: Migrations | Version: 2.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by Tim Graham):

I tried adding:
{{{
@cached_property
def can_rollback_ddl(self):
return not self.connection.mysql_is_mariadb and
self.connection.mysql_version >= (8, 0)
}}}
to `django/db/backends/mysql/features.py` and was met with some failures
such as "`SAVEPOINT s140283873580864_x2 does not exist')` in
`cache.tests.CreateCacheTableForDBCacheTests.test_createcachetable_observes_database_router`
that I couldn't figure out at a quick glance.

--
Ticket URL: <https://code.djangoproject.com/ticket/29895#comment:2>

Django

unread,
Nov 3, 2018, 8:32:49 PM11/3/18
to django-...@googlegroups.com
#29895: Enable atomic DDL statements on MySQL 8+
-----------------------------+------------------------------------
Reporter: Nathan Klug | Owner: nobody
Type: New feature | Status: new
Component: Migrations | Version: 2.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by Tom Forbes):

* cc: Tom Forbes (added)


Comment:

I had a look at this failure and I think I know why it occurs:
https://dev.mysql.com/doc/refman/8.0/en/implicit-commit.html

When using atomic DDL in mysql certain statements immediately and
implicitly commit the transaction. Django doesn't know about this, so it
ends up failing because the savepoints no longer exist.

In any case MySQL cannot roll back DDL like Postgres can, and Atomic DDL
is actually not the same as transactional DDL. I'm not entirely sure but
it seems (according to this https://mysqlserverteam.com/atomic-ddl-in-
mysql-8-0/) that it's just implicitly enabled/working without any
additional code changes.

--
Ticket URL: <https://code.djangoproject.com/ticket/29895#comment:3>

Django

unread,
Nov 4, 2018, 12:36:29 AM11/4/18
to django-...@googlegroups.com
#29895: Adjust atomic DDL documentation to avoid ambiguity with MySQL 8+ notion of
atomic DDL.
--------------------------------------+------------------------------------

Reporter: Nathan Klug | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 2.1

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Simon Charette):

* component: Migrations => Documentation
* type: New feature => Cleanup/optimization


Comment:

Thanks for the investigation Tom.

> When using atomic DDL in mysql certain statements immediately and

implicitly commit the transaction...

Yeah that's the exact opposite of what Django means by ''atomic DDL'' as
what PostgreSQL and SQLite support.

I've repurposed the ticket to be a documentation adjustment instead.

--
Ticket URL: <https://code.djangoproject.com/ticket/29895#comment:4>

Django

unread,
Dec 3, 2018, 8:03:47 PM12/3/18
to django-...@googlegroups.com
#29895: Adjust atomic DDL documentation to avoid ambiguity with MySQL 8+ notion of
atomic DDL.
--------------------------------------+------------------------------------
Reporter: Nathan Klug | Owner: Rodrigo
Type: Cleanup/optimization | Status: assigned

Component: Documentation | Version: 2.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Rodrigo):

* owner: nobody => Rodrigo
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/29895#comment:5>

Django

unread,
Dec 3, 2018, 9:29:24 PM12/3/18
to django-...@googlegroups.com
#29895: Adjust atomic DDL documentation to avoid ambiguity with MySQL 8+ notion of
atomic DDL.
--------------------------------------+------------------------------------
Reporter: Nathan Klug | Owner: Rodrigo
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 2.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Rodrigo):

* has_patch: 0 => 1


Old description:

> I noticed that Django's documentation says "The atomic attribute doesn’t
> have an effect on databases that don’t support DDL transactions (e.g.
> MySQL, Oracle)." here: https://docs.djangoproject.com/en/2.1/howto
> /writing-migrations/#non-atomic-migrations
>
> I noticed that MySQL 8 adds support for atomic DDL statements though
> (https://dev.mysql.com/doc/refman/8.0/en/atomic-ddl.html). Is this
> something that Django supports when using MySQL 8 and the documentation
> is imprecise (if so, consider this a bug report to clarify
> documentation)? or is this not yet supported (if so, consider this a
> feature request)? Thanks!

New description:

I noticed that Django's documentation says "The atomic attribute doesn’t
have an effect on databases that don’t support DDL transactions (e.g.
MySQL, Oracle)." here: https://docs.djangoproject.com/en/2.1/howto
/writing-migrations/#non-atomic-migrations

I noticed that MySQL 8 adds support for atomic DDL statements though
(https://dev.mysql.com/doc/refman/8.0/en/atomic-ddl.html). Is this
something that Django supports when using MySQL 8 and the documentation is
imprecise (if so, consider this a bug report to clarify documentation)? or
is this not yet supported (if so, consider this a feature request)?
Thanks!

https://github.com/math-a3k/django/pull/1

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29895#comment:6>

Django

unread,
Dec 3, 2018, 9:38:19 PM12/3/18
to django-...@googlegroups.com
#29895: Adjust atomic DDL documentation to avoid ambiguity with MySQL 8+ notion of
atomic DDL.
--------------------------------------+------------------------------------
Reporter: Nathan Klug | Owner: Rodrigo
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 2.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Description changed by Rodrigo:

Old description:

> I noticed that Django's documentation says "The atomic attribute doesn’t
> have an effect on databases that don’t support DDL transactions (e.g.
> MySQL, Oracle)." here: https://docs.djangoproject.com/en/2.1/howto
> /writing-migrations/#non-atomic-migrations
>
> I noticed that MySQL 8 adds support for atomic DDL statements though
> (https://dev.mysql.com/doc/refman/8.0/en/atomic-ddl.html). Is this
> something that Django supports when using MySQL 8 and the documentation
> is imprecise (if so, consider this a bug report to clarify
> documentation)? or is this not yet supported (if so, consider this a
> feature request)? Thanks!
>

> https://github.com/math-a3k/django/pull/1

New description:

I noticed that Django's documentation says "The atomic attribute doesn’t
have an effect on databases that don’t support DDL transactions (e.g.
MySQL, Oracle)." here: https://docs.djangoproject.com/en/2.1/howto
/writing-migrations/#non-atomic-migrations

I noticed that MySQL 8 adds support for atomic DDL statements though
(https://dev.mysql.com/doc/refman/8.0/en/atomic-ddl.html). Is this
something that Django supports when using MySQL 8 and the documentation is
imprecise (if so, consider this a bug report to clarify documentation)? or
is this not yet supported (if so, consider this a feature request)?
Thanks!

https://github.com/django/django/pull/10718

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29895#comment:7>

Django

unread,
Dec 6, 2018, 4:45:55 PM12/6/18
to django-...@googlegroups.com
#29895: Adjust atomic DDL documentation to avoid ambiguity with MySQL 8+ notion of
atomic DDL.
--------------------------------------+------------------------------------
Reporter: Nathan Klug | Owner: Rodrigo
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 2.1
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"ad191d9e011f37d79a7f2df3da881b06539aaaea" ad191d9]:
{{{
#!CommitTicketReference repository=""
revision="ad191d9e011f37d79a7f2df3da881b06539aaaea"
Fixed #29895 -- Doc'd why MySQL's atomic DDL statements don't work for
atomic migrations.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29895#comment:8>

Django

unread,
Dec 6, 2018, 4:46:07 PM12/6/18
to django-...@googlegroups.com
#29895: Adjust atomic DDL documentation to avoid ambiguity with MySQL 8+ notion of
atomic DDL.
--------------------------------------+------------------------------------
Reporter: Nathan Klug | Owner: Rodrigo
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 2.1
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"4c506730b5a8dae2ab9a16712db2f39c21d4385a" 4c50673]:
{{{
#!CommitTicketReference repository=""
revision="4c506730b5a8dae2ab9a16712db2f39c21d4385a"
[2.1.x] Fixed #29895 -- Doc'd why MySQL's atomic DDL statements don't work
for atomic migrations.

Backport of ad191d9e011f37d79a7f2df3da881b06539aaaea from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29895#comment:9>

Reply all
Reply to author
Forward
0 new messages