-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-45499][CORE][TESTS][FOLLOWUP] Use ReferenceQueue#remove instead of ReferenceQueue#poll
#43345
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
Conversation
| } | ||
| assert(ref.refersTo(null)) | ||
| assert(refQueue.poll() === ref) | ||
| assert(refQueue.remove() === ref) |
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.
cc @dongjoon-hyun @yaooqinn FYI
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.
remove is a blocking method, should we add a timeout(ms)? like .remove(1000)
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.
also cc @srowen
srowen
left a comment
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.
Meh yeah might be safer to add a timeout
|
OK, 24fe2c0 add |
|
Some test tasks failed, I will re-trigger them later |
The failed test case is not related to the current PR. |
ReferenceQueue#remove instead of ReferenceQueue#pollReferenceQueue#remove instead of ReferenceQueue#poll
|
Merged into master, thanks @srowen @dongjoon-hyun @yaooqinn |
What changes were proposed in this pull request?
This pr replaces
refQueue.poll()withrefQueue.remove()in the test casereference to sub iterator should not be available after completionto ensure that aPhantomReferenceobject can be retrieved fromrefQueue.Why are the changes needed?
#43325 replaces
Reference#isEnqueuedwithReference#refersTo(null)to eliminate the use of deprecated APIs.However, there are some differences between
ref.isEnqueuedandref.refersTo(null).The
ref.isEnqueuedmethod is used to check whether thisPhantomReferenceobject has been added to its reference queue by the garbage collector. When the garbage collector decides to recycle an object, if this object has one or morePhantomReference, then thesePhantomReferencewill be added to their reference queues. So, ifref.isEnqueuedreturnstrue, it means that thisPhantomReferencehas been added to the reference queue, which means that the object it references has been recycled by the garbage collector.The
ref.refersTo(null)method is used to check whether thisPhantomReferenceobject refers to the specified object. In the current code,ref.refersTo(null)is used to check whetherrefstill refers tosub. Ifref.refersTo(null)returnstrue, it means thatrefno longer refers tosub, which means thatsubmight have been recycled by the garbage collector. But this does not mean that thisrefhas been added to the reference queue.So we can see the following test failure in GA:
https://github.com/apache/spark/actions/runs/6484510414/job/17608536854
To solve this issue, this PR replaces
refQueue.poll()withrefQueue.remove()to allow for waiting untilrefis put intorefQueueand can be retrieved fromrefQueue.Does this PR introduce any user-facing change?
No
How was this patch tested?
Pass GitHub Actions
Was this patch authored or co-authored using generative AI tooling?
No