Skip to content
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

[pulsar-client] Avoid leak on publish failure on batch message #5442

Merged
merged 1 commit into from
Oct 23, 2019

Conversation

rdhabalia
Copy link
Contributor

Motivation

Right now, producer-client tries to add batch message into batch-message-container and it can throw Error/RuntimeException BatchMessageContainer::add eg: OutOfDirectMemoryError. In this case, pulsar-client is not releasing payload which can leak the memory. SO, make sure to release payload even with any error.

@rdhabalia rdhabalia added this to the 2.4.2 milestone Oct 22, 2019
@rdhabalia rdhabalia self-assigned this Oct 22, 2019
batchMessageAndSend();
batchMessageContainer.add(msg, callback);
lastSendFuture = callback.getFuture();
} finally {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do get exception here, shouldn't we also trigger the send callback?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we trigger the callback but we missed to reduce to refCnt of payload in producer so, when callback receives callback, it tries to release payload with refCnt=2 so, producer doesn't release the actual payload.

@merlimat merlimat merged commit b466b08 into apache:master Oct 23, 2019
wolfstudy pushed a commit that referenced this pull request Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants