[GitHub] spark pull request #17761: [SPARK-20461][Core][SS]Use UninterruptibleThread ...

2017-04-27 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/spark/pull/17761


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #17761: [SPARK-20461][Core][SS]Use UninterruptibleThread ...

2017-04-25 Thread kunalkhamar
Github user kunalkhamar commented on a diff in the pull request:

https://github.com/apache/spark/pull/17761#discussion_r113274024
  
--- Diff: 
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/CachedKafkaConsumer.scala
 ---
@@ -62,11 +63,20 @@ private[kafka010] case class CachedKafkaConsumer 
private(
 
   case class AvailableOffsetRange(earliest: Long, latest: Long)
 
+  private def runUninterruptiblyIfPossiable[T](body: => T): T = 
Thread.currentThread match {
--- End diff --

nit: rename `runUninterruptiblyIfPossible`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #17761: [SPARK-20461][Core][SS]Use UninterruptibleThread ...

2017-04-25 Thread tdas
Github user tdas commented on a diff in the pull request:

https://github.com/apache/spark/pull/17761#discussion_r113273935
  
--- Diff: 
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/CachedKafkaConsumer.scala
 ---
@@ -62,11 +63,20 @@ private[kafka010] case class CachedKafkaConsumer 
private(
 
   case class AvailableOffsetRange(earliest: Long, latest: Long)
 
+  private def runUninterruptiblyIfPossiable[T](body: => T): T = 
Thread.currentThread match {
--- End diff --

Possiable -> Possible


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #17761: [SPARK-20461][Core][SS]Use UninterruptibleThread ...

2017-04-25 Thread zsxwing
Github user zsxwing commented on a diff in the pull request:

https://github.com/apache/spark/pull/17761#discussion_r113273103
  
--- Diff: core/src/main/scala/org/apache/spark/executor/Executor.scala ---
@@ -84,7 +86,20 @@ private[spark] class Executor(
   }
 
   // Start worker thread pool
-  private val threadPool = ThreadUtils.newDaemonCachedThreadPool("Executor 
task launch worker")
+  private val threadPool = {
+val threadFactory = new ThreadFactoryBuilder()
+  .setDaemon(true)
+  .setNameFormat("Executor task launch worker-%d")
+  .setThreadFactory(new ThreadFactory {
+override def newThread(r: Runnable): Thread =
+  // Use UninterruptibleThread to run tasks so that we can allow 
running codes without being
+  // interrupted by `Thread.interrupt()`. Some issues, such as 
KAFKA-1894, HADOOP-10622,
+  // will hang forever if some methods are interrupted.
+  new UninterruptibleThread(r, "unused") // thread name will be 
set by ThreadFactoryBuilder
--- End diff --

Mostly of the codes are copied from `ThreadUtils`. This one is the only 
difference that matters.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #17761: [SPARK-20461][Core][SS]Use UninterruptibleThread ...

2017-04-25 Thread zsxwing
GitHub user zsxwing opened a pull request:

https://github.com/apache/spark/pull/17761

[SPARK-20461][Core][SS]Use UninterruptibleThread for Executor and fix the 
potential hang in CachedKafkaConsumer

## What changes were proposed in this pull request?

This PR changes Executor's threads to `UninterruptibleThread` so that we 
can use `runUninterruptibly` in `CachedKafkaConsumer`. However, this is just 
best effort to avoid hanging forever. If the user uses`CachedKafkaConsumer` in 
another thread (e.g., create a new thread or Future), the potential hang may 
still happen.

## How was this patch tested?

The new added test.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/zsxwing/spark int

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/spark/pull/17761.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #17761


commit 3d7fc4d86107f1171321946adf58dbd9dbb1f9a1
Author: Shixiong Zhu 
Date:   2017-04-25T18:16:46Z

Use UninterruptibleThread for Executor and fix the potential hang in 
CachedKafkaConsumer




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org