Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#30150 closed Bug (wontfix)

Django 1.11 with MySQL 8: "Unknown system variable 'TX_ISOLATION'"

Reported by: Carsten Fuchs Owned by: nobody
Component: Database layer (models, ORM) Version: 1.11
Severity: Normal Keywords:
Cc: Adam Johnson Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

https://docs.djangoproject.com/en/1.11/ref/databases/#version-support suggests that Django 1.11 works with MySQL 8, but besides #29451, there is a problem similar to #28804 and #28794:

$ python manage.py check --deploy
Traceback (most recent call last):
  File "/home/carsten/.virtualenvs/Zeiterfassung/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
  File "/home/carsten/.virtualenvs/Zeiterfassung/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 101, in execute
    return self.cursor.execute(query, args)
  File "/home/carsten/.virtualenvs/Zeiterfassung/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute
    self.errorhandler(self, exc, value)
  File "/home/carsten/.virtualenvs/Zeiterfassung/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/home/carsten/.virtualenvs/Zeiterfassung/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute
    res = self._query(query)
  File "/home/carsten/.virtualenvs/Zeiterfassung/lib/python3.6/site-packages/MySQLdb/cursors.py", line 412, in _query
    rowcount = self._do_query(q)
  File "/home/carsten/.virtualenvs/Zeiterfassung/lib/python3.6/site-packages/MySQLdb/cursors.py", line 375, in _do_query
    db.query(q)
  File "/home/carsten/.virtualenvs/Zeiterfassung/lib/python3.6/site-packages/MySQLdb/connections.py", line 276, in query
    _mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1193, "Unknown system variable 'TX_ISOLATION'")

The above exception was the direct cause of the following exception:

[...]

This can be worked-around by changing line 289 in db/backends/mysql/base.py

            assignments.append("TX_ISOLATION = '%s'" % self.isolation_level)

into

            assignments.append("transaction_isolation = '%s'" % self.isolation_level)

Any chance to get this, with proper checks for the MySQL version, into Django 1.11?

Change History (5)

comment:1 by Tim Graham <timograham@…>, 5 years ago

In 951ee0b1:

[1.11.x] Refs #30150 -- Doc'd that MySQL 8 isn't supported.

comment:2 by Tim Graham, 5 years ago

Resolution: wontfix
Status: newclosed

Per the supported versions policy, 1.1.11.x only receives data loss and security fixes.

comment:3 by Carsten Fuchs, 5 years ago

Well, it's probably only me, but this puts me into a somewhat precarious situation:
Django 1.11 supports Oracle 11 and MySQL 5*, but not Oracle 12 or MySQL 8.
Django 2 supports Oracle 12 and MySQL 8, but not Oracle 11.

As I intend to switch from Oracle 11 to MySQL, the only supported upgrade path that is left is:
Django 1.11 with Oracle 11 --> Django 1.11 with MySQL 5.7 --> Django 2.0 with MySQL 5.7 --> Django 2.0 with MySQL 8 --> Django 2.1 with MySQL 8.

I'll probably take the risk and use MySQL 8 right from the start anyways, but I wished there had been a milder step possible.

comment:4 by Adam Johnson, 5 years ago

Cc: Adam Johnson added

Carsten, you can always create a subclassed database backend in your project to add the compatibility with MySQL 8 in Django 1.11. You might find it's not just transaction_isolation that's the relevant change, maybe there are more things to backport from 2.0 for that.

in reply to:  4 comment:5 by Carsten Fuchs, 5 years ago

Replying to Adam (Chainz) Johnson:

Carsten, you can always create a subclassed database backend in your project to add the compatibility with MySQL 8 in Django 1.11. You might find it's not just transaction_isolation that's the relevant change, maybe there are more things to backport from 2.0 for that.

Yes, there are certainly a lot more considerations involved with using MySQL 8 with Django 1.11, e.g. #18392 and #29451.
Fortunately, during the tests and research that I spent during the last weeks, I have not become aware of any other issues that indicate anything but a reliable running of MySQL 8 with Django 1.11.
Given Django 1.11's status as noted by Tim above and given that I intend to upgrade to Django 2.0+ as soon as I got confident that my transition from Oracle to MySQL went well, there is no point in adding features to 1.11 that won't make it into an official release. (And unfortunately, I don't think that I understand enough of the Django source code to address issues at that level, at least at the scale of a database backend.)

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