-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-53581][CORE] Fix potential thread-safety issue for mapTaskIds.add() #52337
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
Conversation
LuciferYang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ngone51 We should create a new Jira ticket because SPARK-46957 has already been released in Spark 4.0.
|
@LuciferYang Thanks for the advice. Created a new ticket SPARK-53581. |
core/src/main/scala/org/apache/spark/shuffle/IndexShuffleBlockResolver.scala
Show resolved
Hide resolved
|
Now as the PR title changed should not the |
|
@attilapiros Thanks. Updated. |
attilapiros
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
dongjoon-hyun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, LGTM.
…add() ### What changes were proposed in this pull request? This a followup for #47037. This PR wraps up the synchronize lock for invocation of `OpenHashSet.add()` in `IndexShuffleBlockResolver`. ### Why are the changes needed? `OpenHashSet` is not thread safe. We should enfoce synchronize lock when invokes the add function to ensure the thread-safety. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? N/A. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #52337 from Ngone51/fix-thread-safety. Authored-by: Yi Wu <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 78aba00) Signed-off-by: Dongjoon Hyun <[email protected]>
…add() ### What changes were proposed in this pull request? This a followup for #47037. This PR wraps up the synchronize lock for invocation of `OpenHashSet.add()` in `IndexShuffleBlockResolver`. ### Why are the changes needed? `OpenHashSet` is not thread safe. We should enfoce synchronize lock when invokes the add function to ensure the thread-safety. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? N/A. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #52337 from Ngone51/fix-thread-safety. Authored-by: Yi Wu <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 78aba00) Signed-off-by: Dongjoon Hyun <[email protected]>
|
Thank you, @Ngone51 and all. Merged to master/4.0/3.5 for
cc @peter-toth as the release manager of Apache Spark 3.5.7, too. |
|
Thanks all! |
|
I am wondering if
I am entirely sure if this combination is possible, but would be a good idea to make Thoughts @Ngone51 ? |
|
@mridulm Good catch! I'll make a separate PR to fix it later. |
|
I'd like to expand on this issue. Is there a possibility of the reverse timing sequence for the operations mentioned by @mridulm? If |
@LuciferYang Possible, but I think that's fine. Because even if we have ensured the thread-safety already, this kind of issue could persist due to the race betwen shuffle removal and shuffle adding. The critial issue on this thread-safety problem is that the state of |
…egisterShuffle ### What changes were proposed in this pull request? This PR fixes the thread-safetye issue in `SortShuffleManager.unregisterShuffle` by enforcing synchronous lock on `mapTaskIds`'s iteration. Besides, this PR also addresses the [concern](#52337 (comment)) to enfore the type of `taskIdMapsForShuffle` as `ConcurrentHashMap` to ensure its thread-safety. ### Why are the changes needed? Fix the potential thread-safety issue as pointed at #52337 (comment) and also the [concern](#52337 (comment)). ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? N/A ### Was this patch authored or co-authored using generative AI tooling? No. Closes #52386 from Ngone51/fix. Authored-by: Yi Wu <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
…dd() ### What changes were proposed in this pull request? This a followup for apache#47037. This PR wraps up the synchronize lock for invocation of `OpenHashSet.add()` in `IndexShuffleBlockResolver`. ### Why are the changes needed? `OpenHashSet` is not thread safe. We should enfoce synchronize lock when invokes the add function to ensure the thread-safety. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? N/A. ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#52337 from Ngone51/fix-thread-safety. Authored-by: Yi Wu <[email protected]> (cherry picked from commit 78aba00) Signed-off-by: Dongjoon Hyun <[email protected]> Co-authored-by: Yi Wu <[email protected]>
…add() ### What changes were proposed in this pull request? This a followup for apache#47037. This PR wraps up the synchronize lock for invocation of `OpenHashSet.add()` in `IndexShuffleBlockResolver`. ### Why are the changes needed? `OpenHashSet` is not thread safe. We should enfoce synchronize lock when invokes the add function to ensure the thread-safety. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? N/A. ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#52337 from Ngone51/fix-thread-safety. Authored-by: Yi Wu <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit baae014) Signed-off-by: Dongjoon Hyun <[email protected]>
…add() ### What changes were proposed in this pull request? This a followup for apache#47037. This PR wraps up the synchronize lock for invocation of `OpenHashSet.add()` in `IndexShuffleBlockResolver`. ### Why are the changes needed? `OpenHashSet` is not thread safe. We should enfoce synchronize lock when invokes the add function to ensure the thread-safety. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? N/A. ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#52337 from Ngone51/fix-thread-safety. Authored-by: Yi Wu <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
…egisterShuffle ### What changes were proposed in this pull request? This PR fixes the thread-safetye issue in `SortShuffleManager.unregisterShuffle` by enforcing synchronous lock on `mapTaskIds`'s iteration. Besides, this PR also addresses the [concern](apache#52337 (comment)) to enfore the type of `taskIdMapsForShuffle` as `ConcurrentHashMap` to ensure its thread-safety. ### Why are the changes needed? Fix the potential thread-safety issue as pointed at apache#52337 (comment) and also the [concern](apache#52337 (comment)). ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? N/A ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#52386 from Ngone51/fix. Authored-by: Yi Wu <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
What changes were proposed in this pull request?
This a followup for #47037. This PR wraps up the synchronize lock for invocation of
OpenHashSet.add()inIndexShuffleBlockResolver.Why are the changes needed?
OpenHashSetis not thread safe. We should enfoce synchronize lock when invokes the add function to ensure the thread-safety.Does this PR introduce any user-facing change?
No.
How was this patch tested?
N/A.
Was this patch authored or co-authored using generative AI tooling?
No.