Skip to content

Fix shared preaggregation template reader race - #2757

Open
Miskho wants to merge 1 commit into
DataJunction:mainfrom
Miskho:codex/dj-fix-preagg-template-race
Open

Miskho wants to merge 1 commit into
DataJunction:mainfrom
Miskho:codex/dj-fix-preagg-template-race

Conversation

@Miskho

@Miskho Miskho commented Nov 26, 2026

Copy link
Copy Markdown

Parallel server tests can fail during fixture setup with psycopg.errors.AdminShutdown when one worker reads preaggregation IDs from the shared template_preaggs database while another worker clones it. The clone helper terminates connections to its source template, so the disconnected reader causes subsequent tests on that worker to fail setup.

Yield only the template name and load ordered preaggregation objects through each test's existing private-clone session. This preserves per-test isolation and the preagg1 through preagg10 ordering without opening metadata readers on the shared template. Add a deterministic real-Postgres regression that interleaves cloning before any shared-template read.

Validation (Python 3.13):

  • The regression failed before the fix with the same AdminShutdown error.
  • pytest -q tests/api/preaggregations_test.py --tb=short: 91 passed with locally managed Postgres.
  • pytest -n 3 --dist=loadscope -q tests/api/preaggregations_test.py --tb=short: 91 passed using DJ_TEST_POSTGRES_URL and all three templates prebuilt as in CI.
  • pre-commit run --files datajunction-server/tests/api/preaggregations_test.py: all applicable checks passed, including Ruff, formatting and mypy.

This changes only test fixtures and their regression coverage. It is independent of the compiler changes in #2755, whose CI exposed the race. The full server suite and the Python 3.12 CI matrix were not rerun locally.

@netlify

netlify Bot commented Nov 26, 2026

Copy link
Copy Markdown

👷 Deploy request for thriving-cassata-78ae72 pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 59b095a

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Moves preaggregation metadata reads from the shared template to each test’s private database.

  • Pre-aggregation tests load their setup rows from each private clone.

Reviews (1) · Last reviewed commit: "Fix shared preaggregation template reade..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant