-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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-18670][SS]Limit the number of StreamingQueryListener.StreamProgressEvent when there is no data #16108
Conversation
cc @tdas |
@@ -603,6 +603,13 @@ object SQLConf { | |||
.timeConf(TimeUnit.MILLISECONDS) | |||
.createWithDefault(10L) | |||
|
|||
val STREAMING_NO_DATA_REPORT_INTERVAL = |
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.
Report
is not a term used anywhere. How about streamingNoDataEventInterval
val STREAMING_NO_DATA_REPORT_INTERVAL = | ||
SQLConfigBuilder("spark.sql.streaming.noDataReportInterval") | ||
.internal() | ||
.doc("How long to wait between two progress events when there is no data") |
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.
... (in ms) ...
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.
TimeConf supports various units like 10s
, 100ms
. The unit here is telling which unit we want to use when getting this conf.
if (dataAvailable) { | ||
postEvent(new QueryProgressEvent(lastProgress)) | ||
} else { | ||
val now = triggerClock.getTimeMillis() |
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.
Shouldnt there be an event every time the system switches from dataAvailable = true, to dataAvailable = false. This logic wont do that right?
withSQLConf(SQLConf.STREAMING_NO_DATA_REPORT_INTERVAL.key -> "100ms") { | ||
@volatile var progressEventCount = 0 | ||
|
||
val listener = new StreamingQueryListener { |
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.
can you write a short explanation on what this test does. it hard to understand.
@@ -191,6 +192,48 @@ class StreamingQueryListenerSuite extends StreamTest with BeforeAndAfter { | |||
assert(queryQueryTerminated.exception === newQueryTerminated.exception) | |||
} | |||
|
|||
test("noDataReportInterval") { |
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.
nit: make the name better - only one progressevent per interval when no data
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 the test can be simplified.
@@ -196,6 +198,9 @@ class StreamExecution( | |||
// While active, repeatedly attempt to run batches. | |||
SparkSession.setActiveSession(sparkSession) | |||
|
|||
// The timestamp we report an event that has no input data | |||
var noDataEventTimestamp = Long.MinValue |
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.
oh snap.... i didnt realize... this now more confusing with event time and watermark stuff. sorry! may be rename to lastNoDataProgressEventTime?
@@ -63,6 +63,8 @@ class StreamExecution( | |||
|
|||
private val pollingDelayMs = sparkSession.sessionState.conf.streamingPollingDelay | |||
|
|||
private val noDataEventInterval = sparkSession.sessionState.conf.streamingNoDataEventInterval |
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.
similar to below, noDataProgressEventInterval?
@@ -603,6 +603,13 @@ object SQLConf { | |||
.timeConf(TimeUnit.MILLISECONDS) | |||
.createWithDefault(10L) | |||
|
|||
val STREAMING_NO_DATA_EVENT_INTERVAL = | |||
SQLConfigBuilder("spark.sql.streaming.noDataEventInterval") |
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.
noDataProgressEventInterval
} | ||
} | ||
testStream(MemoryStream[Int].toDS)(actions: _*) | ||
// 11 is the max value of the possible numbers of events. |
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.
why 11? explanation?
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 this test looks a little complicated. Also you are assuming the fact the when there is no data, it will sleep for 10 ms real time. why not something like this.
val input = new MemoryStream() {
@volatile var numTriggers = 0
override def getOffset(): Offset = { numTriggers +=1 ; super.getOffset() }
}
...
// add listener with progressEventCount and flag isTerminationEventPosted
...
testStream(input.toDF) { // on real clock
AddData(...)
AssertOnQuery { q =>
eventually (timeout(streamingTimeout)) {
assert(input.numTriggers > 100) // at least 100 triggers have occurred
}
},
StopStream,
AssertOnQuery { q =>
eventually(timeout(streamingTimeout) {
assert(isTerminationEventPosted) // event queue has drained
assert(numProgressEvent >=1 && numProgressEvent <= 100) // no more than 10 events.
}
}
}
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.
Okay, that wont work as well, because there is not guarantee how long the 100 triggers would take. It may take 100 seconds in a slow machine, in which numProgress events could legitimately have 100 events.
Nonetheless manual clock tests can be improved.
actions += AssertOnQuery { _ => | ||
// Sleep so that if the config `noDataEventInterval` doesn't work, it has enough time | ||
// to report too many events. | ||
Thread.sleep(10) |
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 combination of manual clock and real time sleep is quite confusing
Test build #69505 has finished for PR 16108 at commit
|
Test build #69512 has finished for PR 16108 at commit
|
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.
Test looks good now. But there are other comments that need to be addressed. The name is still confusing, in a different way now. I should have thought of that before suggesting.
testStream(input.toDS)(actions: _*) | ||
spark.sparkContext.listenerBus.waitUntilEmpty(10000) | ||
// 11 is the max value of the possible numbers of events. | ||
assert(numProgressEvent >= 1 && numProgressEvent <= 11) |
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.
Shouldnt this be > 1? What if there is a bug that it only outputs once when isData goes from true -> false, and never outputs again, irrespective of the noDataInterval?
Test build #69526 has finished for PR 16108 at commit
|
Test build #69545 has finished for PR 16108 at commit
|
LGTM. Merging to master and 2.1 |
…ogressEvent when there is no data ## What changes were proposed in this pull request? This PR adds a sql conf `spark.sql.streaming.noDataReportInterval` to control how long to wait before outputing the next StreamProgressEvent when there is no data. ## How was this patch tested? The added unit test. Author: Shixiong Zhu <shixiong@databricks.com> Closes #16108 from zsxwing/SPARK-18670. (cherry picked from commit 56a503d) Signed-off-by: Tathagata Das <tathagata.das1565@gmail.com>
…ogressEvent when there is no data ## What changes were proposed in this pull request? This PR adds a sql conf `spark.sql.streaming.noDataReportInterval` to control how long to wait before outputing the next StreamProgressEvent when there is no data. ## How was this patch tested? The added unit test. Author: Shixiong Zhu <shixiong@databricks.com> Closes apache#16108 from zsxwing/SPARK-18670.
…ogressEvent when there is no data ## What changes were proposed in this pull request? This PR adds a sql conf `spark.sql.streaming.noDataReportInterval` to control how long to wait before outputing the next StreamProgressEvent when there is no data. ## How was this patch tested? The added unit test. Author: Shixiong Zhu <shixiong@databricks.com> Closes apache#16108 from zsxwing/SPARK-18670.
What changes were proposed in this pull request?
This PR adds a sql conf
spark.sql.streaming.noDataReportInterval
to control how long to wait before outputing the next StreamProgressEvent when there is no data.How was this patch tested?
The added unit test.