Skip to content

Conversation

@brkyvz
Copy link
Contributor

@brkyvz brkyvz commented Feb 28, 2017

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.

@brkyvz
Copy link
Contributor Author

brkyvz commented Feb 28, 2017

cc @tdas @zsxwing

Copy link
Member

@zsxwing zsxwing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just some nits.

final val fakeSchema = StructType(StructField("a", IntegerType) :: Nil)

def withMockSources(sources: Source*)(f: => Unit): Unit = {
require(sources.nonEmpty)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: You can use withMockSources(firstSource: Source, otherSources: Source*) to make it become a compile error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

def withMockSources(sources: Source*)(f: => Unit): Unit = {
require(sources.nonEmpty)
var i = 0
val srcProvider = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: srcProvider is not necessary. You can just assign the func to sourceProviderFunction

@brkyvz
Copy link
Contributor Author

brkyvz commented Feb 28, 2017

@zsxwing Addressed

@SparkQA
Copy link

SparkQA commented Mar 1, 2017

Test build #73617 has finished for PR 17107 at commit bc08338.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Mar 1, 2017

Test build #73619 has finished for PR 17107 at commit 3462a98.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@zsxwing
Copy link
Member

zsxwing commented Mar 3, 2017

Thanks. LGTM. Merging to master and 2.1.

asfgit pushed a commit that referenced this pull request Mar 3, 2017
…ream 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`.

Author: Burak Yavuz <[email protected]>

Closes #17107 from brkyvz/close-source.

(cherry picked from commit 9314c08)
Signed-off-by: Shixiong Zhu <[email protected]>
@asfgit asfgit closed this in 9314c08 Mar 3, 2017
@brkyvz brkyvz deleted the close-source branch February 3, 2019 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants