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

Fixed bug leading to semaphore leak when filtering messages #1891

Merged
merged 16 commits into from
Aug 23, 2024

Conversation

szczygiel-m
Copy link
Contributor

No description provided.

faderskd
faderskd previously approved these changes Aug 14, 2024
@@ -72,6 +76,8 @@ public Map<SubscriptionPartitionOffset, MessageState> getOffsetsSnapshotAndRelea
if (entry.getValue() == MessageState.PROCESSED) {
slots.remove(entry.getKey());
permitsReleased++;
} else if (entry.getValue() == MessageState.FILTERED) {
Copy link
Contributor

@faderskd faderskd Aug 14, 2024

Choose a reason for hiding this comment

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

Maybe it would be convenient to have a comment that we only increase semaphore before a sending message, and omitting increasing for filtered, but in any case we put a slot for both of the messages. I just had some problems with understanding how there can be slots in the queue but we didn't increased semaphore for them, thus the comment would help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed the approach and now filtered messages acquires semaphore, please take a look now 😄

hermes.api().publishUntilSuccess(topic.getQualifiedName(), BOB.asJson());

// then
expectSingleBatch(subscriber, SINGLE_MESSAGE_FILTERED);
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestions:

  1. check the value of metric subscription.filtered-out
  2. publish bob first - he is getting filtered
  3. maybe set batch size to 2, and batch time to some small value?

"topic", topic.getName().getName()
)
.withValue(1.0)
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why 1.0 instead of 2.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because previously we set subscriptionPolicy().withInflightSize(1) and we want to be sure, that this value wouldn't be exceeded when there are more messages and there were messages filtered previously.

@@ -53,6 +53,8 @@ public class Message implements FilterableMessage {

private long currentMessageBackoff = -1;

private boolean isFiltered = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

we must ensure that the this value is visible to all threads (see the comment on top of this class)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have checked it and this is always used within a single thread.

Copy link
Collaborator

@moscicky moscicky left a comment

Choose a reason for hiding this comment

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

Previously the semantics of Optional.empty from MessageReceiver#next were that the either the message was not present in kafka or it was filtered. Please add a java doc in MessageReceiver explaining what is the meaning of Optional.empty and Messages#isFiltered now

@@ -10,6 +10,21 @@

public interface MessageReceiver {

/**
* Retrieves the next available message from the queue.
*
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@szczygiel-m szczygiel-m merged commit 1b730c2 into master Aug 23, 2024
27 checks passed
@szczygiel-m szczygiel-m deleted the new_offset_committing_bugfix branch August 23, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants