fix: address PR #836 review — forward task_producer to MCP contexts + cleanups

🔴 nc_get_vector_sync_status reported pending=0 for INGEST_QUEUE=postgres: the
AppContext/OAuthAppContext per-session yields snapshotted the stream fields but
never forwarded task_producer, so lifespan_ctx.task_producer was always None.
Convert task_producer to a @property that reads _vector_sync_state live (like
eviction_task_group), removing the snapshot field so the yields can't drop it.
Add a regression test pinning the contract on both contexts.

🟡 Remove the unused _RECLAIM_TASK_NAME constant.
🟡 get_procrastinate_conninfo: warn + document that DATABASE_URL query params
   (application_name, connect_timeout, …) are dropped.
🟡 worker: open the procrastinate App once — apply_ingest_queue_schema gains
   manage_connection=False so the worker reuses its own open connector instead
   of a redundant open/close before run_worker_async.

🟢 Clarify the apply-schema broad-except comment (non-race errors re-raise) and
   document the deliberate Any typing in ingest_status.get_ingest_pending.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-06-03 12:40:50 +02:00
co-authored by Claude Opus 4.8
parent 63e073c224
commit cfdef3c2c5
6 changed files with 110 additions and 26 deletions
+5 -2
View File
@@ -326,9 +326,12 @@ def worker(concurrency: int | None):
app = get_procrastinate_app()
async def _run() -> None:
# Defensive apply (the always-on API pod is the authoritative applier).
await apply_ingest_queue_schema(app)
# Open the connector pool once and reuse it for both the defensive
# schema apply (the always-on API pod is the authoritative applier) and
# the worker loop — manage_connection=False avoids a redundant
# open/close cycle on startup.
async with app.open_async():
await apply_ingest_queue_schema(app, manage_connection=False)
click.echo(
f"Ingest worker started: queue={INGEST_QUEUE_NAME} concurrency={workers}"
)