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: Fix deadlock in new streaming CSV / NDJSON sinks #21598

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

nameexhaustion
Copy link
Collaborator

No description provided.

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Mar 5, 2025
@@ -122,11 +122,14 @@ impl SinkNode for CsvSinkNode {
writer.write_batch(&df)?;

allocation_size = allocation_size.max(buffer.len());

// Must drop before linearizer insert or will deadlock.
drop(consume_token); // Keep the consume_token until here to increase the
Copy link
Collaborator Author

@nameexhaustion nameexhaustion Mar 5, 2025

Choose a reason for hiding this comment

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

If the consume token is sent into the linearizer, we can end up in a deadlock state for a scan->sink query - given 2 workers from the source node (1 and 2):

  • Worker 1 inserts the consume token into the linearizer buffer
  • The linearizer is waiting for an insertion from worker 2
  • Worker 2 is waiting for the channel of the next source phase
  • Worker 1 is waiting for the consume token to be dropped while holding a ref to the current source phase, preventing it from ending

Copy link

codecov bot commented Mar 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.75%. Comparing base (241d34b) to head (1059afb).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #21598   +/-   ##
=======================================
  Coverage   79.75%   79.75%           
=======================================
  Files        1604     1604           
  Lines      231519   231527    +8     
  Branches     2639     2639           
=======================================
+ Hits       184640   184663   +23     
+ Misses      46270    46255   -15     
  Partials      609      609           

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

@nameexhaustion nameexhaustion marked this pull request as ready for review March 5, 2025 07:24
@ritchie46 ritchie46 merged commit 7943dc1 into pola-rs:main Mar 5, 2025
23 checks passed
@coastalwhite
Copy link
Collaborator

coastalwhite commented Mar 5, 2025

This is really not a fix for the problem, and the deadlock still occurs. Just less often and more related to phase transitions. I fixed it properly in #21600.

anath2 pushed a commit to anath2/polars that referenced this pull request Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants