LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
[MISC] Fix flaky integration CI: rig Postgres lock limit and unmocked pg_barrier dispatch (#2308)
Rahul Johny9b76d929228f
diff --git a/tests/rig/runtime.py b/tests/rig/runtime.pyindex 87941e11a..52a2840c2 100644--- a/tests/rig/runtime.py+++ b/tests/rig/runtime.py@@ -333,7 +333,13 @@ class TestcontainersRuntime:# __post_init__ invariant (host without port) is self-cleaning;# otherwise a partial spec leaks the four containers we just started.try:- pg = PostgresContainer("pgvector/pgvector:pg15")+ # Every xdist worker migrates its own test database in one+ # transaction, each holding a lock per table and constraint. The+ # default of 64 overflows the shared lock table intermittently+ # ("out of shared memory") and errors the whole backend group.+ pg = PostgresContainer("pgvector/pgvector:pg15").with_command(+ "postgres -c max_locks_per_transaction=256"+ )pg.start()self._stack.append(pg)redis = RedisContainer("redis:7.2.3").start()diff --git a/workers/tests/test_pg_barrier.py b/workers/tests/test_pg_barrier.pyindex dcae190e9..6d22d604e 100644--- a/workers/tests/test_pg_barrier.py+++ b/workers/tests/test_pg_barrier.py@@ -27,7 +27,6 @@ from queue_backend.pg_barrier import (_barrier_pg_decrement,_fire_barrier_callback,barrier_pg_abort,- _barrier_pg_decrement,claim_batch,run_batch_with_barrier,try_claim_orchestration,@@ -850,13 +849,14 @@ class TestPgBarrierEnqueue:# expired nor stale. (UN-3661)monkeypatch.setenv("WORKER_BARRIER_KEY_TTL_SECONDS", "600")task, _ = _mock_header_task()- PgBarrier().enqueue(- [task],- callback_task_name="cb",- callback_kwargs={"execution_id": "exec-SD"},- callback_queue="general",- app_instance=None,- )+ with patch("queue_backend.dispatch.dispatch"):+ PgBarrier().enqueue(+ [task],+ callback_task_name="cb",+ callback_kwargs={"execution_id": "exec-SD"},+ callback_queue="general",+ app_instance=None,+ )assert 590 <= _expires_in_seconds(barrier_db, "exec-SD") <= 600 # ~ttl capassert _last_progress_age_seconds(barrier_db, "exec-SD") < 5 # fresh@@ -920,34 +920,37 @@ class TestPgBarrierEnqueue:" now() + interval '1h', now())")task, _ = _mock_header_task()- PgBarrier().enqueue(- [task, _mock_header_task()[0]],- callback_task_name="cb",- callback_kwargs={"execution_id": "exec-R"},- callback_queue="general",- app_instance=None,- )+ with patch("queue_backend.dispatch.dispatch"):+ PgBarrier().enqueue(+ [task, _mock_header_task()[0]],+ callback_task_name="cb",+ callback_kwargs={"execution_id": "exec-R"},+ callback_queue="general",+ app_instance=None,+ )assert _row(barrier_db, "exec-R") == (2, [])def test_enqueue_stamps_organization_id(self, barrier_db):# The whole reason the org column + migration exist (reaper recovery).- PgBarrier().enqueue(- [_mock_header_task()[0]],- callback_task_name="cb",- callback_kwargs={"execution_id": "exec-ORG", "organization_id": "org-42"},- callback_queue="general",- app_instance=None,- )+ with patch("queue_backend.dispatch.dispatch"):+ PgBarrier().enqueue(+ [_mock_header_task()[0]],+ callback_task_name="cb",+ callback_kwargs={"execution_id": "exec-ORG", "organization_id": "org-42"},+ callback_queue="general",+ app_instance=None,+ )assert _org(barrier_db, "exec-ORG") == "org-42"def test_enqueue_defaults_org_to_empty_when_absent(self, barrier_db):- PgBarrier().enqueue(- [_mock_header_task()[0]],- callback_task_name="cb",- callback_kwargs={"execution_id": "exec-NOORG"}, # no organization_id- callback_queue="general",- app_instance=None,- )+ with patch("queue_backend.dispatch.dispatch"):+ PgBarrier().enqueue(+ [_mock_header_task()[0]],+ callback_task_name="cb",+ callback_kwargs={"execution_id": "exec-NOORG"}, # no organization_id+ callback_queue="general",+ app_instance=None,+ )assert _org(barrier_db, "exec-NOORG") == ""def test_upsert_refreshes_org_on_reenqueue(self, barrier_db):@@ -960,13 +963,14 @@ class TestPgBarrierEnqueue:"VALUES ('exec-REORG', 'old-org', 1, '[]'::jsonb, now(), "" now() + interval '1h', now())")- PgBarrier().enqueue(- [_mock_header_task()[0]],- callback_task_name="cb",- callback_kwargs={"execution_id": "exec-REORG", "organization_id": "new-org"},- callback_queue="general",- app_instance=None,- )+ with patch("queue_backend.dispatch.dispatch"):+ PgBarrier().enqueue(+ [_mock_header_task()[0]],+ callback_task_name="cb",+ callback_kwargs={"execution_id": "exec-REORG", "organization_id": "new-org"},+ callback_queue="general",+ app_instance=None,+ )assert _org(barrier_db, "exec-REORG") == "new-org"def test_mid_loop_dispatch_failure_deletes_row(self, barrier_db):