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: panics when creating delta tables in threads #2940

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

PeterKeDer
Copy link
Contributor

Description

Loading in delta tables from multiple threads is causing panics. Reproducible example:

from multiprocessing.pool import ThreadPool
from deltalake import DeltaTable

def make_dt(x):
    return DeltaTable('/path/to/some/local/table')

pool = ThreadPool(processes=16)
list(pool.map(make_dt, range(16)))

causes

pyo3_runtime.PanicException: Failed to record PID for tokio runtime.: 71866

This race condition is caused by multiple threads trying to acquire and set the PID. Multiple threads could succeed at the PID.get() call at time before any threads set the PID, but only one thread can successfully call PID.set, causing the remaining threads to panic.

This fixes by using get_or_init for setting PID, and only panics if the returned runtime_pid is different from the current pid.

Related Issue(s)

@github-actions github-actions bot added the binding/python Issues for the Python package label Oct 11, 2024
Copy link

codecov bot commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 72.45%. Comparing base (ef4e4a3) to head (c813ab7).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
python/src/utils.rs 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2940      +/-   ##
==========================================
+ Coverage   72.43%   72.45%   +0.01%     
==========================================
  Files         131      131              
  Lines       40545    40542       -3     
  Branches    40545    40542       -3     
==========================================
+ Hits        29369    29373       +4     
+ Misses       9293     9292       -1     
+ Partials     1883     1877       -6     

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

@ion-elgreco ion-elgreco added this pull request to the merge queue Oct 11, 2024
Merged via the queue into delta-io:main with commit 5b1ab37 Oct 11, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binding/python Issues for the Python package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic in python > 0.18.2 and <= 0.20.0 around tokio runtime
2 participants