Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@ impl MemConsumer for SortShuffleRepartitioner {
async fn spill(&self) -> Result<()> {
let data = self.data.lock().await.drain();
let spill_metrics = self.exec_ctx.spill_metrics().clone();
let mut spills = self.spills.lock().await;

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.

In this file the on-heap spill_id comes from newSpill() (auron-memmgr/src/spill.rs:182) and try_new_spill takes no index, so spills.len() doesn't feed a spill id here the way it does in agg_table.rs (try_into_spill(spill, spill_idx)). Is the race from the issue actually reachable in sort_repartitioner, or is this more defensive? Either's fine — just want to make sure I'm reading it right.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I found this issue while reviewing the code, and didn't encounter any actual failures. However, this race condition is possible; although sort_repartitioner doesn't take spill_id, it still affects the spill index on the JVM side. If I understand correctly, we should always ensure that the native-side spills length is consistent with the JVM-side length, so we need to lock the spills first.

val spill = OnHeapSpill(this, spills.length)
spills.append(Some(spill))

let spill = tokio::task::spawn_blocking(move || {
let mut spill = try_new_spill(&spill_metrics)?;
let offsets = data.write(spill.get_buf_writer())?;
Ok::<_, DataFusionError>(Offsetted::new(offsets, spill))
})
.await
.expect("tokio spawn_blocking error")?;
Comment on lines +101 to 108

self.spills.lock().await.push(spill);
spills.push(spill);
drop(spills);
self.update_mem_used(0).await?;
Ok(())
}
Expand Down
Loading