forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[SNAP-3270] removing streaming query listener in finalize method #195
Merged
Conversation
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
query manager when session instance is getting collected for GC.
finalize method block if it is already not initialized.
dshirish
approved these changes
Dec 12, 2019
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.
LGTM
(honoured by IDEA version > 2019)
failing due to assertion in after block.
sumwale
pushed a commit
to sumwale/spark
that referenced
this pull request
Nov 5, 2020
…OSoftware#195) For streaming UI, `SnappyStreamingQueryListener` is registered on listener bus at the time of creating `SnappySession`. However, this listener is never removed from the listener bus. Hence even if the `SnappySession` is collected by GC, `SnappyStreamingQueryListener` is left orphan on the listener bus which is never eligible for GC collection. To fix this we are removing the listener from the listener bus when the session the instance is getting collected by GC (i.e. in finalize method) which will make the listener instance eligible for GC during the next GC cycle. It should be OK if the listener instance gets collected in the next GC cycle as the the memory footprint of the listener object is not big. Another possible place to remove the listener in `close` method of the session, however close method of session is not required to be closed explicitly. Reproduced the issue by running the following code as part of a snappy job: ``` while(true){ session.newSession() } ``` Collected histogram of leader process using `jmap` and observed that instances of `SnappyStreamingQueryListener` is increasing indefinitely and never garbage collected whereas `SnappySession` instances are garbage collected: `jmap -histo:live <leader pid>|grep "SnappySession\|SnappyStreamingQueryListener"` Followed the same steps after applying the changes and noticed that `SnappyStreamingQueryListener` instances are garbage collected. --- - `SnappyStreamingQueryListenerSuite` is passing now. Added a call to `finalize` method in `StreamingQueryListenerSuite` to get this change tested.
sumwale
pushed a commit
that referenced
this pull request
Jul 11, 2021
For streaming UI, `SnappyStreamingQueryListener` is registered on listener bus at the time of creating `SnappySession`. However, this listener is never removed from the listener bus. Hence even if the `SnappySession` is collected by GC, `SnappyStreamingQueryListener` is left orphan on the listener bus which is never eligible for GC collection. To fix this we are removing the listener from the listener bus when the session the instance is getting collected by GC (i.e. in finalize method) which will make the listener instance eligible for GC during the next GC cycle. It should be OK if the listener instance gets collected in the next GC cycle as the the memory footprint of the listener object is not big. Another possible place to remove the listener in `close` method of the session, however close method of session is not required to be closed explicitly. Reproduced the issue by running the following code as part of a snappy job: ``` while(true){ session.newSession() } ``` Collected histogram of leader process using `jmap` and observed that instances of `SnappyStreamingQueryListener` is increasing indefinitely and never garbage collected whereas `SnappySession` instances are garbage collected: `jmap -histo:live <leader pid>|grep "SnappySession\|SnappyStreamingQueryListener"` Followed the same steps after applying the changes and noticed that `SnappyStreamingQueryListener` instances are garbage collected. --- - `SnappyStreamingQueryListenerSuite` is passing now. Added a call to `finalize` method in `StreamingQueryListenerSuite` to get this change tested.
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
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.
What changes were proposed in this pull request?
For streaming UI,
SnappyStreamingQueryListener
is registered on listener busat the time of creating
SnappySession
. However, this listener is never removedfrom the listener bus. Hence even if the
SnappySession
is collected by GC,SnappyStreamingQueryListener
is left orphan on the listener bus which is nevereligible for GC collection.
To fix this we are removing the listener from the listener bus when the session
the instance is getting collected by GC (i.e. in finalize method) which will make
the listener instance eligible for GC during the next GC cycle.
It should be OK if the listener instance gets collected in the next GC cycle as the
the memory footprint of the listener object is not big.
Another possible place to remove the listener in
close
method of the session,however close method of session is not required to be closed explicitly.
How was this patch tested?
Reproduced the issue by running the following code as part of a snappy job:
Collected histogram of leader process using
jmap
and observed that instances ofSnappyStreamingQueryListener
is increasing indefinitely and never garbagecollected whereas
SnappySession
instances are garbage collected:jmap -histo:live <leader pid>|grep "SnappySession\|SnappyStreamingQueryListener"
Followed the same steps after applying the changes and noticed that
SnappyStreamingQueryListener
instances are garbage collected.SnappyStreamingQueryListenerSuite
is passing now. Added a call tofinalize
method in
StreamingQueryListenerSuite
to get this change tested.