Skip to content

Fixes #33514: serialize the DAG-scan fork so concurrent pipeline deploys don't fail - #33515

Merged
ShaileshParmar11 merged 2 commits into
mainfrom
fix/airflow-apis-concurrent-deploy-fork
Sep 17, 2026
Merged

ShaileshParmar11 merged 2 commits into
mainfrom
fix/airflow-apis-concurrent-deploy-fork

Conversation

@ShaileshParmar11

@ShaileshParmar11 ShaileshParmar11 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #33514

Concurrent ingestion pipeline deploys (bulk Re Deploy) intermittently failed one pipeline with airflow API returned Internal Server Error … "An unexpected problem occurred". This is also why TestSuitePipelineRedeploy.spec.ts › Re-deploy all test-suite ingestion pipelines failed on every attempt in merge-queue runs 35178258079 and 35215269052.

Root cause. Every deploy ends with scan_dags_job_background(), which forks a multiprocessing.Process from the Airflow API server's request thread. filelock==3.32.2 (pinned by ingestion/airflow-constraints-3.3.1.txt) installs an os.fork audit hook that raises RuntimeError("os.fork is unsafe while filelock is changing descriptor ownership") while any other thread is inside its own fork. Two deploys arriving together fork at once, one raises, and the exception escapes DagDeployer.deploy() into the route's generic 500 handler, after that DAG was already written and synced.

Fix. Hold a module-level threading.Lock around process.start() in scan_dags_job_background, the plugin's only fork site. The lock covers the fork only; scans still run in parallel once started.

Evidence:

  • CI server logs: each failed attempt was two deploys in the same second, one 400 and one 200; single deploys in the same shards all returned 200. The plugin traceback isn't in CI artifacts: the plugin logs only to /opt/airflow/logs/openmetadata_airflow_api.log, and CI collects docker logs.
  • Local stack built from the same ingestion/Dockerfile.ci (Airflow 3.3.1, Python 3.12, filelock 3.32.2): 2 of 20 concurrent deploy pairs failed with the identical 400, and the plugin log showed the os.fork is unsafe error for both.
  • Same image, two threads starting a Process concurrently: 85/200 rounds fail with filelock imported, 0/200 without it, 0/200 with the lock.

Type of change:

  • Bug fix

High-level design:

N/A — small change (2 files).

Tests:

Use cases covered

  • Two ingestion pipelines deployed at the same moment (bulk Re Deploy) both deploy successfully.

Unit tests

  • Added test_concurrent_dag_scans_can_fork in openmetadata-airflow-apis/tests/unit/test_helpers.py. It calls the real scan_dags_job_background() from two threads for 50 rounds, with filelock imported and a no-op scan body, and asserts no fork raised.
  • Before the fix: failed 3/3 runs. After: tests/unit/test_helpers.py passed 3/3 runs (4 tests, ~1s). Run inside the Airflow 3.3.1 ingestion container.
  • Coverage %: not measured; the change is a 3-line lock in scan_dags_job_background, which the new test executes.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (no connector changes).

Playwright (UI) tests

  • Not applicable (no UI changes). The existing playwright/e2e/Features/TestSuitePipelineRedeploy.spec.ts covers this path end to end; this PR's Ingestion shard exercises it against a rebuilt Airflow image (openmetadata-airflow-apis/ is part of the ingestion image fingerprint).

Manual testing performed

  1. Local stack from docker/development/docker-compose.yml (Airflow 3.3.1 ingestion image).
  2. Sent pairs of concurrent POST /api/v1/services/ingestionPipelines/deploy/{id} requests for two TestSuite pipelines: intermittent 400, and openmetadata_airflow_api.log showed Internal error deploying [...] due to [os.fork is unsafe while filelock is changing descriptor ownership].
  3. Reproduced the fork race in isolation in the same container and confirmed the lock removes it (numbers above).
  4. Not done: end-to-end deploy loop against a container running the patched plugin (that needs a rebuilt image); this PR's Playwright Ingestion shard covers it.

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. — N/A, no schema changes.
  • For UI changes: I attached a screen recording and/or screenshots above. — N/A, no UI changes.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing. For complex issues, comment the issue number in the test for future reference.

🤖 Generated with Claude Code

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with the concurrency fix covered by a platform-appropriate regression test.

Summary

