#29895 closed Cleanup/optimization (fixed)
Adjust atomic DDL documentation to avoid ambiguity with MySQL 8+ notion of atomic DDL.
Reported by: | Nathan Klug | Owned by: | Rodrigo |
---|---|---|---|
Component: | Documentation | Version: | 2.1 |
Severity: | Normal | Keywords: | |
Cc: | Tom Forbes | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
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!
Change History (9)
comment:1 by , 6 years ago
Component: | Uncategorized → Migrations |
---|---|
Summary: | Atomic DDL statements in MySQL 8? → Enable atomic DDL statements on MySQL 8+ |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → New feature |
comment:2 by , 6 years ago
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.
comment:3 by , 6 years ago
Cc: | added |
---|
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.
comment:4 by , 6 years ago
Component: | Migrations → Documentation |
---|---|
Summary: | Enable atomic DDL statements on MySQL 8+ → Adjust atomic DDL documentation to avoid ambiguity with MySQL 8+ notion of atomic DDL. |
Type: | New feature → Cleanup/optimization |
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.
comment:5 by , 6 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 6 years ago
Description: | modified (diff) |
---|---|
Has patch: | set |
comment:7 by , 6 years ago
Description: | modified (diff) |
---|
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?