fix(db,frontend): reserve DB connections for API and reduce frontend polling

Background tasks (ingestion, PDF resolution, scheduler) now acquire an
asyncio.Semaphore before checking out a DB connection, guaranteeing at
least N connections remain available for API request handlers. Removes
duplicate polling loop from PublicationsPage, debounces publication
reload on run-status changes, and increases poll interval from 5s to 15s
since SSE handles live discovery.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Justin Visser 2026-03-02 19:09:06 +01:00
parent a490e14126
commit f50b609a36
11 changed files with 97 additions and 69 deletions

View file

@ -221,11 +221,11 @@ def _spawn_background_execution(
user_settings: Any,
idempotency_key: str | None,
) -> None:
from app.db.session import get_session_factory
from app.db.background_session import background_session
task = asyncio.create_task(
ingest_service.execute_run(
session_factory=get_session_factory(),
session_factory=background_session,
run_id=run.id,
user_id=current_user.id,
scholars=scholars,