This PR prevents concurrent ingestion-pipeline deployments from racing while starting DAG-scan child processes.

  • Adds a module-level lock that serializes only Process.start(), allowing the scans themselves to continue concurrently.
  • Adds a concurrency regression test covering simultaneous DAG-scan process starts.
  • Restricts the fork-specific regression test to environments whose multiprocessing start method is fork, resolving the previous cross-platform test concern.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Concurrent deploy request A] --> L[Fork lock]
    B[Concurrent deploy request B] --> L
    L --> FA[Start DAG-scan process A]
    L --> FB[Start DAG-scan process B]
    FA --> SA[Scan A runs independently]
    FB --> SB[Scan B runs independently]
Loading

Reviews (2) · Last reviewed commit: "test(airflow-apis): run the concurrent-f..."

…don't fail

Every deploy forks a background DAG scan from the API server's request
thread. filelock 3.32 (pinned by the Airflow 3.3.1 constraints) installs an
os.fork audit hook that raises RuntimeError while another thread is inside
its own fork, so two deploys landing together (bulk Re Deploy) failed one of
them with a 500 after its DAG was already synced.

Hold a module-level lock around Process.start(). Adds a regression test that
forks scans from two threads; it fails without the lock.

Co-Authored-By: Claude Opus 5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 17, 2026 13:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Sep 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit e574a38d7d5be43ec76f5a8e83d8f1fb8bd9da3b in Playwright run 35233285288, attempt 1.

✅ 4510 passed · ❌ 0 failed · 🟡 5 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 1h 0m 34s

⏱️ Max setup 4m 41s · max shard execution 23m 1s · max shard-job elapsed before upload 26m 39s · reporting 17s

🌐 219.31 requests/attempt · 2.23 app boots/UI scenario · 35.63% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 35.63% (convergence target: at most 15%).
  • Browser traffic was 219.31 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.23 per UI scenario (10701 boots / 4801 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard advanced-search-01 130 0 0 0 0 0
✅ Shard chromium-01 163 0 0 0 0 0
🟡 Shard chromium-02 164 0 1 0 0 0
✅ Shard chromium-03 177 0 0 0 0 0
✅ Shard chromium-04 230 0 0 0 0 0
✅ Shard chromium-05 169 0 0 0 0 0
✅ Shard chromium-06 194 0 0 0 0 0
✅ Shard chromium-07 165 0 0 0 0 0
✅ Shard chromium-08 171 0 0 0 0 0
✅ Shard chromium-09 168 0 0 1 0 0
✅ Shard chromium-10 163 0 0 0 0 0
✅ Shard chromium-11 180 0 0 0 0 0
✅ Shard chromium-12 160 0 0 0 0 0
✅ Shard chromium-13 190 0 0 0 0 0
✅ Shard chromium-14 178 0 0 0 0 0
🟡 Shard chromium-15 186 0 1 0 0 0
🟡 Shard chromium-16 214 0 1 0 0 0
🟡 Shard chromium-17 210 0 1 0 0 0
✅ Shard chromium-18 168 0 0 0 0 0
🟡 Shard chromium-19 200 0 1 0 0 0
✅ Shard chromium-20 164 0 0 0 0 0
✅ Shard chromium-21 168 0 0 0 0 0
✅ Shard chromium-22 166 0 0 0 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard import-export-01 80 0 0 0 0 0
✅ Shard import-export-02 70 0 0 0 0 0
✅ Shard ingestion-01 43 0 0 0 0 0
✅ Shard ingestion-02 55 0 0 0 0 0
✅ Shard reindex-01 28 0 0 0 0 0
✅ Shard search-01 12 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0
🟡 5 flaky test(s) (passed on retry)
  • Features/UserProfileOnlineStatus.spec.ts › Should show "Active recently" for users active within last hour (shard chromium-02, 1 retry)
  • Flow/CustomizeWidgets.spec.ts › KPI Widget (shard chromium-15, 1 retry)
  • Flow/Tour.spec.ts › Tour should work from help section (shard chromium-16, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard chromium-17, 1 retry)
  • Features/ChangeSummaryBadge.spec.ts › AI badge should appear on column description with Suggested source (shard chromium-19, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

This branch was previously deployed

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

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bulk Re Deploy fails one pipeline with Airflow 500 when deploys run concurrently (Airflow 3.3.1)

3 participants