Uh oh!
There was an error while loading. Please reload this page.
[SPARK-17813][SQL][KAFKA] Maximum data per trigger - #15527
Conversation
Testing maxOffsetsPerTrigger requires the per-partition sendMessages testing added in SPARK-17812
SparkQA
commented
Oct 18, 2016
Test build #67113 has finished for PR 15527 at commit
|
SparkQA
commented
Oct 24, 2016
Test build #67455 has finished for PR 15527 at commit
|
SparkQA
commented
Oct 24, 2016
Test build #67459 has finished for PR 15527 at commit
|
zsxwing
left a comment
There was a problem hiding this comment.
Thanks for your work. The major issue is currentPartitionOffsets should be set when recovering from failure.
| @@ -153,11 +201,7 @@ private[kafka010] case class KafkaSource( | |||
There was a problem hiding this comment.
currentPartitionOffsets should be set to untilPartitionOffsets if it's empty. It means recovery from a failure.
There was a problem hiding this comment.
Shouldn't it be set to the highest available offset in the streaming metadata log, not the highest available offset in kafka?
There was a problem hiding this comment.
currentPartitionOffsets is the last processed offsets. Right? When recovering from the failure, getBatch will be called firstly, then getOffset.
There was a problem hiding this comment.
Ok, I see what you were saying, thought you were talking about resetting it in getOffset, not the end passed to getBatch.
| StartStream(ProcessingTime(100), clock), | ||
| AdvanceManualClock(100), | ||
| // 1 from smallest, 1 from middle, 8 from biggest | ||
| CheckAnswer(1, 10, 100, 101, 102, 103, 104, 105, 106, 107), |
There was a problem hiding this comment.
There is a race condition here. The batch may be still running. I figured out the following codes to cover the recovery and fix the race condition finally.
test("maxOffsetsPerTrigger") {
valtopic= newTopic()
testUtils.createTopic(topic, partitions =3)
testUtils.sendMessages(topic, (100 to 200).map(_.toString).toArray, Some(0))
testUtils.sendMessages(topic, (10 to 20).map(_.toString).toArray, Some(1))
testUtils.sendMessages(topic, Array("1"), Some(2))
valreader= spark
.readStream
.format("kafka")
.option("kafka.bootstrap.servers", testUtils.brokerAddress)
.option("kafka.metadata.max.age.ms", "1")
.option("maxOffsetsPerTrigger", 10)
.option("subscribe", topic)
.option("startingOffsets", "earliest")
valkafka= reader.load()
.selectExpr("CAST(key AS STRING)", "CAST(value AS STRING)")
.as[(String, String)]
valmapped: org.apache.spark.sql.Dataset[_] = kafka.map(kv => kv._2.toInt)
valclock=newStreamManualClockvalwaitUntilBatchProcessed=AssertOnQuery { q =>
eventually(Timeout(streamingTimeout)) {
if (!q.exception.isDefined) {
assert(clock.isStreamWaitingAt(clock.getTimeMillis()))
}
}
if (q.exception.isDefined) {
throw q.exception.get
}
true
}
testStream(mapped)(
StartStream(ProcessingTime(100), clock),
waitUntilBatchProcessed,
// 1 from smallest, 1 from middle, 8 from biggestCheckAnswer(1, 10, 100, 101, 102, 103, 104, 105, 106, 107),
AdvanceManualClock(100),
waitUntilBatchProcessed,
// smallest now empty, 1 more from middle, 9 more from biggestCheckAnswer(1, 10, 100, 101, 102, 103, 104, 105, 106, 107,
11, 108, 109, 110, 111, 112, 113, 114, 115, 116
),
StopStream,
StartStream(ProcessingTime(100), clock),
waitUntilBatchProcessed,
AdvanceManualClock(100),
waitUntilBatchProcessed,
// smallest now empty, 1 more from middle, 9 more from biggestCheckAnswer(1, 10, 100, 101, 102, 103, 104, 105, 106, 107,
11, 108, 109, 110, 111, 112, 113, 114, 115, 116,
12, 117, 118, 119, 120, 121, 122, 123, 124, 125
),
AdvanceManualClock(100),
waitUntilBatchProcessed,
// smallest now empty, 1 more from middle, 9 more from biggestCheckAnswer(1, 10, 100, 101, 102, 103, 104, 105, 106, 107,
11, 108, 109, 110, 111, 112, 113, 114, 115, 116,
12, 117, 118, 119, 120, 121, 122, 123, 124, 125,
13, 126, 127, 128, 129, 130, 131, 132, 133, 134
)
)
}This test fails now because of an issue being fixed in #14553.
SparkQA
commented
Oct 27, 2016
Test build #67616 has finished for PR 15527 at commit
|
| until: Map[TopicPartition, Long]): Map[TopicPartition, Long] = { | ||
| val fromNew = fetchNewPartitionEarliestOffsets(until.keySet.diff(from.keySet).toSeq) | ||
| val sizes = until.flatMap { case (tp, end) => | ||
| // If begin isn't defined, something's wrong, but let alert logic in getBatch handle it |
| until | ||
| } else { | ||
| until.map { case (tp, end) => | ||
| tp -> sizes.get(tp).map { size => |
SparkQA
commented
Oct 27, 2016
Test build #67645 has finished for PR 15527 at commit
|
zsxwing
commented
Oct 27, 2016
LGTM. Thanks! Merging to master and 2.0. |
## What changes were proposed in this pull request? maxOffsetsPerTrigger option for rate limiting, proportionally based on volume of different topicpartitions. ## How was this patch tested? Added unit test Author: cody koeninger <cody@koeninger.org> Closes#15527 from koeninger/SPARK-17813. (cherry picked from commit 1042325) Signed-off-by: Shixiong Zhu <shixiong@databricks.com>
## What changes were proposed in this pull request? maxOffsetsPerTrigger option for rate limiting, proportionally based on volume of different topicpartitions. ## How was this patch tested? Added unit test Author: cody koeninger <cody@koeninger.org> Closesapache#15527 from koeninger/SPARK-17813.
## What changes were proposed in this pull request? maxOffsetsPerTrigger option for rate limiting, proportionally based on volume of different topicpartitions. ## How was this patch tested? Added unit test Author: cody koeninger <cody@koeninger.org> Closesapache#15527 from koeninger/SPARK-17813.
What changes were proposed in this pull request?
maxOffsetsPerTrigger option for rate limiting, proportionally based on volume of different topicpartitions.
How was this patch tested?
Added unit test