Skip to content

fix(migrations): merge the two alembic heads on master - #44317

Closed
mikebridge wants to merge 2 commits into
apache:masterfrom
mikebridge:fix-alembic-merge-two-heads
Closed

mikebridge wants to merge 2 commits into
apache:masterfrom
mikebridge:fix-alembic-merge-two-heads

Conversation

@mikebridge

Copy link
Copy Markdown
Member

SUMMARY

superset db upgrade currently fails on master. Two migrations landed as siblings rather than in a chain, so the revision graph has two heads:

revision migration from
88a01c781622 index_ab_user_lower_username #43939
c7f53d184ea2 coordinate_purge_audit_pruning #43490

Both are childless — nothing declares either as its down_revision — so alembic cannot resolve head:

ERROR [flask_migrate] Error: Multiple head revisions are present for given argument 'head';
please specify a specific target revision, '<branchname>@head' to narrow to a specific head,
or 'heads' for all heads

This blocks anyone running migrations on master, including a fresh install and CI jobs that upgrade a database.

Neither migration depends on the other (one adds a functional index on ab_user, the other coordinates purge-audit pruning), so this is an empty merge: upgrade() and downgrade() are both pass, and the revision exists only to rejoin the graph. One file, no schema change.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Verified against a fresh, empty PostgreSQL database, both directions:

without this revision (master today):
  ERROR [flask_migrate] Error: Multiple head revisions are present ...
  superset.app: The script directory has multiple heads (due to branching).

with this revision:
  superset db upgrade -> exit 0
  select version_num from alembic_version  ->  e2f0a912492a   (single head)

TESTING INSTRUCTIONS

superset db upgrade          # from an empty database: completes, single head

Or inspect the graph directly — alembic heads should report exactly one revision. Note that a naive regex over the migration files gives the wrong answer here: several existing merge migrations declare down_revision as a multi-line tuple, so a parser that only handles the single-string form reports dozens of spurious heads. An AST walk over all 388 revisions returns exactly one with this change, and exactly the two above without it.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Migration notes: the revision is empty in both directions, so upgrade and downgrade are instantaneous, require no locks, and need no downtime. No UPDATING.md entry — there is no behavioural change to describe.

🤖 Generated with Claude Code

https://claude.ai/code/session_01267VBWbvWTNZUg9GvXKgkC

`88a01c781622` (functional index on `ab_user(lower(username))`, apache#43939)
and `c7f53d184ea2` (purge-audit pruning coordination, apache#43490) landed as
siblings rather than in a chain, leaving the revision graph with two
heads. Every `superset db upgrade` against master fails:

    ERROR [flask_migrate] Error: Multiple head revisions are present for
    given argument 'head'; please specify a specific target revision,
    '<branchname>@Head' to narrow to a specific head, or 'heads' for all
    heads

Neither migration depends on the other, so this is an empty merge that
only rejoins the graph — no schema change, and nothing to undo.

Verified from an empty PostgreSQL database: `superset db upgrade` fails
with the error above without this revision and completes cleanly with
it, leaving a single `alembic_version` of `e2f0a912492a`.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01267VBWbvWTNZUg9GvXKgkC
@bito-code-review

bito-code-review Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #cd14be

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: fa047a4..fa047a4
    • superset/migrations/versions/2026-09-15_00-30_e2f0a912492a_merge_ab_user_index_with_purge_audit_.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@github-actions github-actions Bot added the risk:db-migration PRs that require a DB migration label Sep 15, 2026
@codecov

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.23%. Comparing base (a184395) to head (c36a240).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #44317      +/-   ##
==========================================
+ Coverage   75.91%   80.23%   +4.32%     
==========================================
  Files        2926     2926              
  Lines      173041   173041              
  Branches    40145    40145              
==========================================
+ Hits       131359   138842    +7483     
+ Misses      39003    31607    -7396     
+ Partials     2679     2592      -87     
Flag Coverage Δ
hive 37.35% <ø> (?)
mysql 56.92% <ø> (?)
postgres 56.95% <ø> (?)
presto 39.45% <ø> (?)
python 84.65% <ø> (+8.51%) ⬆️
sqlite 56.64% <ø> (?)
unit 76.14% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aminghadersohi

Copy link
Copy Markdown
Contributor

Coordinating baseline repair for #44284: its 15 failing checks (integration, browser, CLI examples, dev image, and dependent required gates) are blocked by these same two Alembic heads. #44288 is an earlier no-op merge of the identical parents, and #44283 also joins them in its data migration. Please land only one merge revision and rebase/reparent the others, or the two-head failure will return. I will rebase #44284 onto the selected repair after it lands and rerun its CI; I will not merge these PRs. @mikebridge @richardfogaca

@mikebridge

Copy link
Copy Markdown
Member Author

Closing in favour of @aminghadersohi 's #44288

@mikebridge mikebridge closed this Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:db-migration PRs that require a DB migration size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants