You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2022/10/25 13:35:30 UTC
[GitHub] [bookkeeper] wenbingshen opened a new pull request, #3577: Fix set explicitLac no released entry
wenbingshen opened a new pull request, #3577:
URL: https://github.com/apache/bookkeeper/pull/3577
### Motivation
org.apache.bookkeeper.bookie.BookieImpl#setExplicitLac did not release the reference to the entry at the end.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] StevenLuMT commented on a diff in pull request #3577: Fix ByteBuf memory leak problem when setExplicitLac
Posted by GitBox <gi...@apache.org>.
StevenLuMT commented on code in PR #3577:
URL: https://github.com/apache/bookkeeper/pull/3577#discussion_r1007746366
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieImpl.java:
##########
@@ -1016,19 +1017,25 @@ private ByteBuf createExplicitLACEntry(long ledgerId, ByteBuf explicitLac) {
public void setExplicitLac(ByteBuf entry, WriteCallback writeCallback, Object ctx, byte[] masterKey)
throws IOException, InterruptedException, BookieException {
+ ByteBuf explicitLACEntry = null;
try {
long ledgerId = entry.getLong(entry.readerIndex());
LedgerDescriptor handle = handles.getHandle(ledgerId, masterKey);
synchronized (handle) {
entry.markReaderIndex();
handle.setExplicitLac(entry);
entry.resetReaderIndex();
- ByteBuf explicitLACEntry = createExplicitLACEntry(ledgerId, entry);
+ explicitLACEntry = createExplicitLACEntry(ledgerId, entry);
getJournal(ledgerId).logAddEntry(explicitLACEntry, false /* ackBeforeSync */, writeCallback, ctx);
}
} catch (NoWritableLedgerDirException e) {
stateManager.transitionToReadOnlyMode();
throw new IOException(e);
+ } finally {
+ entry.release();
Review Comment:
I think can use ReferenceCountUtil.safeRelease to release the entry,like the code:
`ReferenceCountUtil.safeRelease(entry);`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] wenbingshen commented on pull request #3577: Fix ByteBuf memory leak problem when setExplicitLac
Posted by GitBox <gi...@apache.org>.
wenbingshen commented on PR #3577:
URL: https://github.com/apache/bookkeeper/pull/3577#issuecomment-1297949818
@StevenLuMT PTAL. Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] StevenLuMT commented on a diff in pull request #3577: Fix ByteBuf memory leak problem when setExplicitLac
Posted by GitBox <gi...@apache.org>.
StevenLuMT commented on code in PR #3577:
URL: https://github.com/apache/bookkeeper/pull/3577#discussion_r1007746366
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieImpl.java:
##########
@@ -1016,19 +1017,25 @@ private ByteBuf createExplicitLACEntry(long ledgerId, ByteBuf explicitLac) {
public void setExplicitLac(ByteBuf entry, WriteCallback writeCallback, Object ctx, byte[] masterKey)
throws IOException, InterruptedException, BookieException {
+ ByteBuf explicitLACEntry = null;
try {
long ledgerId = entry.getLong(entry.readerIndex());
LedgerDescriptor handle = handles.getHandle(ledgerId, masterKey);
synchronized (handle) {
entry.markReaderIndex();
handle.setExplicitLac(entry);
entry.resetReaderIndex();
- ByteBuf explicitLACEntry = createExplicitLACEntry(ledgerId, entry);
+ explicitLACEntry = createExplicitLACEntry(ledgerId, entry);
getJournal(ledgerId).logAddEntry(explicitLACEntry, false /* ackBeforeSync */, writeCallback, ctx);
}
} catch (NoWritableLedgerDirException e) {
stateManager.transitionToReadOnlyMode();
throw new IOException(e);
+ } finally {
+ entry.release();
Review Comment:
I think can use ReferenceCountUtil.safeRelease to release the entry,make sure run the next step
like the code:
`ReferenceCountUtil.safeRelease(entry);`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] wenbingshen commented on a diff in pull request #3577: Fix ByteBuf memory leak problem when setExplicitLac
Posted by GitBox <gi...@apache.org>.
wenbingshen commented on code in PR #3577:
URL: https://github.com/apache/bookkeeper/pull/3577#discussion_r1009140647
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieImpl.java:
##########
@@ -1016,19 +1017,25 @@ private ByteBuf createExplicitLACEntry(long ledgerId, ByteBuf explicitLac) {
public void setExplicitLac(ByteBuf entry, WriteCallback writeCallback, Object ctx, byte[] masterKey)
throws IOException, InterruptedException, BookieException {
+ ByteBuf explicitLACEntry = null;
try {
long ledgerId = entry.getLong(entry.readerIndex());
LedgerDescriptor handle = handles.getHandle(ledgerId, masterKey);
synchronized (handle) {
entry.markReaderIndex();
handle.setExplicitLac(entry);
entry.resetReaderIndex();
- ByteBuf explicitLACEntry = createExplicitLACEntry(ledgerId, entry);
+ explicitLACEntry = createExplicitLACEntry(ledgerId, entry);
getJournal(ledgerId).logAddEntry(explicitLACEntry, false /* ackBeforeSync */, writeCallback, ctx);
}
} catch (NoWritableLedgerDirException e) {
stateManager.transitionToReadOnlyMode();
throw new IOException(e);
+ } finally {
+ entry.release();
Review Comment:
I have addressed your comment. Thanks. PTAL.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] hangc0276 commented on pull request #3577: Fix ByteBuf memory leak problem when setExplicitLac
Posted by GitBox <gi...@apache.org>.
hangc0276 commented on PR #3577:
URL: https://github.com/apache/bookkeeper/pull/3577#issuecomment-1305011464
@wenbingshen It's hard to cherry-pick this pr to branch-4.14, would you please push a separate Pr to branch-4.14? thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] wenbingshen commented on pull request #3577: Fix ByteBuf memory leak problem when setExplicitLac
Posted by GitBox <gi...@apache.org>.
wenbingshen commented on PR #3577:
URL: https://github.com/apache/bookkeeper/pull/3577#issuecomment-1305022686
> @wenbingshen It's hard to cherry-pick this pr to branch-4.14, would you please push a separate Pr to branch-4.14? thanks
Okay. I will push a pr to 4.14 today.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] StevenLuMT merged pull request #3577: Fix ByteBuf memory leak problem when setExplicitLac
Posted by GitBox <gi...@apache.org>.
StevenLuMT merged PR #3577:
URL: https://github.com/apache/bookkeeper/pull/3577
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] wenbingshen commented on pull request #3577: Fix set explicitLac no released entry
Posted by GitBox <gi...@apache.org>.
wenbingshen commented on PR #3577:
URL: https://github.com/apache/bookkeeper/pull/3577#issuecomment-1293220687
@hangc0276 I have added an unit test. PTAL. Thanks.
When I apply the changes from this PR, the tests pass:

When I roll back the changes from this PR, the test fails:

The effect is as expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] wenbingshen commented on pull request #3577: Fix set explicitLac no released entry
Posted by GitBox <gi...@apache.org>.
wenbingshen commented on PR #3577:
URL: https://github.com/apache/bookkeeper/pull/3577#issuecomment-1291429215
> @wenbingshen Would you please add a test to cover it?
@hangc0276 Okay. I will add a test later. Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] wenbingshen commented on pull request #3577: Fix set explicitLac no released entry
Posted by GitBox <gi...@apache.org>.
wenbingshen commented on PR #3577:
URL: https://github.com/apache/bookkeeper/pull/3577#issuecomment-1290678143
ping @dlg99 @eolivelli @hangc0276 @zymap PTAL. Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] zymap commented on pull request #3577: Fix ByteBuf memory leak problem when setExplicitLac
Posted by GitBox <gi...@apache.org>.
zymap commented on PR #3577:
URL: https://github.com/apache/bookkeeper/pull/3577#issuecomment-1296468777
@StevenLuMT I think we could use another PR to resolve that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [bookkeeper] wenbingshen commented on pull request #3577: Fix ByteBuf memory leak problem when setExplicitLac
Posted by GitBox <gi...@apache.org>.
wenbingshen commented on PR #3577:
URL: https://github.com/apache/bookkeeper/pull/3577#issuecomment-1296470910
> @StevenLuMT I think we could use another PR to resolve that.
I agree.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org