You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/04/28 09:24:08 UTC
[GitHub] [spark] fanyunbojerry opened a new pull request #28389: [SPARK-31592]bufferPoolsBySize in HeapMemoryAllocator should be thread safe
fanyunbojerry opened a new pull request #28389:
URL: https://github.com/apache/spark/pull/28389
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
-->
### What changes were proposed in this pull request?
Currently, bufferPoolsBySize in HeapMemoryAllocator uses a Map type whose value type is LinkedList.
LinkedList is not thread safe and may hit the error below
```
java.util.NoSuchElementExceptionException
at java.util.LinkedList.removeFirst(LinkedList.java:270)
at java.util.LinkedList.remove(LinkedList.java:685)
at org.apache.spark.unsafe.memory.HeapMemoryAllocator.allocate(HeapMemoryAllocator.java:57)
```
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on a change in pull request #28389: [SPARK-31592]bufferPoolsBySize in HeapMemoryAllocator should be thread safe
Posted by GitBox <gi...@apache.org>.
srowen commented on a change in pull request #28389:
URL: https://github.com/apache/spark/pull/28389#discussion_r416769598
##########
File path: common/unsafe/src/main/java/org/apache/spark/unsafe/memory/HeapMemoryAllocator.java
##########
@@ -50,7 +50,7 @@ public MemoryBlock allocate(long size) throws OutOfMemoryError {
long alignedSize = numWords * 8L;
assert (alignedSize >= size);
if (shouldPool(alignedSize)) {
- synchronized (this) {
+ synchronized (bufferPoolsBySize) {
Review comment:
I don't see how it can happen. Is this on 2.4, master? the only thing added is a new WeakReference(), which can't be null.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28389: [SPARK-31592]bufferPoolsBySize in HeapMemoryAllocator should be thread safe
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28389:
URL: https://github.com/apache/spark/pull/28389#issuecomment-620491616
Can one of the admins verify this patch?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on a change in pull request #28389: [SPARK-31592]bufferPoolsBySize in HeapMemoryAllocator should be thread safe
Posted by GitBox <gi...@apache.org>.
srowen commented on a change in pull request #28389:
URL: https://github.com/apache/spark/pull/28389#discussion_r416671300
##########
File path: common/unsafe/src/main/java/org/apache/spark/unsafe/memory/HeapMemoryAllocator.java
##########
@@ -50,7 +50,7 @@ public MemoryBlock allocate(long size) throws OutOfMemoryError {
long alignedSize = numWords * 8L;
assert (alignedSize >= size);
if (shouldPool(alignedSize)) {
- synchronized (this) {
+ synchronized (bufferPoolsBySize) {
Review comment:
I'm probably missing something, but how does this help? concurrent access is already excluded.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen closed pull request #28389: [SPARK-31592]bufferPoolsBySize in HeapMemoryAllocator should be thread safe
Posted by GitBox <gi...@apache.org>.
srowen closed pull request #28389:
URL: https://github.com/apache/spark/pull/28389
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28389: [SPARK-31592]bufferPoolsBySize in HeapMemoryAllocator should be thread safe
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28389:
URL: https://github.com/apache/spark/pull/28389#issuecomment-620488475
Can one of the admins verify this patch?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] fanyunbojerry commented on a change in pull request #28389: [SPARK-31592]bufferPoolsBySize in HeapMemoryAllocator should be thread safe
Posted by GitBox <gi...@apache.org>.
fanyunbojerry commented on a change in pull request #28389:
URL: https://github.com/apache/spark/pull/28389#discussion_r416758545
##########
File path: common/unsafe/src/main/java/org/apache/spark/unsafe/memory/HeapMemoryAllocator.java
##########
@@ -50,7 +50,7 @@ public MemoryBlock allocate(long size) throws OutOfMemoryError {
long alignedSize = numWords * 8L;
assert (alignedSize >= size);
if (shouldPool(alignedSize)) {
- synchronized (this) {
+ synchronized (bufferPoolsBySize) {
Review comment:
You're right. I checked my executor log again and I find the executor got NPE first
```
java.lang.NullPointerException
at org.apache.spark.unsafe.memory.HeapMemoryAllocator.allocate(HeapMemoryAllocator.java:58)
at org.apache.spark.memory.TaskMemoryManager.allocatePage(TaskMemoryManager.java:302)
at org.apache.spark.memory.MemoryConsumer.allocateArray(MemoryConsumer.java:96)
at org.apache.spark.unsafe.map.BytesToBytesMap.allocate(BytesToBytesMap:800)
...
```
And later got the NoSuchElementExceptionException.
```
java.util.NoSuchElementExceptionException
at java.util.LinkedList.removeFirst(LinkedList.java:270)
at java.util.LinkedList.remove(LinkedList.java:685)
at org.apache.spark.unsafe.memory.HeapMemoryAllocator.allocate(HeapMemoryAllocator.java:57)
at org.apache.spark.memory.TaskMemoryManager.allocatePage(TaskMemoryManager.java:302)
at org.apache.spark.memory.MemoryConsumer.allocateArray(MemoryConsumer.java:96)
at org.apache.spark.unsafe.map.BytesToBytesMap.allocate(BytesToBytesMap:800)
...
```
But I can't find out why NPE error here. Maybe a null WeakReference<long[]> added?
I updated the JIRA SPARK-31592.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28389: [SPARK-31592]bufferPoolsBySize in HeapMemoryAllocator should be thread safe
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28389:
URL: https://github.com/apache/spark/pull/28389#issuecomment-620488475
Can one of the admins verify this patch?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org