-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Issue 6437][broker] Prevent marker messages from accumulating in backlog of replicated subscription #7299
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
Conversation
| if (dispatcher == null || !dispatcher.isAtleastOneConsumerAvailable()) { | ||
| sub.acknowledgeMessage(Collections.singletonList(position), AckType.Individual, | ||
| Collections.emptyMap()); | ||
| } |
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.
I'm a bit worried here. If the producer continues to produce messages but does not have consumers to consume messages, the individual ack the snapshot message will introduce more discontinuous acknowledge ranges. If that is true, the individualAcks in the cursor will get bigger and bigger.
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.
And if all consumers of the subscription are disconnected. The subscription also removes from this topic. So maybe can't ack the snapshot message at this moment.
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.
I'm a bit worried here. If the producer continues to produce messages but does not have consumers to consume messages, the individual ack the snapshot message will introduce more discontinuous acknowledge ranges. If that is true, the
individualAcksin the cursor will get bigger and bigger.
I see. Uhm...
Is there any other solution to this issue?
And if all consumers of the subscription are disconnected. The subscription also removes from this topic. So maybe can't ack the snapshot message at this moment.
If there are no subscriptions on the topic, we don't need to ack since the messages will not accumulate in the backlog, do we?
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.
Is there any other solution to this issue?
I also don’t have a very good way, it looks okay, just an extreme case
If there are no subscriptions on the topic, we don't need to ack since the messages will not accumulate in the backlog, do we?
make sense
|
move to milestone 2.8.0 first |
…affic (#10292) ### Motivation Fixes #6437 This is a different approach to fix the issue, alternative to #7299. Instead of automatically acking the marker messages when the consumers are not connected, we should instead stop taking the snapshot when there's no traffic. There's no point in continuing storing these snapshots all the time if there's no traffic. ### Modifications 1. When we detect that there has been no new messages since the last snapshot was take, skip the new snapshot. 2. When there are no local producers, skip 1 snapshot creation. This is done in order to create a quiet period and give more time to not have any remote markers since our last snapshot was created.
This is a further modification of the previously closed PR #6592.
Fixes #6437
Motivation
In a replicated subscription with no consumers connected, the number of marker messages in the backlog will continue to increase. If at least one active consumer is connected, the marker messages will be acknowledged and deleted by the dispatcher.
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java
Lines 88 to 100 in 2d2c63e
On the other hand, if no consumers are connected, or if they are connected but cannot receive any messages, the dispatcher does not exist or has stopped reading entries. As a result, the marker messages accumulate in the backlog without being acknoledged by anyone.
Modifications
There are four types of marker messages:
Of these, three messages, except
ReplicatedSubscriptionsSnapshot, are not used in the local cluster. They are published to local topics for sending to remote clusters. So, modified theReplicatedSubscriptionsControllerclass to acknowledge these marker messages on all subscriptions immediately after publishing the messages to a local topic.On the other hand,
ReplicatedSubscriptionsSnapshotis only used by dispatchers in the local cluster and does not need to be sent to remote clusters. So,ReplicatedSubscriptionsControlleronly acknowledges those messages on behalf of dispatcher if dispatcher has not been initialized or if there are no available consumers.In addition, marker messages sent from remote clusters are now acknowledged by the replicator on all subscriptions.
With these changes, marker messages no longer continue to accumulate in the replicated subscription backlog.