Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ingest): avoid multiprocessing "fork" start method #12543

Merged
merged 2 commits into from
Feb 4, 2025
Merged

Conversation

hsheth2
Copy link
Collaborator

@hsheth2 hsheth2 commented Feb 3, 2025

We use threads in a variety of places within our CLI. The multiprocessing "fork" start method is not safe to use with threads. MacOS and Windows already default to "spawn", and Linux will as well starting in Python 3.14. See https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods

This fixes a bug where the classification module would deadlock when using more than one worker process. Reverts #12261, since that workaround is no longer required.

By making changes to both the entrypoint and the classification module, we can ensure that

  1. if people use our code via Pipeline.create(...).run(), we will not cause any deadlocks
  2. we will play nice with any dependencies that use multiprocessing

Eventually it may make sense to use "forkserver" as the default where available, but we can revisit that in the future.

Tested locally.

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

We use threads in a variety of places within our CLI. The multiprocessing "fork" start method is not safe to use with threads.
MacOS and Windows already default to "spawn", and Linux will as well starting in Python 3.14.
See https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods

This fixes a bug where the classification module would deadlock when
using more than one worker process.

Eventually it may make sense to use "forkserver" as the default where available, but we can revisit that in the future.
@github-actions github-actions bot added the ingestion PR or Issue related to the ingestion of metadata label Feb 3, 2025
@datahub-cyborg datahub-cyborg bot added the needs-review Label for PRs that need review from a maintainer. label Feb 3, 2025
Copy link

codecov bot commented Feb 3, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
metadata-ingestion/src/datahub/entrypoints.py 50.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (75.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Files with missing lines Coverage Δ
...datahub/ingestion/glossary/classification_mixin.py 89.14% <100.00%> (+5.55%) ⬆️
...stion/src/datahub/ingestion/glossary/classifier.py 95.65% <100.00%> (+0.19%) ⬆️
metadata-ingestion/src/datahub/entrypoints.py 68.57% <50.00%> (-0.27%) ⬇️

... and 14 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f0d475...142cac3. Read the comment docs.

@datahub-cyborg datahub-cyborg bot added pending-submitter-merge and removed needs-review Label for PRs that need review from a maintainer. labels Feb 4, 2025
@hsheth2 hsheth2 merged commit 35e2bbb into master Feb 4, 2025
217 of 219 checks passed
@hsheth2 hsheth2 deleted the hs--cus-3566 branch February 4, 2025 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ingestion PR or Issue related to the ingestion of metadata pending-submitter-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants