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/08/27 12:31:36 UTC
[GitHub] [spark] LantaoJin opened a new pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
LantaoJin opened a new pull request #29558:
URL: https://github.com/apache/spark/pull/29558
### What changes were proposed in this pull request?
Remove all pieces of the broadcast when failed to store some pieces of a broadcast to avoid memory leak.
In TorrentBroadcast.scala
```scala
L133: if (!blockManager.putSingle(broadcastId, value, MEMORY_AND_DISK, tellMaster = false))
L137: TorrentBroadcast.blockifyObject(value, blockSize, SparkEnv.get.serializer, compressionCodec)
L147: if (!blockManager.putBytes(pieceId, bytes, MEMORY_AND_DISK_SER, tellMaster = true))
```
After the original value is saved successfully(TorrentBroadcast.scala: L133), but the following `blockifyObject()`(L137) or store piece(L147) steps are failed. There is no opportunity to release broadcast from memory.
### Why are the changes needed?
We use Spark thrift-server as a long-running service. A bad query submitted a heavy BroadcastNestLoopJoin operation and made driver full GC. We killed the bad query but we found the driver's memory usage was still high and full GCs had very frequency. By investigating with GC dump and log, we found the broadcast may memory leak.
2020-08-19T18:54:02.824-0700: [Full GC (Allocation Failure) 2020-08-19T18:54:02.824-0700: [Class Histogram (before full gc):
116G->112G(170G), 184.9121920 secs]
[Eden: 32.0M(7616.0M)->0.0B(8704.0M) Survivors: 1088.0M->0.0B Heap: 116.4G(170.0G)->112.9G(170.0G)], [Metaspace: 177285K->177270K(182272K)]
num #instances #bytes class name
----------------------------------------------
1: 676531691 72035438432 [B
2: 676502528 32472121344 org.apache.spark.sql.catalyst.expressions.UnsafeRow
3: 99551 12018117568 [Ljava.lang.Object;
4: 26570 4349629040 [I
5: 6 3264536688 [Lorg.apache.spark.sql.catalyst.InternalRow;
6: 1708819 256299456 [C
7: 2338 179615208 [J
8: 1703669 54517408 java.lang.String
9: 103860 34896960 org.apache.spark.status.TaskDataWrapper
10: 177396 25545024 java.net.URI
...
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Manually test. This UT is hard to write and the patch is straightforward.
----------------------------------------------------------------
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] SparkQA removed a comment on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692020561
**[Test build #128649 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128649/testReport)** for PR 29558 at commit [`b565c33`](https://github.com/apache/spark/commit/b565c338390b9c54404bf55572b13e6a9c656e7d).
----------------------------------------------------------------
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] SparkQA commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692110009
**[Test build #128649 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128649/testReport)** for PR 29558 at commit [`b565c33`](https://github.com/apache/spark/commit/b565c338390b9c54404bf55572b13e6a9c656e7d).
* This patch **fails Spark unit tests**.
* This patch merges cleanly.
* This patch adds no public classes.
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692110930
Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/128649/
Test FAILed.
----------------------------------------------------------------
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] LantaoJin commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
LantaoJin commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692390073
retest this please
----------------------------------------------------------------
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] dongjoon-hyun commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-684162639
Thank you for pinging me, @LantaoJin . According to SPARK-32715 JIRA description, is this 3.1.0-only bug?
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-681920745
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692451876
----------------------------------------------------------------
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] LantaoJin commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
LantaoJin commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692019954
https://github.com/apache/spark/pull/29558/files/f9314aed6b3715db4cb9e0482397212c50573a20#discussion_r482915559
`removeBroadcast` should be thread-safe
----------------------------------------------------------------
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] dongjoon-hyun closed pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun closed pull request #29558:
URL: https://github.com/apache/spark/pull/29558
----------------------------------------------------------------
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] SparkQA commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692451008
**[Test build #128684 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128684/testReport)** for PR 29558 at commit [`b565c33`](https://github.com/apache/spark/commit/b565c338390b9c54404bf55572b13e6a9c656e7d).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
----------------------------------------------------------------
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] LantaoJin commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
LantaoJin commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-682280130
> Why the application doesn't fail when the exception raised in `TorrentBroadcast.writeBlocks()`? Is it because of the thrift-server?
Yes. I think in many cases, this exception won't fail the whole application. In our case, it happened in executing a query which included a `BroadcastExchangeExec`, it broadcasts a relation.
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692391808
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692391808
----------------------------------------------------------------
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] dongjoon-hyun commented on a change in pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #29558:
URL: https://github.com/apache/spark/pull/29558#discussion_r480659730
##########
File path: core/src/main/scala/org/apache/spark/broadcast/TorrentBroadcast.scala
##########
@@ -130,25 +130,33 @@ private[spark] class TorrentBroadcast[T: ClassTag](obj: T, id: Long)
// Store a copy of the broadcast variable in the driver so that tasks run on the driver
// do not create a duplicate copy of the broadcast variable's value.
val blockManager = SparkEnv.get.blockManager
- if (!blockManager.putSingle(broadcastId, value, MEMORY_AND_DISK, tellMaster = false)) {
- throw new SparkException(s"Failed to store $broadcastId in BlockManager")
- }
- val blocks =
- TorrentBroadcast.blockifyObject(value, blockSize, SparkEnv.get.serializer, compressionCodec)
- if (checksumEnabled) {
- checksums = new Array[Int](blocks.length)
- }
- blocks.zipWithIndex.foreach { case (block, i) =>
+ try {
+ if (!blockManager.putSingle(broadcastId, value, MEMORY_AND_DISK, tellMaster = false)) {
+ throw new SparkException(s"Failed to store $broadcastId in BlockManager")
+ }
+ val blocks =
+ TorrentBroadcast.blockifyObject(value, blockSize, SparkEnv.get.serializer, compressionCodec)
if (checksumEnabled) {
- checksums(i) = calcChecksum(block)
+ checksums = new Array[Int](blocks.length)
}
- val pieceId = BroadcastBlockId(id, "piece" + i)
- val bytes = new ChunkedByteBuffer(block.duplicate())
- if (!blockManager.putBytes(pieceId, bytes, MEMORY_AND_DISK_SER, tellMaster = true)) {
- throw new SparkException(s"Failed to store $pieceId of $broadcastId in local BlockManager")
+ blocks.zipWithIndex.foreach { case (block, i) =>
+ if (checksumEnabled) {
+ checksums(i) = calcChecksum(block)
+ }
+ val pieceId = BroadcastBlockId(id, "piece" + i)
+ val bytes = new ChunkedByteBuffer(block.duplicate())
+ if (!blockManager.putBytes(pieceId, bytes, MEMORY_AND_DISK_SER, tellMaster = true)) {
+ throw new SparkException(s"Failed to store $pieceId of $broadcastId " +
+ s"in local BlockManager")
+ }
}
+ blocks.length
+ } catch {
+ case t: Throwable =>
+ logError(s"Store broadcast $broadcastId fail, remove all pieces of the broadcast")
+ blockManager.removeBroadcast(id, tellMaster = true)
Review comment:
Is this correct? What happens if this is thrown at line 135, @LantaoJin ?
----------------------------------------------------------------
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] SparkQA removed a comment on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692391473
**[Test build #128684 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128684/testReport)** for PR 29558 at commit [`b565c33`](https://github.com/apache/spark/commit/b565c338390b9c54404bf55572b13e6a9c656e7d).
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-682008825
----------------------------------------------------------------
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] SparkQA commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-681920209
**[Test build #127954 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/127954/testReport)** for PR 29558 at commit [`f9314ae`](https://github.com/apache/spark/commit/f9314aed6b3715db4cb9e0482397212c50573a20).
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692017817
Merged build finished. Test PASSed.
----------------------------------------------------------------
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] LantaoJin commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
LantaoJin commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-684161707
Ping @cloud-fan @dongjoon-hyun
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692451876
----------------------------------------------------------------
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] LantaoJin edited a comment on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
LantaoJin edited a comment on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692019954
> `Would it has the thread-safe issue since blockManager is an IsolatedRpcEndpoint?`
`removeBroadcast()` should be thread-safe
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-681920745
----------------------------------------------------------------
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] SparkQA commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-682007355
**[Test build #127954 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/127954/testReport)** for PR 29558 at commit [`f9314ae`](https://github.com/apache/spark/commit/f9314aed6b3715db4cb9e0482397212c50573a20).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
----------------------------------------------------------------
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] LantaoJin commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
LantaoJin commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-684168331
> Thank you for pinging me, @LantaoJin . According to [SPARK-32715](https://issues.apache.org/jira/browse/SPARK-32715) JIRA description, is this 3.1.0-only bug?
No. I just use the latest version. I will update that jira page.
----------------------------------------------------------------
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] Ngone51 commented on a change in pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
Ngone51 commented on a change in pull request #29558:
URL: https://github.com/apache/spark/pull/29558#discussion_r482915559
##########
File path: core/src/main/scala/org/apache/spark/broadcast/TorrentBroadcast.scala
##########
@@ -130,25 +130,33 @@ private[spark] class TorrentBroadcast[T: ClassTag](obj: T, id: Long)
// Store a copy of the broadcast variable in the driver so that tasks run on the driver
// do not create a duplicate copy of the broadcast variable's value.
val blockManager = SparkEnv.get.blockManager
- if (!blockManager.putSingle(broadcastId, value, MEMORY_AND_DISK, tellMaster = false)) {
- throw new SparkException(s"Failed to store $broadcastId in BlockManager")
- }
- val blocks =
- TorrentBroadcast.blockifyObject(value, blockSize, SparkEnv.get.serializer, compressionCodec)
- if (checksumEnabled) {
- checksums = new Array[Int](blocks.length)
- }
- blocks.zipWithIndex.foreach { case (block, i) =>
+ try {
+ if (!blockManager.putSingle(broadcastId, value, MEMORY_AND_DISK, tellMaster = false)) {
+ throw new SparkException(s"Failed to store $broadcastId in BlockManager")
+ }
+ val blocks =
+ TorrentBroadcast.blockifyObject(value, blockSize, SparkEnv.get.serializer, compressionCodec)
if (checksumEnabled) {
- checksums(i) = calcChecksum(block)
+ checksums = new Array[Int](blocks.length)
}
- val pieceId = BroadcastBlockId(id, "piece" + i)
- val bytes = new ChunkedByteBuffer(block.duplicate())
- if (!blockManager.putBytes(pieceId, bytes, MEMORY_AND_DISK_SER, tellMaster = true)) {
- throw new SparkException(s"Failed to store $pieceId of $broadcastId in local BlockManager")
+ blocks.zipWithIndex.foreach { case (block, i) =>
+ if (checksumEnabled) {
+ checksums(i) = calcChecksum(block)
+ }
+ val pieceId = BroadcastBlockId(id, "piece" + i)
+ val bytes = new ChunkedByteBuffer(block.duplicate())
+ if (!blockManager.putBytes(pieceId, bytes, MEMORY_AND_DISK_SER, tellMaster = true)) {
+ throw new SparkException(s"Failed to store $pieceId of $broadcastId " +
+ s"in local BlockManager")
+ }
}
+ blocks.length
+ } catch {
+ case t: Throwable =>
+ logError(s"Store broadcast $broadcastId fail, remove all pieces of the broadcast")
+ blockManager.removeBroadcast(id, tellMaster = true)
Review comment:
Would it has the thread-safe issue since `blockManager` is an `IsolatedRpcEndpoint`?
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692017817
----------------------------------------------------------------
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] Ngone51 commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
Ngone51 commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-686434497
cc @tgravescs @jiangxb1987
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692017830
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/33272/
Test PASSed.
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692110916
Merged build finished. Test FAILed.
----------------------------------------------------------------
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] SparkQA commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692020561
**[Test build #128649 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128649/testReport)** for PR 29558 at commit [`b565c33`](https://github.com/apache/spark/commit/b565c338390b9c54404bf55572b13e6a9c656e7d).
----------------------------------------------------------------
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] SparkQA removed a comment on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-681920209
**[Test build #127954 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/127954/testReport)** for PR 29558 at commit [`f9314ae`](https://github.com/apache/spark/commit/f9314aed6b3715db4cb9e0482397212c50573a20).
----------------------------------------------------------------
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] Ngone51 commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
Ngone51 commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-681946658
Why the application doesn't fail when the exception raised in `TorrentBroadcast.writeBlocks()`? Is it because of the thrift-server?
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-682008825
----------------------------------------------------------------
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] SparkQA commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692391473
**[Test build #128684 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128684/testReport)** for PR 29558 at commit [`b565c33`](https://github.com/apache/spark/commit/b565c338390b9c54404bf55572b13e6a9c656e7d).
----------------------------------------------------------------
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] mridulm commented on a change in pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
mridulm commented on a change in pull request #29558:
URL: https://github.com/apache/spark/pull/29558#discussion_r486436039
##########
File path: core/src/main/scala/org/apache/spark/broadcast/TorrentBroadcast.scala
##########
@@ -130,25 +130,33 @@ private[spark] class TorrentBroadcast[T: ClassTag](obj: T, id: Long)
// Store a copy of the broadcast variable in the driver so that tasks run on the driver
// do not create a duplicate copy of the broadcast variable's value.
val blockManager = SparkEnv.get.blockManager
- if (!blockManager.putSingle(broadcastId, value, MEMORY_AND_DISK, tellMaster = false)) {
- throw new SparkException(s"Failed to store $broadcastId in BlockManager")
- }
- val blocks =
- TorrentBroadcast.blockifyObject(value, blockSize, SparkEnv.get.serializer, compressionCodec)
- if (checksumEnabled) {
- checksums = new Array[Int](blocks.length)
- }
- blocks.zipWithIndex.foreach { case (block, i) =>
+ try {
+ if (!blockManager.putSingle(broadcastId, value, MEMORY_AND_DISK, tellMaster = false)) {
+ throw new SparkException(s"Failed to store $broadcastId in BlockManager")
+ }
+ val blocks =
+ TorrentBroadcast.blockifyObject(value, blockSize, SparkEnv.get.serializer, compressionCodec)
if (checksumEnabled) {
- checksums(i) = calcChecksum(block)
+ checksums = new Array[Int](blocks.length)
}
- val pieceId = BroadcastBlockId(id, "piece" + i)
- val bytes = new ChunkedByteBuffer(block.duplicate())
- if (!blockManager.putBytes(pieceId, bytes, MEMORY_AND_DISK_SER, tellMaster = true)) {
- throw new SparkException(s"Failed to store $pieceId of $broadcastId in local BlockManager")
+ blocks.zipWithIndex.foreach { case (block, i) =>
+ if (checksumEnabled) {
+ checksums(i) = calcChecksum(block)
+ }
+ val pieceId = BroadcastBlockId(id, "piece" + i)
+ val bytes = new ChunkedByteBuffer(block.duplicate())
+ if (!blockManager.putBytes(pieceId, bytes, MEMORY_AND_DISK_SER, tellMaster = true)) {
+ throw new SparkException(s"Failed to store $pieceId of $broadcastId " +
+ s"in local BlockManager")
+ }
}
+ blocks.length
+ } catch {
+ case t: Throwable =>
+ logError(s"Store broadcast $broadcastId fail, remove all pieces of the broadcast")
+ blockManager.removeBroadcast(id, tellMaster = true)
Review comment:
I agree with @dongjoon-hyun - `blockManager.putSingle` for broadcastid should be outside try/catch. Rest look fine.
----------------------------------------------------------------
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] dongjoon-hyun commented on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692402763
Thank you for update, @LantaoJin .
----------------------------------------------------------------
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] LantaoJin commented on a change in pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
LantaoJin commented on a change in pull request #29558:
URL: https://github.com/apache/spark/pull/29558#discussion_r480673106
##########
File path: core/src/main/scala/org/apache/spark/broadcast/TorrentBroadcast.scala
##########
@@ -130,25 +130,33 @@ private[spark] class TorrentBroadcast[T: ClassTag](obj: T, id: Long)
// Store a copy of the broadcast variable in the driver so that tasks run on the driver
// do not create a duplicate copy of the broadcast variable's value.
val blockManager = SparkEnv.get.blockManager
- if (!blockManager.putSingle(broadcastId, value, MEMORY_AND_DISK, tellMaster = false)) {
- throw new SparkException(s"Failed to store $broadcastId in BlockManager")
- }
- val blocks =
- TorrentBroadcast.blockifyObject(value, blockSize, SparkEnv.get.serializer, compressionCodec)
- if (checksumEnabled) {
- checksums = new Array[Int](blocks.length)
- }
- blocks.zipWithIndex.foreach { case (block, i) =>
+ try {
+ if (!blockManager.putSingle(broadcastId, value, MEMORY_AND_DISK, tellMaster = false)) {
+ throw new SparkException(s"Failed to store $broadcastId in BlockManager")
+ }
+ val blocks =
+ TorrentBroadcast.blockifyObject(value, blockSize, SparkEnv.get.serializer, compressionCodec)
if (checksumEnabled) {
- checksums(i) = calcChecksum(block)
+ checksums = new Array[Int](blocks.length)
}
- val pieceId = BroadcastBlockId(id, "piece" + i)
- val bytes = new ChunkedByteBuffer(block.duplicate())
- if (!blockManager.putBytes(pieceId, bytes, MEMORY_AND_DISK_SER, tellMaster = true)) {
- throw new SparkException(s"Failed to store $pieceId of $broadcastId in local BlockManager")
+ blocks.zipWithIndex.foreach { case (block, i) =>
+ if (checksumEnabled) {
+ checksums(i) = calcChecksum(block)
+ }
+ val pieceId = BroadcastBlockId(id, "piece" + i)
+ val bytes = new ChunkedByteBuffer(block.duplicate())
+ if (!blockManager.putBytes(pieceId, bytes, MEMORY_AND_DISK_SER, tellMaster = true)) {
+ throw new SparkException(s"Failed to store $pieceId of $broadcastId " +
+ s"in local BlockManager")
+ }
}
+ blocks.length
+ } catch {
+ case t: Throwable =>
+ logError(s"Store broadcast $broadcastId fail, remove all pieces of the broadcast")
+ blockManager.removeBroadcast(id, tellMaster = true)
Review comment:
We can begin to Try..Catch from L137 if the L134 is atomic. But I think `L157: blockManager.removeBroadcast(id, tellMaster = true)` is no harmful even exception throws from L135. Please correct me if I understand incorrectly.
----------------------------------------------------------------
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] LantaoJin edited a comment on pull request #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
LantaoJin edited a comment on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-682280130
> Why the application doesn't fail when the exception raised in `TorrentBroadcast.writeBlocks()`? Is it because of the thrift-server?
Yes. I think in many cases, this exception won't fail the whole application. In our case, it happened in executing a query which included a `BroadcastExchangeExec`, it broadcasts a relation. It failed the query execution.
----------------------------------------------------------------
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 #29558: [SPARK-32715][CORE] Fix memory leak when failed to store pieces of broadcast
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29558:
URL: https://github.com/apache/spark/pull/29558#issuecomment-692110916
----------------------------------------------------------------
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