Search code examples
pythonmysqldjangoamazon-web-servicesamazon-elastic-beanstalk

Changing MySQL isolation level on Django/Elastic beanstalk/RDS


I'm trying to change the isolation level of my MySQL instance on RDS through a Django application. I've followed the recommendation here

So, I changed my Django db settings to:

'OPTIONS': {
    'init_command': 'SET default_storage_engine=INNODB; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED'
}

This command works fine when I run directly in the database (MySQL version 8.0.13) However, when I try to deploy it to Elastic Beanstalk I got the following error:

Command failed on instance. Return code: 1 Output: (TRUNCATED)... manual that corresponds to your MySQL server version for the right syntax to use near 'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED' at line 1")

I also tried changing the line to:

SET default_storage_engine=INNODB, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED

With the same results

Any idea what might be wrong? Or another solution that I can use (maybe I can just run this command and set it to global isolation level instead?)


Solution

  • Perhaps that OPTIONS cannot handle 2 commands. So remove the first one -- it is useful only when creating a new table. And it may be possible to specify the ENGINE=InnoDB on any CREATE TABLEs you need to do. Anyway, I would expect AWS to default to that. And 8.0 has that engine default.