Skip to content

Commit 7c0e0fb

Browse files
committed
document phoenix alembic downgrade issue
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com> Assisted-by: Claude
1 parent 4ed3166 commit 7c0e0fb

1 file changed

Lines changed: 110 additions & 0 deletions

File tree

README-agents.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,116 @@ Issues can be re-triggered through the workflow in two ways:
145145

146146
The `ymir_fusa` label will be automatically added by the triage agent to JIRA issues involving FuSa packages. Related merge requests will need to be reviewed and approved by subject matter experts before merging.
147147

148+
## Troubleshooting
149+
150+
### Phoenix: Alembic migration failure after version rollback
151+
152+
When Phoenix is rolled back to an older version (e.g. v16 → v15), the SQLite database
153+
contains an Alembic revision from the newer version that the older code doesn't
154+
recognize. Phoenix crashes on startup with:
155+
156+
```
157+
alembic.util.exc.CommandError: Can't locate revision identified by '0ff41b5b118f'
158+
```
159+
160+
The fix is to stamp the database with the head revision the running Phoenix version
161+
expects. For the v16 → v15 rollback, the known revisions are:
162+
163+
| Version | Alembic head revision |
164+
|---------|-----------------------|
165+
| v15 | `575aa27302ee` |
166+
| v16 | `0ff41b5b118f` |
167+
168+
#### Fix locally (podman-compose)
169+
170+
1. Stop Phoenix:
171+
172+
```bash
173+
podman-compose stop phoenix
174+
```
175+
176+
2. Find the volume mount path:
177+
178+
```bash
179+
podman volume inspect ai-workflows_phoenix-data --format '{{.Mountpoint}}'
180+
```
181+
182+
3. Stamp the database:
183+
184+
```bash
185+
python3 -c "
186+
import sqlite3, sys
187+
db = '$(podman volume inspect ai-workflows_phoenix-data --format '{{.Mountpoint}}')/phoenix.db'
188+
conn = sqlite3.connect(db)
189+
cur = conn.cursor()
190+
cur.execute('SELECT version_num FROM alembic_version')
191+
print('Current:', cur.fetchall())
192+
cur.execute(\"UPDATE alembic_version SET version_num = '575aa27302ee' WHERE version_num = '0ff41b5b118f'\")
193+
print('Rows updated:', cur.rowcount)
194+
conn.commit()
195+
cur.execute('SELECT version_num FROM alembic_version')
196+
print('Updated:', cur.fetchall())
197+
conn.close()
198+
"
199+
```
200+
201+
4. Start Phoenix again:
202+
203+
```bash
204+
podman-compose start phoenix
205+
```
206+
207+
#### Fix in OpenShift
208+
209+
1. Scale down Phoenix to release the PVC:
210+
211+
```bash
212+
oc scale deployment phoenix --replicas=0
213+
```
214+
215+
2. Find the head revision the current Phoenix image expects:
216+
217+
```bash
218+
oc debug deployment/phoenix --container=phoenix -- python3 -c "
219+
from alembic.config import Config
220+
from alembic.script import ScriptDirectory
221+
c = Config()
222+
c.set_main_option('script_location', '/usr/local/lib/python3.14/site-packages/phoenix/db/migrations')
223+
s = ScriptDirectory.from_config(c)
224+
print('Head revision:', s.get_current_head())
225+
"
226+
```
227+
228+
3. Update the `alembic_version` in the SQLite database (replace `OLD_REV` and
229+
`NEW_REV` with the values from the table above, or use step 2 output for a
230+
different version pair):
231+
232+
```bash
233+
oc debug deployment/phoenix --container=phoenix -- python3 -c "
234+
import sqlite3
235+
conn = sqlite3.connect('/mnt/data/phoenix.db')
236+
cur = conn.cursor()
237+
cur.execute('SELECT version_num FROM alembic_version')
238+
print('Current:', cur.fetchall())
239+
cur.execute(\"UPDATE alembic_version SET version_num = 'NEW_REV' WHERE version_num = 'OLD_REV'\")
240+
print('Rows updated:', cur.rowcount)
241+
conn.commit()
242+
cur.execute('SELECT version_num FROM alembic_version')
243+
print('Updated:', cur.fetchall())
244+
conn.close()
245+
"
246+
```
247+
248+
4. Scale Phoenix back up:
249+
250+
```bash
251+
oc scale deployment phoenix --replicas=1
252+
```
253+
254+
The stamp only updates Alembic's tracking metadata — any extra columns or indexes
255+
added by the newer version's migrations remain in the database. SQLite tolerates
256+
unused columns, so this is generally safe.
257+
148258
## Advanced Usage
149259

150260
### Automatic Issue Fetching

0 commit comments

Comments
 (0)