-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-23033][SS] Don't use task level retry for continuous processing #20225
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9f7066e
fail if attempt number isn't 0
jose-torres f641be0
capture task retry and convert it to global retry
jose-torres 761fd26
bring in state update
jose-torres 1bf613f
bring in stream test sync
jose-torres f175094
stop before check in rate stream stress
jose-torres 5dbc038
Merge remote-tracking branch 'apache/master' into no-retry
jose-torres 3b19fcb
fix merge
jose-torres ad2f206
rename test
jose-torres 54d3a2c
stop the query rather than retry looping when task tries to retry
jose-torres b40c8f0
use finally
jose-torres b5d621b
use ExpectFailure
jose-torres cea2ddc
add docs
jose-torres 49f1eb6
fix sync
jose-torres 0122aeb
Merge remote-tracking branch 'apache/master' into no-retry
jose-torres f97bc9d
Merge remote-tracking branch 'apache/master' into no-retry
jose-torres File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...la/org/apache/spark/sql/execution/streaming/continuous/ContinuousTaskRetryException.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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.execution.streaming.continuous | ||
|
||
import org.apache.spark.SparkException | ||
|
||
/** | ||
* An exception thrown when a continuous processing task runs with a nonzero attempt ID. | ||
*/ | ||
class ContinuousTaskRetryException | ||
extends SparkException("Continuous execution does not support task retry", null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,36 +17,18 @@ | |
|
||
package org.apache.spark.sql.streaming.continuous | ||
|
||
import java.io.{File, InterruptedIOException, IOException, UncheckedIOException} | ||
import java.nio.channels.ClosedByInterruptException | ||
import java.util.concurrent.{CountDownLatch, ExecutionException, TimeoutException, TimeUnit} | ||
import java.util.UUID | ||
|
||
import scala.reflect.ClassTag | ||
import scala.util.control.ControlThrowable | ||
|
||
import com.google.common.util.concurrent.UncheckedExecutionException | ||
import org.apache.commons.io.FileUtils | ||
import org.apache.hadoop.conf.Configuration | ||
|
||
import org.apache.spark.{SparkContext, SparkEnv} | ||
import org.apache.spark.scheduler.{SparkListener, SparkListenerJobStart} | ||
import org.apache.spark.{SparkContext, SparkEnv, SparkException} | ||
import org.apache.spark.scheduler.{SparkListener, SparkListenerJobStart, SparkListenerTaskStart} | ||
import org.apache.spark.sql._ | ||
import org.apache.spark.sql.catalyst.plans.logical.Range | ||
import org.apache.spark.sql.catalyst.streaming.InternalOutputModes | ||
import org.apache.spark.sql.execution.command.ExplainCommand | ||
import org.apache.spark.sql.execution.datasources.v2.{DataSourceV2ScanExec, WriteToDataSourceV2Exec} | ||
import org.apache.spark.sql.execution.streaming._ | ||
import org.apache.spark.sql.execution.streaming.continuous._ | ||
import org.apache.spark.sql.execution.streaming.sources.MemorySinkV2 | ||
import org.apache.spark.sql.execution.streaming.state.{StateStore, StateStoreConf, StateStoreId, StateStoreProvider} | ||
import org.apache.spark.sql.functions._ | ||
import org.apache.spark.sql.internal.SQLConf | ||
import org.apache.spark.sql.sources.StreamSourceProvider | ||
import org.apache.spark.sql.streaming.{StreamTest, Trigger} | ||
import org.apache.spark.sql.streaming.util.StreamManualClock | ||
import org.apache.spark.sql.test.TestSparkSession | ||
import org.apache.spark.sql.types._ | ||
import org.apache.spark.util.Utils | ||
|
||
class ContinuousSuiteBase extends StreamTest { | ||
// We need more than the default local[2] to be able to schedule all partitions simultaneously. | ||
|
@@ -219,6 +201,41 @@ class ContinuousSuite extends ContinuousSuiteBase { | |
StopStream) | ||
} | ||
|
||
test("task failure kills the query") { | ||
val df = spark.readStream | ||
.format("rate") | ||
.option("numPartitions", "5") | ||
.option("rowsPerSecond", "5") | ||
.load() | ||
.select('value) | ||
|
||
// Get an arbitrary task from this query to kill. It doesn't matter which one. | ||
var taskId: Long = -1 | ||
val listener = new SparkListener() { | ||
override def onTaskStart(start: SparkListenerTaskStart): Unit = { | ||
taskId = start.taskInfo.taskId | ||
} | ||
} | ||
spark.sparkContext.addSparkListener(listener) | ||
try { | ||
testStream(df, useV2Sink = true)( | ||
StartStream(Trigger.Continuous(100)), | ||
Execute(waitForRateSourceTriggers(_, 2)), | ||
Execute { _ => | ||
// Wait until a task is started, then kill its first attempt. | ||
eventually(timeout(streamingTimeout)) { | ||
assert(taskId != -1) | ||
} | ||
spark.sparkContext.killTaskAttempt(taskId) | ||
}, | ||
ExpectFailure[SparkException] { e => | ||
e.getCause != null && e.getCause.getCause.isInstanceOf[ContinuousTaskRetryException] | ||
}) | ||
} finally { | ||
spark.sparkContext.removeSparkListener(listener) | ||
} | ||
} | ||
|
||
test("query without test harness") { | ||
val df = spark.readStream | ||
.format("rate") | ||
|
@@ -258,13 +275,9 @@ class ContinuousStressSuite extends ContinuousSuiteBase { | |
AwaitEpoch(0), | ||
Execute(waitForRateSourceTriggers(_, 201)), | ||
IncrementEpoch(), | ||
Execute { query => | ||
val data = query.sink.asInstanceOf[MemorySinkV2].allData | ||
val vals = data.map(_.getLong(0)).toSet | ||
assert(scala.Range(0, 25000).forall { i => | ||
vals.contains(i) | ||
}) | ||
}) | ||
StopStream, | ||
CheckAnswerRowsContains(scala.Range(0, 25000).map(Row(_))) | ||
) | ||
} | ||
|
||
test("automatic epoch advancement") { | ||
|
@@ -280,6 +293,7 @@ class ContinuousStressSuite extends ContinuousSuiteBase { | |
AwaitEpoch(0), | ||
Execute(waitForRateSourceTriggers(_, 201)), | ||
IncrementEpoch(), | ||
StopStream, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these needed? |
||
CheckAnswerRowsContains(scala.Range(0, 25000).map(Row(_)))) | ||
} | ||
|
||
|
@@ -311,6 +325,7 @@ class ContinuousStressSuite extends ContinuousSuiteBase { | |
StopStream, | ||
StartStream(Trigger.Continuous(2012)), | ||
AwaitEpoch(50), | ||
StopStream, | ||
CheckAnswerRowsContains(scala.Range(0, 25000).map(Row(_)))) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the earlier comment about the overloaded failure mode this PR exposed.