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:
co-authored by
Claude Opus 4.8
parent
63e073c224
commit
cfdef3c2c5
@@ -1437,6 +1437,13 @@ def get_procrastinate_conninfo(database_url: str | None = None) -> str:
|
||||
(set ``DATABASE_URL`` to a ``+psycopg`` URL) rather than rewriting the driver
|
||||
in code — see charts repo, not this repo.
|
||||
|
||||
Only the host/port/dbname/user/password components are forwarded; any
|
||||
``?key=value`` query parameters on the URL (e.g. ``application_name``,
|
||||
``connect_timeout``) are **dropped** — TLS is set separately via
|
||||
:func:`_pg_ssl_params`, and SQLAlchemy-specific query options don't map
|
||||
cleanly to libpq keywords. A warning is logged when params are dropped so
|
||||
operators aren't surprised.
|
||||
|
||||
Raises ``ValueError`` for a non-Postgres URL — procrastinate is Postgres-only.
|
||||
"""
|
||||
from psycopg.conninfo import make_conninfo # noqa: PLC0415
|
||||
@@ -1449,6 +1456,13 @@ def get_procrastinate_conninfo(database_url: str | None = None) -> str:
|
||||
f"got driver {url.drivername!r}"
|
||||
)
|
||||
|
||||
if url.query:
|
||||
logging.getLogger(__name__).warning(
|
||||
"Dropping DATABASE_URL query parameters not forwarded to the "
|
||||
"procrastinate connector: %s",
|
||||
", ".join(sorted(url.query)),
|
||||
)
|
||||
|
||||
params: dict[str, str] = {}
|
||||
if url.host:
|
||||
params["host"] = url.host
|
||||
|
||||
Reference in New Issue
Block a user