AWS AMI instance disconnection then local quickstart migration error

Hi @regis,

So I want to try tutor on the cloud using the tutor AMI form the AWS marketplace. Followed instructions including setting up of A and CNAME records. DNS checker shows the right IP address for the domain and *. subdomains.

I ran local quickstart… but the console disconnected. It happened twice. On my third attempt to run local quickstart, the following occurred. Short of terminating the instance, how do I resolve this? Do I have to tweak the migrations table?

Running migrations:
Applying student.0034_courseenrollmentcelebration…Traceback (most recent call last):
File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py”, line 82, in _execute
return self.cursor.execute(sql)
File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py”, line 71, in execute
return self.cursor.execute(query, args)
File “/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py”, line 206, in execute
res = self._query(query)
File “/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py”, line 319, in _query
db.query(q)
File “/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py”, line 259, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1050, “Table ‘student_courseenrollmentcelebration’ already exists”)

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

Traceback (most recent call last):
File “./manage.py”, line 123, in
execute_from_command_line([sys.argv[0]] + django_args)
File “/openedx/venv/lib/python3.8/site-packages/django/core/management/init.py”, line 381, in execute_from_command_line
utility.execute()
File “/openedx/venv/lib/python3.8/site-packages/django/core/management/init.py”, line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py”, line 323, in run_from_argv
self.execute(*args, **cmd_options)
File “/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py”, line 364, in execute
output = self.handle(*args, **options)
File “/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py”, line 83, in wrapped
res = handle_func(*args, **kwargs)
File “/openedx/venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py”, line 232, in handle
post_migrate_state = executor.migrate(
File “/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py”, line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File “/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py”, line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File “/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py”, line 245, in apply_migration
state = migration.apply(state, schema_editor)
File “/openedx/venv/lib/python3.8/site-packages/django/db/migrations/migration.py”, line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File “/openedx/venv/lib/python3.8/site-packages/django/db/migrations/operations/models.py”, line 92, in database_forwards
schema_editor.create_model(model)
File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/schema.py”, line 307, in create_model
self.execute(sql, params or None)
File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/schema.py”, line 137, in execute
cursor.execute(sql, params)
File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py”, line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py”, line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py”, line 84, in _execute
return self.cursor.execute(sql, params)
File “/openedx/venv/lib/python3.8/site-packages/django/db/utils.py”, line 89, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py”, line 82, in _execute
return self.cursor.execute(sql)
File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py”, line 71, in execute
return self.cursor.execute(query, args)
File “/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py”, line 206, in execute
res = self._query(query)
File “/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py”, line 319, in _query
db.query(q)
File “/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py”, line 259, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1050, “Table ‘student_courseenrollmentcelebration’ already exists”)

As I am not too familiar with openedx tables, I was wary about doing a fake migrate. Just decided to terminate the instance and create a new one.

Hi @eragon! Did it work for you? It’s almost certainly an issue with the amount of memory available on your machine.

Hi @regis, yup after two attempts! Initially, it did not as I was using t3a.medium (after watching the overhang video from 2019 suggesting a t3.medium one), then I eventually used the t3a.large instance as recommended in the marketplace. :smiley:

Good. FYI this is about the only scenario where you should delete Tutor data: when migrations are interrupted, they leave the database in an unknown state which is difficult to recover from. As the database does not contain any precious data at that point, it’s easier to just delete and re-create it.