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

Handle exceptions during node execution more elegantly. #9585

Merged
merged 7 commits into from
Mar 1, 2024

Conversation

peterallenwebb
Copy link
Contributor

@peterallenwebb peterallenwebb commented Feb 15, 2024

resolves #9583

Problem

Because of a bug in Python's thread pool mechanism, an uncaught exception on dbt's task threads would cause it to hang.

Solution

Eliminate a follow-up exception that caused a top-level exception to escape.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

@cla-bot cla-bot bot added the cla:yes label Feb 15, 2024
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

Copy link

codecov bot commented Feb 29, 2024

Codecov Report

Attention: Patch coverage is 44.44444% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 88.02%. Comparing base (e4fe839) to head (1aef690).

Files Patch % Lines
core/dbt/task/runnable.py 44.44% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9585      +/-   ##
==========================================
- Coverage   88.08%   88.02%   -0.07%     
==========================================
  Files         178      178              
  Lines       22433    22439       +6     
==========================================
- Hits        19761    19751      -10     
- Misses       2672     2688      +16     
Flag Coverage Δ
integration 85.48% <44.44%> (-0.16%) ⬇️
unit 62.24% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@peterallenwebb peterallenwebb marked this pull request as ready for review February 29, 2024 23:19
@peterallenwebb peterallenwebb requested a review from a team as a code owner February 29, 2024 23:19
)
else:
msg = f"Exception on worker thread. {thread_exception}"
fire_event(Note(msg=msg))
Copy link
Member

Choose a reason for hiding this comment

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

Should we use the GenericExceptionOnRun event instead here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd vote for this

@peterallenwebb peterallenwebb merged commit 6fd0a94 into main Mar 1, 2024
58 checks passed
@peterallenwebb peterallenwebb deleted the paw/do-not-hang-on-worker-exception branch March 1, 2024 20:52
Copy link
Contributor

The backport to 1.7.latest failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.7.latest 1.7.latest
# Navigate to the new working tree
cd .worktrees/backport-1.7.latest
# Create a new branch
git switch --create backport-9585-to-1.7.latest
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 6fd0a947297056e4a92d796111a2be578b774b47
# Push it to GitHub
git push --set-upstream origin backport-9585-to-1.7.latest
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.7.latest

Then, create a pull request where the base branch is 1.7.latest and the compare/head branch is backport-9585-to-1.7.latest.

gshank pushed a commit that referenced this pull request Mar 20, 2024
* Handle exceptions during node execution more elegantly.

* Add changelog entry.

* Fix import

* Add task documentation.

* Change event type for noting thread exceptions.
gshank added a commit that referenced this pull request Mar 20, 2024
* Handle exceptions during node execution more elegantly.

* Add changelog entry.

* Fix import

* Add task documentation.

* Change event type for noting thread exceptions.

Co-authored-by: Peter Webb <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do Not Hang on Worker Thread Exceptions
3 participants