-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[fix][broker] Release EntryBuffer after parse proto object #20170
Conversation
@@ -127,7 +127,9 @@ private CompletableFuture<Void> addSnapshotSegments(LedgerHandle ledgerHandle, | |||
private SnapshotMetadata parseSnapshotMetadataEntry(LedgerEntry ledgerEntry) { | |||
try { | |||
ByteBuf entryBuffer = ledgerEntry.getEntryBuffer(); | |||
return SnapshotMetadata.parseFrom(entryBuffer.nioBuffer()); | |||
SnapshotMetadata snapshotMetadata = SnapshotMetadata.parseFrom(entryBuffer.nioBuffer()); |
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.
You should add try-finally here to aovid any exception.
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.
Ok
@@ -140,6 +142,7 @@ private List<SnapshotSegment> parseSnapshotSegmentEntries(Enumeration<LedgerEntr | |||
SnapshotSegment snapshotSegment = new SnapshotSegment(); | |||
ByteBuf entryBuffer = ledgerEntry.getEntryBuffer(); | |||
snapshotSegment.parseFrom(entryBuffer, entryBuffer.readableBytes()); | |||
entryBuffer.release(); |
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.
Same as above.
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.
Ok
de36c72
to
03f6154
Compare
03f6154
to
950f73b
Compare
Codecov Report
@@ Coverage Diff @@
## master #20170 +/- ##
============================================
+ Coverage 72.55% 72.95% +0.39%
- Complexity 3661 31960 +28299
============================================
Files 1868 1868
Lines 138457 138468 +11
Branches 15235 15236 +1
============================================
+ Hits 100458 101017 +559
+ Misses 29953 29415 -538
+ Partials 8046 8036 -10
Flags with carried forward coverage won't be shown. Click here to find out more.
|
(cherry picked from commit 35e9897)
Motivation & Modifications
Release EntryBuffer after parsing the proto object, It was introduced by PR #20158
Reduce data copy on the addEntry
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: