fix(state): degrade list_sessions_rich on stale read-only profile DBs - #80126
Closed
JuizSpeaking wants to merge 1 commit into
Closed
fix(state): degrade list_sessions_rich on stale read-only profile DBs#80126JuizSpeaking wants to merge 1 commit into
JuizSpeaking wants to merge 1 commit into
Conversation
The desktop sidebar aggregates every profile's state.db read-only, and read-only opens deliberately skip schema reconciliation. A dormant profile's DB can therefore be older than the running binary, missing columns the list queries select unconditionally (last_activity_at, last_read_at, pinned, ...). The sidebar's per-profile try/except then swallows the 'no such column' error and silently drops the whole profile from the session list — reads as 'sessions are gone'. list_sessions_rich now probes the live sessions columns once per SessionDB instance and degrades instead of raising: - activity expression falls back to messages-max + started_at when last_activity_at is absent (UNION ALL keeps a NULL arm so the MAX subquery stays well-formed) - compact projection is intersected with the live columns - pinned back-fill is skipped when the pinned column is absent The compression-tip batch fetch (_get_session_rich_rows_batch) follows the same guard since it backs list_sessions_rich's projection. Adds regression tests covering a genuinely stale read-only DB.
Collaborator
|
Appreciate the contribution! Closed by #80797 |
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
The desktop sidebar (
GET /api/profiles/sessions/sidebar) aggregates every profile'sstate.dbread-only, and read-only opens deliberately skip schema reconciliation. A dormant profile's DB can therefore be older than the running binary, missing columns the list queries select unconditionally (last_activity_at,last_read_at,pinned, …). The sidebar's per-profiletry/exceptthen swallows the resultingno such columnerror and silently drops the whole profile from the session list — which reads as "all sessions are gone except the active profile's."Fix
list_sessions_richnow probes the livesessionscolumns once perSessionDBinstance and degrades instead of raising on stale-schema read-only opens:_sql_session_last_active/_by_id): falls back toMAX(messages.timestamp)+started_atwhenlast_activity_atis absent. TheUNION ALLkeeps aNULLarm so theMAXsubquery stays well-formed._compact_session_cols_live): intersected with the live columns, socompact_rows=Truenever selects a column the DB doesn't have.pinnedcolumn is absent._get_session_rich_rows_batch): follows the same guard since it backslist_sessions_rich's projection.Writable opens are unaffected: they still reconcile the schema at startup, so the probe always sees the full column set there.
Tests
New
tests/test_hermes_state_readonly_stale_schema.py:compact_rowslisting against a genuinely stale read-only DB returns rows (degradedlast_active) instead of raising_compact_session_cols_liveintersection behaviorFocused suite: 216 passed (state, readonly-preflight, WAL-fallback + new file).
Repro