fix(kanban): run column migrations before SCHEMA_SQL on existing DBs - #29203
Closed
maskiey wants to merge 1 commit into
Closed
fix(kanban): run column migrations before SCHEMA_SQL on existing DBs#29203maskiey wants to merge 1 commit into
maskiey wants to merge 1 commit into
Conversation
When a gateway is upgraded, the kanban SCHEMA_SQL may reference columns (e.g. session_id) that don't exist in pre-existing databases. The old code ran conn.executescript(SCHEMA_SQL) first, which would fail when trying to CREATE INDEX on a missing column, preventing _migrate_add_optional_columns() from ever running. Fix: check if the tasks table already exists and, if so, run additive column migrations BEFORE SCHEMA_SQL. This ensures all columns exist before any index creation attempts. The post-SCHEMA_SQL migration call is kept (idempotent) to handle fresh databases. Repro: gateway running with a pre-session_id kanban.db would enter a tight retry loop at 100% CPU because every dispatcher tick failed with 'sqlite3.OperationalError: no such column: session_id'.
maskiey
force-pushed
the
fix/kanban-schema-migration-order
branch
from
May 20, 2026 09:07
597cb2f to
8229b35
Compare
Collaborator
|
Duplicate of #28461 / #28781 (merged). The kanban migration ordering bug (SCHEMA_SQL indexes referencing columns not yet added by |
1 task
Contributor
|
Thanks for filing this — the migration-ordering bug is already fixed on current main by the merged #28781. Automated hermes-sweeper review evidence:
Closing as implemented on main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where gateway upgrades cause 100% CPU and broken kanban dispatcher.
Root Cause
conn.executescript(SCHEMA_SQL)references columns (e.g.session_id) via index creation that don't exist in pre-existing databases. The old code ran SCHEMA_SQL first, which would fail when trying toCREATE INDEXon a missing column, preventing_migrate_add_optional_columns()from ever running.Fix
Check if the tasks table already exists before running SCHEMA_SQL. If it does, run additive column migrations FIRST so all columns exist before any index creation attempts. The post-SCHEMA_SQL migration call is kept (idempotent) to handle fresh databases.
Reproduction
session_idcolumnsession_idin SCHEMA_SQLsqlite3.OperationalError: no such column: session_idTest Plan