Skip to content

Conversation

@poorbarcode
Copy link
Contributor

@poorbarcode poorbarcode commented Aug 12, 2025

Motivation

1. Instead of finding the target position for each subscription, search the target position once, and expire messages for each subscription.

Background: The steps of expiry of a topic

  • Call expiry for each subscription
    • The subscription finds the target position, then calls mark deleting for the cursor
  • Call expiry for each replicator
    • The replicator finds the target position, then calls mark deleting for the cursor

So the task calls for finding the target position many times when a topic expires. But the finding position operation is really expensive

2. Improve the method expireMessages(Position)

The previous steps of expiring messages by position:

  • Search the target position with a binary search
  • Expire messages by the target position.

It costs a lot, we can simplify the steps by managedLedger.getPreviousPosition(x)

Modifications

Since all of the tasks that find the target position that relates to the same topic will get the same result, we can call the finding operation at most once, during expiring messages for a topic

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: x

…ng messages for a topic, even though there are many subscriptions
@poorbarcode poorbarcode added this to the 4.1.0 milestone Aug 12, 2025
@poorbarcode poorbarcode self-assigned this Aug 12, 2025
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Aug 12, 2025
@poorbarcode poorbarcode requested a review from coderzc August 13, 2025 02:22
@poorbarcode
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

@poorbarcode poorbarcode merged commit 84205eb into apache:master Aug 28, 2025
141 of 145 checks passed
poorbarcode pushed a commit that referenced this pull request Aug 28, 2025
…ng messages for a topic, even though there are many subscriptions (#24622)

(cherry picked from commit 84205eb)
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 55.10204% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.26%. Comparing base (277835a) to head (5180d8a).
⚠️ Report is 32 commits behind head on master.

Files with missing lines Patch % Lines
...sar/broker/service/persistent/PersistentTopic.java 47.50% 19 Missing and 2 partials ⚠️
...ice/persistent/PersistentMessageExpiryMonitor.java 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24622      +/-   ##
============================================
- Coverage     74.38%   74.26%   -0.12%     
- Complexity    32808    32848      +40     
============================================
  Files          1881     1885       +4     
  Lines        146843   147007     +164     
  Branches      16866    16936      +70     
============================================
- Hits         109222   109169      -53     
- Misses        28964    29131     +167     
- Partials       8657     8707      +50     
Flag Coverage Δ
inttests 26.62% <2.04%> (-0.17%) ⬇️
systests 22.70% <2.04%> (-0.63%) ⬇️
unittests 73.74% <55.10%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...g/apache/bookkeeper/mledger/impl/OpFindNewest.java 78.51% <ø> (ø)
...ice/persistent/PersistentMessageExpiryMonitor.java 66.15% <88.88%> (+3.34%) ⬆️
...sar/broker/service/persistent/PersistentTopic.java 79.37% <47.50%> (-1.06%) ⬇️

... and 123 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 28, 2025
…ng messages for a topic, even though there are many subscriptions (apache#24622)

(cherry picked from commit 84205eb)
(cherry picked from commit 29778d5)
Technoboy- pushed a commit to Technoboy-/pulsar that referenced this pull request Sep 10, 2025
…ng messages for a topic, even though there are many subscriptions (apache#24622)

(cherry picked from commit 84205eb)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Sep 12, 2025
…ng messages for a topic, even though there are many subscriptions (apache#24622)

(cherry picked from commit 84205eb)
(cherry picked from commit 29778d5)
nborisov pushed a commit to nborisov/pulsar that referenced this pull request Sep 12, 2025
…ng messages for a topic, even though there are many subscriptions (apache#24622)

(cherry picked from commit 84205eb)
KannarFr pushed a commit to CleverCloud/pulsar that referenced this pull request Sep 22, 2025
…ng messages for a topic, even though there are many subscriptions (apache#24622)
walkinggo pushed a commit to walkinggo/pulsar that referenced this pull request Oct 8, 2025
…ng messages for a topic, even though there are many subscriptions (apache#24622)
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.

4 participants