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

feature: Pulsar pool messages support in failure handlers #2584

Merged
merged 2 commits into from
Apr 15, 2024

Conversation

michalcukierman
Copy link
Contributor

Added messages release in failure handler, What do you think @ozangunalp @marekczajkowski?

Copy link
Collaborator

@ozangunalp ozangunalp left a comment

Choose a reason for hiding this comment

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

I'll add a change to run ack/nack tests with poolMessages to true.

@@ -42,6 +42,7 @@ public PulsarIgnore(String channel) {
public Uni<Void> handle(PulsarIncomingMessage<?> message, Throwable reason, Metadata metadata) {
log.messageFailureIgnored(channel, reason.getMessage());
log.messageFailureFullCause(reason);
message.unwrap().release();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would not work as the ack needs to access messageid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ozangunalp
the release method:

public void release() {
    if (this.poolMessage) {
      ReferenceCountUtil.safeRelease(this.payload);
      this.recycle();
    }

  }

works only on payload, not the messageId. MessageId is not a ByteBuf, but a standard Java class (not a direct memory).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok your are right, the recycle method sets the messageId to null. I'll fix that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@michalcukierman I just pushed a change to the branch with some tests. The final change only calls the release on continue and failstop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @ozangunalp and sorry for incomplete PR, I believe it’s OK now. We’ll probably enable pooling, so if anything comes out, we will let you know.

Choose a reason for hiding this comment

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

@ozangunalp It looks like the message release introduced by @michalcukierman is required to avoid a memory leak. While this change resolves the direct memory issue, it breaks DLQ functionality due to a bug in Pulsar. I have created an issue to track this problem.

@ozangunalp ozangunalp merged commit 4b95ff1 into smallrye:main Apr 15, 2024
4 checks passed
@ozangunalp ozangunalp added this to the 4.21.0 milestone Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants