Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation fails due to Lost connection to MySQL during query #1195

Closed
StevePotter opened this issue Feb 5, 2025 · 1 comment
Closed

Comments

@StevePotter
Copy link

I run tutor local launch and it runs and applies a bunch of migrations, and ultimately fails on one. Attempts to install after that give a django.db.utils.OperationalError: (1060, "Duplicate column name 'algorithm'"), which I assume is the result of retrying a completed migration.

I removed all docker containers and cleared out /Users/steve/Library/Application Support/tutor/data, but it keeps happening. I've tried 4 times now, not sure why that's going on.

Applying embargo.0001_initial... OK
  Applying embargo.0002_data__add_countries... OK
  Applying enterprise.0198_alter_enterprisecourseenrollment_options... OK
  Applying enterprise.0199_auto_20240130_0628... OK
  Applying enterprise.0200_enterprisegroup_enterprisegroupmembership_historicalenterprisegroup_historicalenterprisegroupmembers... OK
  Applying enterprise.0201_auto_20240227_2227... OK
  Applying enterprise.0202_enterprisegroup_applies_to_all_contexts_and_more... OK
  Applying enterprise.0203_auto_20240312_1527... OK
  Applying enterprise.0204_auto_20240408_0723... OK
  Applying enterprise.0205_auto_20240408_1117... OK
  Applying enterprise.0206_auto_20240408_1344... OK
  Applying enterprise.0207_alter_enterprisegroupmembership_enterprise_customer_user_and_more... OK
  Applying enterprise.0208_enterprisecustomer_disable_expiry_messaging_for_learner_credit_and_more... OK
  Applying enterprise.0209_alter_enterprisecustomer_disable_expiry_messaging_for_learner_credit_and_more... OK
  Applying enterprise.0210_enterprisecustomer_enable_learner_portal_sidebar_message_and_more... OK
  Applying enterprise.0211_enterprisecustomer_show_videos_in_learner_portal_search_results_and_more... OK
  Applying enterprise.0212_alter_enterprisecustomer_career_engagement_network_message_and_more...Traceback (most recent call last):
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 75, in execute
    return self.cursor.execute(query, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/openedx/venv/lib/python3.11/site-packages/MySQLdb/connections.py", line 261, in query
    _mysql.connection.query(self, query)
MySQLdb.OperationalError: (2013, 'Lost connection to MySQL server during query')

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

Traceback (most recent call last):
  File "/openedx/edx-platform/./manage.py", line 106, in <module>
    execute_from_command_line([sys.argv[0]] + django_args)
  File "/openedx/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/openedx/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/openedx/venv/lib/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/openedx/venv/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
            ^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/db/migrations/migration.py", line 132, in apply
    operation.database_forwards(
  File "/openedx/venv/lib/python3.11/site-packages/django/db/migrations/operations/fields.py", line 235, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 831, in alter_field
    self._alter_field(
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 1056, in _alter_field
    self.execute(
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 201, in execute
    cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/openedx/venv/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 75, in execute
    return self.cursor.execute(query, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/openedx/venv/lib/python3.11/site-packages/MySQLdb/connections.py", line 261, in query
    _mysql.connection.query(self, query)
django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server during query')
Error: Command failed with status 1: docker compose -f /Users/steve/Library/Application Support/tutor/env/local/docker-compose.yml -f /Users/steve/Library/Application Support/tutor/env/local/docker-compose.prod.yml --project-name tutor_local -f /Users/steve/Library/Application Support/tutor/env/local/docker-compose.jobs.yml run --rm lms-job sh -e -c dockerize -wait tcp://mysql:3306 -timeout 20s
dockerize -wait tcp://mongodb:27017 -timeout 20s

echo "Loading settings $DJANGO_SETTINGS_MODULE"

./manage.py lms migrate

# Create meilisearch indexes
./manage.py lms shell -c "import search.meilisearch; search.meilisearch.create_indexes()"

# Create oauth2 apps for CMS SSO
# https://github.com/openedx/edx-platform/blob/master/docs/guides/studio_oauth.rst
./manage.py lms manage_user cms cms@openedx --unusable-password
./manage.py lms create_dot_application \
  --grant-type authorization-code \
  --redirect-uris "http://studio.local.openedx.io/complete/edx-oauth2/" \
  --client-id cms-sso \
  --client-secret rqYOctPRheW0o3TVuovVthlN \
  --scopes user_id \
  --skip-authorization \
  --update cms-sso cms
./manage.py lms create_dot_application \
  --grant-type authorization-code \
  --redirect-uris "http://studio.local.openedx.io:8001/complete/edx-oauth2/" \
  --client-id cms-sso-dev \
  --client-secret rqYOctPRheW0o3TVuovVthlN \
  --scopes user_id \
  --skip-authorization \
  --update cms-sso-dev cms


# Fix incorrect uploaded file path
if [ -d /openedx/data/uploads/ ]; then
  if [ -n "$(ls -A /openedx/data/uploads/)" ]; then
    echo "Migrating LMS uploaded files to shared directory"
    mv /openedx/data/uploads/* /openedx/media/
    rm -rf /openedx/data/uploads/
  fi
fi

# Create waffle switches to enable some features, if they have not been explicitly defined before
# Completion tracking: add green ticks to every completed unit
(./manage.py lms waffle_switch --list | grep completion.enable_completion_tracking) || ./manage.py lms waffle_switch --create completion.enable_completion_tracking on

The results of docker ps:

CONTAINER ID   IMAGE                                  COMMAND                  CREATED          STATUS          PORTS                                            NAMES
612246a5386b   overhangio/openedx:19.0.1-indigo       "celery --app=cms.ce…"   42 minutes ago   Up 42 minutes   8000/tcp                                         tutor_local-cms-worker-1
4b00a67f0967   overhangio/openedx:19.0.1-indigo       "uwsgi /openedx/uwsg…"   42 minutes ago   Up 41 minutes   8000/tcp                                         tutor_local-cms-1
e9050fe0209f   overhangio/openedx-mfe:19.0.0-indigo   "caddy run --config …"   42 minutes ago   Up 42 minutes   80/tcp, 443/tcp, 2019/tcp, 443/udp               tutor_local-mfe-1
ff5c40268e49   overhangio/openedx:19.0.1-indigo       "celery --app=lms.ce…"   42 minutes ago   Up 42 minutes   8000/tcp                                         tutor_local-lms-worker-1
9274fba3c035   overhangio/openedx:19.0.1-indigo       "uwsgi /openedx/uwsg…"   42 minutes ago   Up 41 minutes   8000/tcp                                         tutor_local-lms-1
d59c34939212   redis:7.2.4                            "docker-entrypoint.s…"   42 minutes ago   Up 42 minutes   6379/tcp                                         tutor_local-redis-1
11cc7b74205d   mongo:7.0.7                            "docker-entrypoint.s…"   42 minutes ago   Up 42 minutes   27017/tcp                                        tutor_local-mongodb-1
acefc858913c   getmeili/meilisearch:v1.8.4            "tini -- /bin/sh -c …"   42 minutes ago   Up 42 minutes   7700/tcp                                         tutor_local-meilisearch-1
68d6992a988c   devture/exim-relay:4.96-r1-0           "/sbin/tini -- exim …"   42 minutes ago   Up 42 minutes   8025/tcp                                         tutor_local-smtp-1
efd15924b227   caddy:2.7.4                            "caddy run --config …"   42 minutes ago   Up 42 minutes   443/tcp, 0.0.0.0:80->80/tcp, 2019/tcp, 443/udp   tutor_local-caddy-1
3174a847ae48   mysql:8.4.0                            "docker-entrypoint.s…"   42 minutes ago   Up 33 minutes   3306/tcp, 33060/tcp                              tutor_local-mysql-1
@StevePotter
Copy link
Author

I'm a moron, just hit container memory limits. Closing

@github-project-automation github-project-automation bot moved this from Pending Triage to Done in Tutor project management Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant