-
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][Follow Up] Task level retry for continuous processing #20675
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,7 +201,7 @@ class ContinuousSuite extends ContinuousSuiteBase { | |
StopStream) | ||
} | ||
|
||
test("task failure kills the query") { | ||
test("task restart") { | ||
val df = spark.readStream | ||
.format("rate") | ||
.option("numPartitions", "5") | ||
|
@@ -219,18 +219,59 @@ class ContinuousSuite extends ContinuousSuiteBase { | |
spark.sparkContext.addSparkListener(listener) | ||
try { | ||
testStream(df, useV2Sink = true)( | ||
StartStream(Trigger.Continuous(100)), | ||
StartStream(longContinuousTrigger), | ||
AwaitEpoch(0), | ||
Execute(waitForRateSourceTriggers(_, 2)), | ||
IncrementEpoch(), | ||
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] | ||
}) | ||
Execute(waitForRateSourceTriggers(_, 4)), | ||
IncrementEpoch(), | ||
// Check the answer exactly, if there's duplicated result, CheckAnserRowsContains | ||
// will also return true. | ||
CheckAnswerRowsContainsOnlyOnce(scala.Range(0, 20).map(Row(_))), | ||
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. Checking exact answer can just be 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. Actually I firstly use
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. Ah, right, my bad. |
||
StopStream) | ||
} finally { | ||
spark.sparkContext.removeSparkListener(listener) | ||
} | ||
} | ||
|
||
test("task restart without last offset") { | ||
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(longContinuousTrigger), | ||
Execute { _ => | ||
// Wait until a task is started, then kill its first attempt. | ||
eventually(timeout(streamingTimeout)) { | ||
assert(taskId != -1) | ||
} | ||
spark.sparkContext.killTaskAttempt(taskId) | ||
}, | ||
AwaitEpoch(0), | ||
Execute(waitForRateSourceTriggers(_, 2)), | ||
IncrementEpoch(), | ||
CheckAnswerRowsContainsOnlyOnce(scala.Range(0, 10).map(Row(_))), | ||
StopStream) | ||
} finally { | ||
spark.sparkContext.removeSparkListener(listener) | ||
} | ||
|
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.
I think it might be better to create a new interface ContinuousDataReaderFactory, and implement this there as something like
createDataReaderWithOffset(PartitionOffset offset)
. That way the intended lifecycle is explicit.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.
Cool, that's more clearer.