-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-18144][SQL] logging StreamingQueryListener$QueryStartedEvent #15675
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
Changes from all commits
5a8dc87
46788bd
766c67d
24bcd7b
2c2147e
8d2b3a6
4b29d8f
00dd3ce
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 |
|---|---|---|
|
|
@@ -41,6 +41,8 @@ class StreamingQueryListenerBus(sparkListenerBus: LiveListenerBus) | |
| def post(event: StreamingQueryListener.Event) { | ||
| event match { | ||
| case s: QueryStartedEvent => | ||
| sparkListenerBus.post(s) | ||
|
Member
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.
Member
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. Since this is hacky, it's better to have some tests to make sure we won't break things in future when removing the hacky codes. |
||
| // post to local listeners to trigger callbacks | ||
| postToAll(s) | ||
| case _ => | ||
| sparkListenerBus.post(event) | ||
|
|
@@ -50,7 +52,13 @@ class StreamingQueryListenerBus(sparkListenerBus: LiveListenerBus) | |
| override def onOtherEvent(event: SparkListenerEvent): Unit = { | ||
| event match { | ||
| case e: StreamingQueryListener.Event => | ||
| postToAll(e) | ||
| // SPARK-18144: we broadcast QueryStartedEvent to all listeners attached to this bus | ||
| // synchronously and the ones attached to LiveListenerBus asynchronously. Therefore, | ||
| // we need to ignore QueryStartedEvent if this method is called within SparkListenerBus | ||
| // thread | ||
| if (!LiveListenerBus.withinListenerThread.value || !e.isInstanceOf[QueryStartedEvent]) { | ||
| postToAll(e) | ||
| } | ||
| case _ => | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,7 +290,10 @@ class StreamingQuerySuite extends StreamTest with BeforeAndAfter with Logging { | |
| // A StreamingQueryListener that gets the query status after the first completed trigger | ||
| val listener = new StreamingQueryListener { | ||
| @volatile var firstStatus: StreamingQueryStatus = null | ||
| override def onQueryStarted(queryStarted: QueryStartedEvent): Unit = { } | ||
| @volatile var queryStartedEvent = 0 | ||
|
Member
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. nit: please add |
||
| override def onQueryStarted(queryStarted: QueryStartedEvent): Unit = { | ||
| queryStartedEvent += 1 | ||
| } | ||
| override def onQueryProgress(queryProgress: QueryProgressEvent): Unit = { | ||
| if (firstStatus == null) firstStatus = queryProgress.queryStatus | ||
| } | ||
|
|
@@ -303,6 +306,8 @@ class StreamingQuerySuite extends StreamTest with BeforeAndAfter with Logging { | |
| q.processAllAvailable() | ||
| eventually(timeout(streamingTimeout)) { | ||
| assert(listener.firstStatus != null) | ||
| // test if QueryStartedEvent callback is called for only once | ||
| assert(listener.queryStartedEvent === 1) | ||
| } | ||
| listener.firstStatus | ||
| } finally { | ||
|
|
||
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.
actually I didn't see any reason to distinguish these two types of event when posting