You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by brkyvz <gi...@git.apache.org> on 2017/02/28 22:53:55 UTC

[GitHub] spark pull request #17107: [SPARK-19774] StreamExecution should call stop() ...

GitHub user brkyvz opened a pull request:

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

    [SPARK-19774] StreamExecution should call stop() on sources when a stream fails

    ## What changes were proposed in this pull request?
    
    We call stop() on a Structured Streaming Source only when the stream is shutdown when a user calls streamingQuery.stop(). We should actually stop all sources when the stream fails as well, otherwise we may leak resources, e.g. connections to Kafka.
    
    ## How was this patch tested?
    
    Unit tests in `StreamingQuerySuite`.

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

    $ git pull https://github.com/brkyvz/spark close-source

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

    https://github.com/apache/spark/pull/17107.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 #17107
    
----
commit bc0833815d72cdbd32c2a3d68ab31e427304f319
Author: Burak Yavuz <br...@gmail.com>
Date:   2017-02-28T22:52:44Z

    ready for review

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17107: [SPARK-19774] StreamExecution should call stop() on sour...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17107
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17107: [SPARK-19774] StreamExecution should call stop() on sour...

Posted by brkyvz <gi...@git.apache.org>.
Github user brkyvz commented on the issue:

    https://github.com/apache/spark/pull/17107
  
    @zsxwing Addressed


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17107: [SPARK-19774] StreamExecution should call stop() on sour...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17107
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/73619/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17107: [SPARK-19774] StreamExecution should call stop() on sour...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on the issue:

    https://github.com/apache/spark/pull/17107
  
    Thanks. LGTM. Merging to master and 2.1.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17107: [SPARK-19774] StreamExecution should call stop() on sour...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17107
  
    **[Test build #73617 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73617/testReport)** for PR 17107 at commit [`bc08338`](https://github.com/apache/spark/commit/bc0833815d72cdbd32c2a3d68ab31e427304f319).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17107: [SPARK-19774] StreamExecution should call stop() ...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

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


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17107: [SPARK-19774] StreamExecution should call stop() on sour...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17107
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/73617/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17107: [SPARK-19774] StreamExecution should call stop() ...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17107#discussion_r103576473
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/streaming/util/MockSourceProvider.scala ---
    @@ -0,0 +1,84 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.streaming.util
    +
    +import org.apache.spark.sql.SQLContext
    +import org.apache.spark.sql.execution.streaming.Source
    +import org.apache.spark.sql.sources.StreamSourceProvider
    +import org.apache.spark.sql.types.{IntegerType, StructField, StructType}
    +
    +/**
    + * A StreamSourceProvider that provides mocked Sources for unit testing. Example usage:
    + *
    + * {{{
    + *    MockSourceProvider.withMockSources(source1, source2) {
    + *      val df1 = spark.readStream
    + *        .format("org.apache.spark.sql.streaming.util.MockSourceProvider")
    + *        .load()
    + *
    + *      val df2 = spark.readStream
    + *        .format("org.apache.spark.sql.streaming.util.MockSourceProvider")
    + *        .load()
    + *
    + *      df1.union(df2)
    + *      ...
    + *    }
    + * }}}
    + */
    +class MockSourceProvider extends StreamSourceProvider {
    +  override def sourceSchema(
    +      spark: SQLContext,
    +      schema: Option[StructType],
    +      providerName: String,
    +      parameters: Map[String, String]): (String, StructType) = {
    +    ("dummySource", MockSourceProvider.fakeSchema)
    +  }
    +
    +  override def createSource(
    +      spark: SQLContext,
    +      metadataPath: String,
    +      schema: Option[StructType],
    +      providerName: String,
    +      parameters: Map[String, String]): Source = {
    +    MockSourceProvider.sourceProviderFunction()
    +  }
    +}
    +
    +object MockSourceProvider {
    +  // Function to generate sources. May provide multiple sources if the user implements such a
    +  // function.
    +  private var sourceProviderFunction: () => Source = _
    +
    +  final val fakeSchema = StructType(StructField("a", IntegerType) :: Nil)
    +
    +  def withMockSources(sources: Source*)(f: => Unit): Unit = {
    +    require(sources.nonEmpty)
    --- End diff --
    
    nit: You can use `withMockSources(firstSource: Source, otherSources: Source*)` to make it become a compile error.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17107: [SPARK-19774] StreamExecution should call stop() on sour...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17107
  
    **[Test build #73619 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73619/testReport)** for PR 17107 at commit [`3462a98`](https://github.com/apache/spark/commit/3462a9834f990beade996034280968685af312d6).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17107: [SPARK-19774] StreamExecution should call stop() on sour...

Posted by brkyvz <gi...@git.apache.org>.
Github user brkyvz commented on the issue:

    https://github.com/apache/spark/pull/17107
  
    cc @tdas @zsxwing 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17107: [SPARK-19774] StreamExecution should call stop() ...

Posted by brkyvz <gi...@git.apache.org>.
Github user brkyvz commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17107#discussion_r103578830
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/streaming/util/MockSourceProvider.scala ---
    @@ -0,0 +1,84 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.streaming.util
    +
    +import org.apache.spark.sql.SQLContext
    +import org.apache.spark.sql.execution.streaming.Source
    +import org.apache.spark.sql.sources.StreamSourceProvider
    +import org.apache.spark.sql.types.{IntegerType, StructField, StructType}
    +
    +/**
    + * A StreamSourceProvider that provides mocked Sources for unit testing. Example usage:
    + *
    + * {{{
    + *    MockSourceProvider.withMockSources(source1, source2) {
    + *      val df1 = spark.readStream
    + *        .format("org.apache.spark.sql.streaming.util.MockSourceProvider")
    + *        .load()
    + *
    + *      val df2 = spark.readStream
    + *        .format("org.apache.spark.sql.streaming.util.MockSourceProvider")
    + *        .load()
    + *
    + *      df1.union(df2)
    + *      ...
    + *    }
    + * }}}
    + */
    +class MockSourceProvider extends StreamSourceProvider {
    +  override def sourceSchema(
    +      spark: SQLContext,
    +      schema: Option[StructType],
    +      providerName: String,
    +      parameters: Map[String, String]): (String, StructType) = {
    +    ("dummySource", MockSourceProvider.fakeSchema)
    +  }
    +
    +  override def createSource(
    +      spark: SQLContext,
    +      metadataPath: String,
    +      schema: Option[StructType],
    +      providerName: String,
    +      parameters: Map[String, String]): Source = {
    +    MockSourceProvider.sourceProviderFunction()
    +  }
    +}
    +
    +object MockSourceProvider {
    +  // Function to generate sources. May provide multiple sources if the user implements such a
    +  // function.
    +  private var sourceProviderFunction: () => Source = _
    +
    +  final val fakeSchema = StructType(StructField("a", IntegerType) :: Nil)
    +
    +  def withMockSources(sources: Source*)(f: => Unit): Unit = {
    +    require(sources.nonEmpty)
    --- End diff --
    
    good idea


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17107: [SPARK-19774] StreamExecution should call stop() on sour...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17107
  
    **[Test build #73617 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73617/testReport)** for PR 17107 at commit [`bc08338`](https://github.com/apache/spark/commit/bc0833815d72cdbd32c2a3d68ab31e427304f319).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17107: [SPARK-19774] StreamExecution should call stop() ...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17107#discussion_r103576879
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/streaming/util/MockSourceProvider.scala ---
    @@ -0,0 +1,84 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.streaming.util
    +
    +import org.apache.spark.sql.SQLContext
    +import org.apache.spark.sql.execution.streaming.Source
    +import org.apache.spark.sql.sources.StreamSourceProvider
    +import org.apache.spark.sql.types.{IntegerType, StructField, StructType}
    +
    +/**
    + * A StreamSourceProvider that provides mocked Sources for unit testing. Example usage:
    + *
    + * {{{
    + *    MockSourceProvider.withMockSources(source1, source2) {
    + *      val df1 = spark.readStream
    + *        .format("org.apache.spark.sql.streaming.util.MockSourceProvider")
    + *        .load()
    + *
    + *      val df2 = spark.readStream
    + *        .format("org.apache.spark.sql.streaming.util.MockSourceProvider")
    + *        .load()
    + *
    + *      df1.union(df2)
    + *      ...
    + *    }
    + * }}}
    + */
    +class MockSourceProvider extends StreamSourceProvider {
    +  override def sourceSchema(
    +      spark: SQLContext,
    +      schema: Option[StructType],
    +      providerName: String,
    +      parameters: Map[String, String]): (String, StructType) = {
    +    ("dummySource", MockSourceProvider.fakeSchema)
    +  }
    +
    +  override def createSource(
    +      spark: SQLContext,
    +      metadataPath: String,
    +      schema: Option[StructType],
    +      providerName: String,
    +      parameters: Map[String, String]): Source = {
    +    MockSourceProvider.sourceProviderFunction()
    +  }
    +}
    +
    +object MockSourceProvider {
    +  // Function to generate sources. May provide multiple sources if the user implements such a
    +  // function.
    +  private var sourceProviderFunction: () => Source = _
    +
    +  final val fakeSchema = StructType(StructField("a", IntegerType) :: Nil)
    +
    +  def withMockSources(sources: Source*)(f: => Unit): Unit = {
    +    require(sources.nonEmpty)
    +    var i = 0
    +    val srcProvider = () => {
    --- End diff --
    
    nit: `srcProvider` is not necessary. You can just assign the func to  `sourceProviderFunction`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17107: [SPARK-19774] StreamExecution should call stop() on sour...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17107
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17107: [SPARK-19774] StreamExecution should call stop() on sour...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17107
  
    **[Test build #73619 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73619/testReport)** for PR 17107 at commit [`3462a98`](https://github.com/apache/spark/commit/3462a9834f990beade996034280968685af312d6).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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