[MISC] Fix flaky integration CI: rig Postgres lock limit and unmocked pg_barrier dispatch - #2308
Merged
Merged
Conversation
…ier enqueue tests
The integration tier fails intermittently for two unrelated reasons.
Backend: every xdist worker migrates its own test database in one
transaction, holding a lock per table and constraint. The rig's Postgres
runs with the default max_locks_per_transaction=64, so the shared lock
table overflows at random ("out of shared memory") and errors hundreds of
backend tests at setup. Start the container with 256.
Workers: five TestPgBarrierEnqueue tests never mocked
queue_backend.dispatch.dispatch. Since UN-4078 made the PG queue the only
transport, enqueue really dispatches the headers, opening a connection
from DB_* env (default host unstract-db) instead of the TEST_DB_* test
database. Wrap them in the same patch their neighbours use. Also drop a
duplicated _barrier_pg_decrement import.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
muhammad-ali-e
approved these changes
Sep 30, 2026
|
Contributor
|
Contributor
Unstract test resultsPer-group results
Critical paths
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
max_locks_per_transaction=256(tests/rig/runtime.py).queue_backend.dispatch.dispatchin the 5TestPgBarrierEnqueuetests that were really dispatching (workers/tests/test_pg_barrier.py), and drop a duplicated_barrier_pg_decrementimport in the same file.Why
The integration tier fails intermittently, in OSS and in every downstream cloud run, which tests against OSS
main. Seen today onZipstack/unstract-cloudmain (a run failed at 11:21 and the same commit passed at 11:23) and on the v0.182.0 release PR (Zipstack/unstract-cloud#1808), which failed on its first run and again on a re-run.out of shared memory/ "increase max_locks_per_transaction". Every xdist worker migrates its own test database in one transaction, holding a lock per table and constraint. With the Postgres default of 64, the shared lock table overflows at random and errors the backend tests while their database is being set up: 704 errors on the first run, 47 on the re-run.could not translate host name "unstract-db". UN-4078 (UN-4078 [MISC] Remove the Celery execution transport from the workers, backend and SDK #2284) made the PG queue the only transport, soPgBarrier.enqueuenow really sends the headers. These 5 tests never mocked that, so it opened a connection fromDB_*env (default hostunstract-db) instead of theTEST_DB_*test database. The rest of the class already wrapsenqueueinpatch("queue_backend.dispatch.dispatch").How
PostgresContainer("pgvector/pgvector:pg15").with_command("postgres -c max_locks_per_transaction=256").enqueuein the same patch their neighbours use. Their assertions are unchanged; they check the barrier row, not the dispatch.Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
pgvector/pgvector:pg15via testcontainers with the new command.SHOW max_locks_per_transactionreturns256and the container passes its readiness wait. The effect on the flake can only be confirmed in CI.pg_barrier_state/pg_batch_deduptables created by hand from the models, andDB_HOSTunset, as in CI:main's copy of the file: the same 5 tests fail withcould not translate host name "unstract-db", matching CI.TestPgBarrierEnqueue10/10 passed; whole file 99 passed.ruff checkis clean on both files.ruff format --checkflags both files, but it flagsmain's copies identically, so that's pre-existing and not touched here.Screenshots
Checklist
I have read and understood the Contribution Guidelines.
🤖 Generated with Claude Code