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

[CELEBORN-1544][0.4] ShuffleWriter needs to call close finally to avoid memory leaks #2718

Closed
wants to merge 2 commits into from

Conversation

pan3793
Copy link
Member

@pan3793 pan3793 commented Aug 30, 2024

Backport CELEBORN-1544 (#2661 and #2663) to branch-0.4

What changes were proposed in this pull request?

This PR aims to fix a possible memory leak in ShuffleWriter.

Why are the changes needed?

When we turn on spark.speculation=true or we kill the executing SQL, the task may be interrupted. At this time, ShuffleWriter may not call close.
At this time, DataPusher#idleQueue will occupy some memory capacity ( celeborn.client.push.buffer.max.size * celeborn.client.push.queue.capacity ) and the instance will not be released.

Thread 537 (DataPusher-78931):
  State: TIMED_WAITING
  Blocked count: 0
  Waited count: 16337
  IsDaemon: true
  Stack:
    java.lang.Thread.sleep(Native Method)
    org.apache.celeborn.client.write.DataPushQueue.takePushTasks(DataPushQueue.java:135)
    org.apache.celeborn.client.write.DataPusher$1.run(DataPusher.java:122)

Does this PR introduce any user-facing change?

No

How was this patch tested?

Production testing

Current

image

PR

image

…mory leaks

This PR aims to fix a possible memory leak in ShuffleWriter.

When we turn on `spark.speculation=true` or we kill the executing SQL, the task may be interrupted. At this time, `ShuffleWriter` may not call close.
At this time, `DataPusher#idleQueue` will occupy some memory capacity ( `celeborn.client.push.buffer.max.size` * `celeborn.client.push.queue.capacity` ) and the instance will not be released.

```java
Thread 537 (DataPusher-78931):
  State: TIMED_WAITING
  Blocked count: 0
  Waited count: 16337
  IsDaemon: true
  Stack:
    java.lang.Thread.sleep(Native Method)
    org.apache.celeborn.client.write.DataPushQueue.takePushTasks(DataPushQueue.java:135)
    org.apache.celeborn.client.write.DataPusher$1.run(DataPusher.java:122)
```

No

Production testing

<img width="547" alt="image" src="https://github.com/user-attachments/assets/d6f64257-144e-4139-96c6-518ca5f1bfd2">

<img width="479" alt="image" src="https://github.com/user-attachments/assets/e4ff62ec-5b9d-47a4-a36c-1d13bf378cbc">

Closes apache#2661 from cxzl25/CELEBORN-1544.

Authored-by: sychen <[email protected]>
Signed-off-by: zky.zhoukeyong <[email protected]>
…call abort to avoid memory leaks

This PR aims to fix a possible memory leak in ShuffleWriter.

Introduce a private abort method, which can be called to release memory when an exception occurs.

apache#2661 Call the close method in the finally block, but the close method has `shuffleClient.mapperEnd`, which is dangerous for incomplete tasks, and the data may be inaccurate.

No

GA

Closes apache#2663 from cxzl25/CELEBORN-1544-followup.

Authored-by: sychen <[email protected]>
Signed-off-by: zky.zhoukeyong <[email protected]>
@cfmcgrady
Copy link
Contributor

thank you, merging to branch-0.4(v0.4.3).

cfmcgrady pushed a commit that referenced this pull request Sep 2, 2024
…id memory leaks

Backport CELEBORN-1544 (#2661 and #2663) to branch-0.4

### What changes were proposed in this pull request?
This PR aims to fix a possible memory leak in ShuffleWriter.

### Why are the changes needed?
When we turn on `spark.speculation=true` or we kill the executing SQL, the task may be interrupted. At this time, `ShuffleWriter` may not call close.
At this time, `DataPusher#idleQueue` will occupy some memory capacity ( `celeborn.client.push.buffer.max.size` * `celeborn.client.push.queue.capacity` ) and the instance will not be released.

```java
Thread 537 (DataPusher-78931):
  State: TIMED_WAITING
  Blocked count: 0
  Waited count: 16337
  IsDaemon: true
  Stack:
    java.lang.Thread.sleep(Native Method)
    org.apache.celeborn.client.write.DataPushQueue.takePushTasks(DataPushQueue.java:135)
    org.apache.celeborn.client.write.DataPusher$1.run(DataPusher.java:122)
```

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Production testing

#### Current
<img width="547" alt="image" src="https://github.com/user-attachments/assets/d6f64257-144e-4139-96c6-518ca5f1bfd2">

#### PR
<img width="479" alt="image" src="https://github.com/user-attachments/assets/e4ff62ec-5b9d-47a4-a36c-1d13bf378cbc">

Closes #2718 from pan3793/CELEBORN-1544-0.4.

Authored-by: sychen <[email protected]>
Signed-off-by: Fu Chen <[email protected]>
@cfmcgrady cfmcgrady closed this Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants