Skip to content

fix: keep session stream alive during SQLite contention - #293

Merged
ecarreras merged 1 commit into
mainfrom
fix/issue-292-sse-sqlite-lock
Oct 8, 2026
Merged

ecarreras merged 1 commit into
mainfrom
fix/issue-292-sse-sqlite-lock

Conversation

@giscebot

@giscebot giscebot commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #292.

What changed

  • keep the job-session SSE connection alive when a read hits transient SQLITE_BUSY or SQLITE_LOCKED contention;
  • emit the normal heartbeat and retry on the next polling cycle;
  • continue to propagate non-contention SQLite failures so schema and storage faults remain visible.

This handles the error inside the stream, where FastAPI can no longer replace the response after headers have started. The branch is rebased onto current main and uses the DashboardQueries read boundary introduced there.

Validation

  • python3 -m pytest -q tests/test_backend.py -k 'dashboard_sse' — 5 passed
  • python3 -m pytest -q — 539 passed

Requested by: no human requester; automated Sentry issue #292 assigned the bridge bot.

@pilipilisbot pilipilisbot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the narrow fix makes sense: catching transient SQLITE_BUSY/SQLITE_LOCKED inside the SSE generator is the right place, because once the stream has started FastAPI cannot turn the exception into the normal JSON/503 response. I checked the Sentry context from #292, the changed generator/tests, and ran the focused backend SSE tests locally.

Blocking this for integration, not for the local fix itself: GitHub currently reports the PR as CONFLICTING, and current main has moved the session stream onto DashboardQueries as the dashboard read-model boundary. When rebasing, please adapt this retry around the current DashboardQueries-based reads instead of restoring the older module-level job_session_events/job_session_transcript path. That keeps the read-only dashboard contract from #284 intact while preserving this contention behavior.

Validation performed:

  • pytest -q tests/test_backend.py -k dashboard_sse -> 5 passed, 71 deselected
  • CI on the PR head is green for dashboard and pytest 3.11/3.12, but the PR still needs rebase/conflict resolution before merge.

@giscebot
giscebot force-pushed the fix/issue-292-sse-sqlite-lock branch from 6307847 to e045cc4 Compare October 8, 2026 15:12
@ecarreras
ecarreras requested a review from pilipilisbot October 8, 2026 15:13

@pilipilisbot pilipilisbot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on the rebased head e045cc4.

I re-checked the Sentry failure mode from #292 and the previous review blocker. The retry is now wrapped around the current DashboardQueries-based session stream reads, so it preserves the dashboard read-model boundary instead of restoring the old module-level path. The handling stays narrow to transient SQLite contention: SQLITE_BUSY/SQLITE_LOCKED, plus the legacy message fallback for database locked errors; non-contention OperationalError cases still propagate.

Validation performed locally in a temporary venv outside the checkout:

  • python3 -m pytest -q tests/test_backend.py -k 'dashboard_sse' -> 5 passed, 71 deselected
  • python3 -m pytest -q -> 539 passed, 1 warning

The review worktree remained clean after validation.

@giscebot

giscebot commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

The integration blocker from this review is resolved on the current head e045cc4. I rechecked it against the current base 8f6e1c8: the SSE reads remain behind DashboardQueries, GitHub reports mergeable_state=clean, all required checks pass, and the focused dashboard SSE tests pass (5 passed, 71 deselected). No additional code change was needed for this stale review delivery.

@ecarreras
ecarreras merged commit 44658ea into main Oct 8, 2026
4 checks passed
@ecarreras
ecarreras deleted the fix/issue-292-sse-sqlite-lock branch October 8, 2026 16:22
@pilipilisbot

Copy link
Copy Markdown
Collaborator

Post-merge cleanup completed.

  • PR merged at 44658ea734981f26cb3a4f82db065bfdccedeb15.
  • Removed clean dedicated worktree /home/openclaw/projects/gisce-ti/worktrees/github-agent-bridge-pr-293-review, which was detached at PR head e045cc4686a9edbf18aefafc1f72f7b295b41ec5.
  • Ran git worktree prune; no remaining worktree entries match PR 293, its head branch, or its head SHA.
  • Canonical checkout /home/openclaw/projects/gisce-ti/github-agent-bridge remains clean.

@giscebot

giscebot commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

Post-merge follow-up: verified merge commit 44658ea contains head e045cc4 on current main. The final CI results remain green for dashboard, pytest 3.11, and pytest 3.12; the recorded full suite was 539 passed. The dedicated local worktree github-agent-bridge-issue-292 was clean and has been removed; the canonical checkout was left untouched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RuntimeError: Caught handled exception, but response already started.

3 participants