Bug #107174 Isolation level support for connectors and/or Django backend
Submitted: 2 May 2022 7:37 Modified: 20 May 2022 20:55
Reporter: Ville Skyttä Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S2 (Serious)
Version:8.0.29 OS:Any
Assigned to: CPU Architecture:Any

[2 May 2022 7:37] Ville Skyttä
Description:
Ability to set transaction isolation level for the Django backend would be beneficial for cases where it cannot be configured elsewhere.

Django has a strong preference for READ COMMITTED: https://docs.djangoproject.com/en/3.2/ref/databases/#isolation-level-2

Django's built in drivers set READ COMMITTED by default:
https://github.com/django/django/blob/e01b383e021d37e1b7ee62f1cf2e490fb849b95d/django/db/b...
https://github.com/django/django/blob/e01b383e021d37e1b7ee62f1cf2e490fb849b95d/django/db/b...

How to repeat:
Attempting to use for example 'isolation_level': 'read committed' in Django db OPTIONS results in error message from connector:

AttributeError: Unsupported argument 'isolation_level'

...and I haven't followed through whether that setting would actually do anything just by letting it pass through, or if something akin to what Django's own does (see links above) would be needed.

Suggested fix:
Add an option for setting session transaction isolation level to connector, make it usable in the shipped Django backend.

Alternatively/additionally, option to execute arbitrary SQL on connect would be beneficial, and could actually be used as a workaround for absence of the transaction isolation level option (manual "SET SESSION TRANSACTION ISOLATION LEVEL ..." could be done).
[2 May 2022 9:22] MySQL Verification Team
Hello Ville Skyttä,

Thank you for the report and feedback.
Verified as described.

regards,
Umesh
[20 May 2022 20:55] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/Python 8.0.30 release, and here's the proposed changelog entry from the documentation team:

For Django, allow setting the connection isolation level with an
'isolation_level' OPTIONS entry in Django's DATABASES configuration.

Thank you for the bug report.