-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Unlink delegate in ReleasableBytesReference once ref count reaches 0 #127058
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
base: main
Are you sure you want to change the base?
Unlink delegate in ReleasableBytesReference once ref count reaches 0 #127058
Conversation
We have some spots where we retain a reference to the `ReleasableBytesReference` instance well beyond its ref-count reaching `0`. If it itself references Netty buffers or `BigArrays` that are not pooled (mostly as a result of overflowing the pooled number of bytes for large messages or under heavy load) then those bytes are not GC-able unless we unlink them here.
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
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.
Deserves a few more assertions or at least null checks e.g. in isFragment()
, ramBytesUsed()
, length()
, retainedSlice()
; also retain()
should probably mustIncRef
now.
Makes sense, added an assertion on the delegate into |
@@ -282,7 +281,7 @@ public void testIndicesPrivilegesAreEnforcedForCcrRestoreSessionActions() throws | |||
GetCcrRestoreFileChunkAction.REMOTE_TYPE, | |||
new GetCcrRestoreFileChunkRequest(response2.getNode(), sessionUUID2, leaderIndex2FileName, 1, shardId2) | |||
); | |||
assertThat(getChunkResponse.getChunk().length(), equalTo(1)); | |||
assertFalse(getChunkResponse.getChunk().hasReferences()); |
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.
Heh this is pretty much exactly what this is about :P this assertion shouldn't have worked but worked as long as we didn't check for having a reference in the length()
call. I see no value in the original version and there's a tiny bit of value in checking that we actually released the reference here but I guess we could just as well drop any assertion on the response.
We have some spots where we retain a reference to the
ReleasableBytesReference
instance well beyond its ref-count reaching0
. If it itself references Netty buffers orBigArrays
that are not pooled (mostly as a result of overflowing the pooled number of bytes for large messages or under heavy load) then those bytes are not GC-able unless we unlink them here.