Skip to content

[fix][client] Match logical topic when removing unacked messages#25921

Merged
lhotari merged 2 commits into
apache:masterfrom
Dream95:fix_unacktracker_topicname
Jun 5, 2026
Merged

[fix][client] Match logical topic when removing unacked messages#25921
lhotari merged 2 commits into
apache:masterfrom
Dream95:fix_unacktracker_topicname

Conversation

@Dream95

@Dream95 Dream95 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Motivation

When a multi-topic consumer unsubscribes from a topic, it removes unacked messages that belong to the unsubscribed topic.
The previous matching logic used substring matching on TopicMessageId#getOwnerTopic(). This could incorrectly remove messages from topics with similar prefixes, such as matching my-topic-v2 when unsubscribing my-topic.

Modifications

  • Normalize both the message owner topic and the target topic to their partitioned topic name before comparing them.
  • Remove unacked messages for all partitions of the unsubscribed logical topic.
  • Add test coverage to verify that similarly prefixed topics are not removed by mistake.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:
./gradlew :pulsar-client-original:test --tests org.apache.pulsar.client.impl.UnAckedTopicMessageRedeliveryTrackerTest

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Signed-off-by: Dream95 <zhou_8621@163.com>
…c matching

Signed-off-by: Dream95 <zhou_8621@163.com>
@Dream95 Dream95 requested a review from lhotari June 3, 2026 16:03

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@lhotari lhotari merged commit 4e50957 into apache:master Jun 5, 2026
43 of 44 checks passed
lhotari pushed a commit that referenced this pull request Jun 5, 2026
)

Signed-off-by: Dream95 <zhou_8621@163.com>
(cherry picked from commit 4e50957)
lhotari pushed a commit that referenced this pull request Jun 5, 2026
)

Signed-off-by: Dream95 <zhou_8621@163.com>
(cherry picked from commit 4e50957)
priyanshu-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 8, 2026
…che#25921)

Signed-off-by: Dream95 <zhou_8621@163.com>
(cherry picked from commit 4e50957)
(cherry picked from commit d3690e8)
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.

3 participants