You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "devikaaaa33 (via GitHub)" <gi...@apache.org> on 2025/07/27 05:57:17 UTC

[I] Db restoration issue from version 4.1.1 to 5.0.0 [superset]

devikaaaa33 opened a new issue, #34332:
URL: https://github.com/apache/superset/issues/34332

   ### Bug description
   
   Hi Team, I am trying to upgrade superset version from 4.1.1 to 5.0.0 and getting below error. Alembic version of old DB is 48cbb571fa3a
   
   Upgrading DB schema...
   Loaded your LOCAL configuration at [/app/pythonpath/superset_config.py]
   2025-07-27 05:45:45,326:INFO:superset.initialization:Setting database isolation level to READ COMMITTED
   /app/.venv/lib/python3.11/site-packages/flask_limiter/extension.py:333: UserWarning: Using the in-memory storage for tracking rate limits as no storage was explicitly specified. This is not recommended for production use. See: https://flask-limiter.readthedocs.io#configuring-a-storage-backend for documentation about configuring the storage backend.
     warnings.warn(
   2025-07-27 05:45:45,501:INFO:superset.utils.screenshots:No PIL installation found
   2025-07-27 05:45:46,207:INFO:superset.utils.pdf:No PIL installation found
   INFO  [alembic.env] Starting the migration scripts.
   INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
   INFO  [alembic.runtime.migration] Will assume transactional DDL.
   INFO  [alembic.runtime.migration] Running upgrade  -> 4e6a06bad7a8, Init
   Traceback (most recent call last):
     File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1910, in _execute_context
       self.dialect.do_execute(
     File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
       cursor.execute(statement, parameters)
   psycopg2.errors.DuplicateTable: relation "dashboards" already exists
   
   
   The above exception was the direct cause of the following exception:
   
   Traceback (most recent call last):
     File "/app/.venv/bin/superset", line 10, in <module>
       sys.exit(superset())
                ^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
       return self.main(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
       rv = self.invoke(ctx)
            ^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
       return _process_result(sub_ctx.command.invoke(sub_ctx))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
       return _process_result(sub_ctx.command.invoke(sub_ctx))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
       return ctx.invoke(self.callback, **ctx.params)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
       return __callback(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
       return f(get_current_context(), *args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/flask/cli.py", line 358, in decorator
       return __ctx.invoke(f, *args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
       return __callback(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/flask_migrate/cli.py", line 149, in upgrade
       _upgrade(directory, revision, sql, tag, x_arg)
     File "/app/.venv/lib/python3.11/site-packages/flask_migrate/__init__.py", line 98, in wrapped
       f(*args, **kwargs)
     File "/app/.venv/lib/python3.11/site-packages/flask_migrate/__init__.py", line 185, in upgrade
       command.upgrade(config, revision, sql=sql, tag=tag)
     File "/app/.venv/lib/python3.11/site-packages/alembic/command.py", line 406, in upgrade
       script.run_env()
     File "/app/.venv/lib/python3.11/site-packages/alembic/script/base.py", line 586, in run_env
       util.load_python_file(self.dir, "env.py")
     File "/app/.venv/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
       module = load_module_py(module_id, path)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
       spec.loader.exec_module(module)  # type: ignore
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "<frozen importlib._bootstrap_external>", line 940, in exec_module
     File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
     File "/app/.venv/lib/python3.11/site-packages/superset/extensions/../migrations/env.py", line 142, in <module>
       run_migrations_online()
     File "/app/.venv/lib/python3.11/site-packages/superset/extensions/../migrations/env.py", line 133, in run_migrations_online
       context.run_migrations()
     File "<string>", line 8, in run_migrations
     File "/app/.venv/lib/python3.11/site-packages/alembic/runtime/environment.py", line 946, in run_migrations
       self.get_context().run_migrations(**kw)
     File "/app/.venv/lib/python3.11/site-packages/alembic/runtime/migration.py", line 623, in run_migrations
       step.migration_fn(**kw)
     File "/app/.venv/lib/python3.11/site-packages/superset/migrations/versions/2015-09-21_17-30_4e6a06bad7a8_init.py", line 57, in upgrade
       op.create_table(
     File "<string>", line 8, in create_table
     File "<string>", line 3, in create_table
     File "/app/.venv/lib/python3.11/site-packages/alembic/operations/ops.py", line 1318, in create_table
       return operations.invoke(op)
              ^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/alembic/operations/base.py", line 442, in invoke
       return fn(self, operation)
              ^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/alembic/operations/toimpl.py", line 143, in create_table
       operations.impl.create_table(table, **kw)
     File "/app/.venv/lib/python3.11/site-packages/alembic/ddl/impl.py", line 406, in create_table
       self._exec(schema.CreateTable(table, **kw))
     File "/app/.venv/lib/python3.11/site-packages/alembic/ddl/impl.py", line 247, in _exec
       return conn.execute(construct, params)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1385, in execute
       return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection
       return connection._execute_ddl(
              ^^^^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1477, in _execute_ddl
       ret = self._execute_context(
             ^^^^^^^^^^^^^^^^^^^^^^
     File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1953, in _execute_context
       self._handle_dbapi_exception(
     File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2134, in _handle_dbapi_exception
       util.raise_(
     File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
       raise exception
     File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1910, in _execute_context
       self.dialect.do_execute(
     File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
       cursor.execute(statement, parameters)
   sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateTable) relation "dashboards" already exists
   
   [SQL:
   CREATE TABLE dashboards (
   	created_on TIMESTAMP WITHOUT TIME ZONE NOT NULL,
   	changed_on TIMESTAMP WITHOUT TIME ZONE NOT NULL,
   	id SERIAL NOT NULL,
   	dashboard_title VARCHAR(500),
   	position_json TEXT,
   	created_by_fk INTEGER,
   	changed_by_fk INTEGER,
   	PRIMARY KEY (id),
   	FOREIGN KEY(created_by_fk) REFERENCES ab_user (id),
   	FOREIGN KEY(changed_by_fk) REFERENCES ab_user (id)
   )
   
   ]
   (Background on this error at: https://sqlalche.me/e/14/f405)
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   5.0.0
   
   ### Python version
   
   3.11
   
   ### Node version
   
   18 or greater
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
   - [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
   - [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Db restoration issue from version 4.1.1 to 5.0.0 [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #34332:
URL: https://github.com/apache/superset/issues/34332#issuecomment-4898756942

   Closing this since it's a deployment issue, not a Superset bug: alembic tried to run the Init migration because the restored metadata DB was missing/out-of-sync on alembic_version (DuplicateTable on 'dashboards'). Fix is restoring alembic_version correctly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Db restoration issue from version 4.1.1 to 5.0.0 [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #34332:
URL: https://github.com/apache/superset/issues/34332#issuecomment-3124049017

   <!-- Answer -->
   The error happens because Alembic thinks your metadata database is uninitialized—it’s trying to run the very first migration, which creates tables like dashboards that already exist. This usually means the alembic_version table in your metadata DB is missing, empty, or has the wrong value. Superset relies on this table to know which migrations have already run; if it’s out of sync, you’ll get “table already exists” errors when upgrading [see migration script](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/migrations/versions/2015-09-21_17-30_4e6a06bad7a8_init.py).
   
   To fix:  
   1. Back up your metadata database.
   2. Inspect the alembic_version table (e.g., `SELECT * FROM alembic_version;`).  
      - If it’s missing, create it:  
        ```sql
        CREATE TABLE alembic_version (version_num VARCHAR(32) NOT NULL);
        ```
      - If it’s empty or wrong, set it to your last known good revision (for you: `48cbb571fa3a`):  
        ```sql
        DELETE FROM alembic_version;
        INSERT INTO alembic_version (version_num) VALUES ('48cbb571fa3a');
        ```
   3. Re-run `superset db upgrade`.
   
   If you’ve had failed or partial migrations before, your schema might be inconsistent—consider testing the upgrade on a DB copy first. The official docs don’t require any special steps for this upgrade path [docs](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/docs/docs/installation/upgrading-superset.mdx).
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/bc34f8c3-a5dc-4b0a-bba2-06462a6b5219?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/bc34f8c3-a5dc-4b0a-bba2-06462a6b5219?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/bc34f8c3-a5dc-4b0a-bba2-06462a6b5219?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/bc34f8c3-a5dc-4b0a-bba2-06462a6b5219?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/bc34f8c3-a5dc-4b0a-bba2-06462a6b5219?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/bc34f8c3-a5dc-4b0a-bba2-06462a6b5219?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/bc34f8c3-a5dc-4b0a-bba2-06462a6b5219?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=githu
 b)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/34332)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Db restoration issue from version 4.1.1 to 5.0.0 [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed issue #34332: Db restoration issue from version 4.1.1 to 5.0.0
URL: https://github.com/apache/superset/issues/34332


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org