SurfSense/surfsense_backend
Matt Van Horn 456dd7417c
fix(connectors): refresh Redis heartbeat during long Phase 1 indexing
Closes #1295

The connector indexing route's `_run_indexing_with_notifications` set the
Redis heartbeat key once at the start of indexing and relied on
`on_heartbeat_callback` (only fired in Phase 2 per-document loops) to
refresh it. The GitHub connector's Phase 1 runs `gitingest` as a blocking
subprocess via `asyncio.to_thread`, so for any repo larger than the
2-minute TTL, the key expires before Phase 2 starts. The
`cleanup_stale_indexing_notifications_task` then marks the document as
failed with the misleading "Sync was interrupted unexpectedly. Please
retry." message — even though the indexing thread is still running and
gitingest's own subprocess timeout is 900 seconds.

Add a background asyncio coroutine that refreshes the Redis key every
60 seconds for the duration of the indexing call. Same pattern already
in use at app/tasks/celery_tasks/document_tasks.py:_run_heartbeat_loop,
just adapted to use the route's get_heartbeat_redis_client() and
_get_heartbeat_key() helpers.

Cancellation runs in the `finally` block BEFORE the heartbeat-key
delete so the loop cannot race and re-create the key after we have
deleted it. The new `HEARTBEAT_REFRESH_INTERVAL = 60` constant mirrors
the celery task module's value.
2026-04-26 02:46:43 -07:00
..
alembic fix: renumber vision_llm migration from 121 to 123 to resolve conflict with upstream 2026-04-11 11:02:44 +02:00
app fix(connectors): refresh Redis heartbeat during long Phase 1 indexing 2026-04-26 02:46:43 -07:00
scripts rewrite snapshot script: use run_commands, dotenv, idempotent delete 2026-04-13 18:29:17 +02:00
tests Merge upstream/dev into feat/kb-export-and-folder-upload 2026-04-11 10:28:40 +02:00
.dockerignore feat: Added Docker Support and missing dependencies. 2025-03-20 18:52:06 -07:00
.env.example add Daytona sandbox env vars to .env.example 2026-04-13 16:23:58 +02:00
.gitignore feat: init video presentation agent 2026-03-21 22:13:41 -07:00
.python-version feat: SurfSense v0.0.6 init 2025-03-14 18:53:14 -07:00
alembic.ini add github connector, add alembic for db migrations, fix bug updating connectors 2025-04-13 13:56:22 -07:00
celery_worker.py fix: celery_app path and gmail indexing 2025-10-21 21:11:41 -07:00
Dockerfile feat: enhance memory management and session handling in database operations 2026-02-28 23:59:28 -08:00
main.py feat: added configable summary calculation and various improvements 2026-02-26 18:24:57 -08:00
pyproject.toml feat: bumped version to 0.0.15 2026-04-08 16:17:37 -07:00
uv.lock feat: bumped version to 0.0.15 2026-04-08 16:17:37 -07:00