question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Superset db upgrade hangs for a custom alembic script

See original GitHub issue

The superset db upgrade command hangs when trying to run a custom alembic script to increase the length of username column in the ab_user table. Once the upgrade runs, it creates an idle sleep connection with the database which supposedly creates a lock on the ab_user table which prevents the alter command to run. We are using a 10.1.19-MariaDB as the database which is hosted in AWS RDS.

For the first time installation, the upgrade works fine and deployment completes successfully. But when we create a new alembic script, build and restart the server the hoping the db upgrade should result

Not able to figure out how a sleep command is getting generated internally before the upgrade process. Has it to do with FAB or alembic in general?

Expected results

The db upgrade process should complete successfully

Actual results

The upgrade process hangs during

Screenshots

The list of all the process for the db. The second last row is the one which prevents the ALTER command to be executed. The time for the command is same so it seems it just go triggered during the upgrade process AllProcessList

The lock on ab_user table ab_user_LOCK

How to reproduce the bug

  1. Have an installed version of superset running with db up and running.
  2. Write a custom alembic migrate script to increase the username length
  3. Build the project and restart the server.
  4. The db upgrade process should get stuck

Environment

  • superset version: 0.999.0dev
  • python version: 3.7.2
  • node.js version: 10.15.0
  • npm version: 6.9.0

Additional context

Generated alembic script

revision = 'c088a7201375'
down_revision = 'c82ee8a39623'

from alembic import op
import sqlalchemy as sa


def upgrade():
    with op.batch_alter_table('ab_user') as batch_op:
        batch_op.alter_column(
            'username',
            nullable=False,
            type_=sa.String(length=256),
            existing_type=sa.String(length=64),
            existing_server_default=None, 
            existing_nullable=False)


def downgrade():
    with op.batch_alter_table('ab_user') as batch_op:
        batch_op.alter_column(
            'username',
            nullable=False,
            type_=sa.String(length=64),
            existing_type=sa.String(length=256),
            existing_server_default=None, 
            existing_nullable=False)

Below are the logs from the console when the db gets stuck

xxx-superset             | INFO  [alembic.runtime.migration] Context impl MySQLImpl.
xxx-superset             | INFO  [alembic.runtime.migration] Will assume transactional DDL.
xxx-superset             | INFO  [alembic.runtime.migration] Running upgrade c82ee8a39623 -> c088a7201375, increase username length

The upgrade process gets stuck for ~ 8 hours as the sleep command times out after that time as per the default db configuration time for time_wait_timeout and wait_timeout of 28800 seconds. After the time out, the ALTER command gets executed. Also, if we manually KILL the thread, the ALTER gets executed and the upgrade finishes successfully.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
issue-label-bot[bot]commented, Jul 19, 2019

Issue-Label Bot is automatically applying the label #bug to this issue, with a confidence of 0.96. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

0reactions
stale[bot]commented, Oct 6, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Superset db upgrade hangs for a custom alembic script #7902
The superset db upgrade command hangs when trying to run a custom alembic script to increase the length of username column in the...
Read more >
Error while running “superset db upgrade” after changing ...
to sqlalchemy-alembic. I am trying to change the metadata DB to Vertica from sqlite and I am facing an issue while running "superset...
Read more >
airbnb/superset - Gitter
Hi all,. We are in the process of deploying Superset to production. Unfortunately Im not sure if we can wait for the first...
Read more >
Alembic migration hangs after creating db session
I can run SELECT statements and read data from the other database, but the alembic migration always ends up hanging after running my...
Read more >
Database migrations using alembic - YouTube
The talk will discuss manually adding data migration to a schema migration script and describe how using alembic has changed our development ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found