Skip to content

[improve] [admin] Make the default value of param --get-subscription-backlog-size of admin API topics stats true - #19302

Merged
codelipenghui merged 3 commits into
apache:masterfrom
poorbarcode:discuss/get_subscription_backlog_size
Jan 28, 2023
Merged

[improve] [admin] Make the default value of param --get-subscription-backlog-size of admin API topics stats true#19302
codelipenghui merged 3 commits into
apache:masterfrom
poorbarcode:discuss/get_subscription_backlog_size

Conversation

@poorbarcode

@poorbarcode poorbarcode commented Jan 20, 2023

Copy link
Copy Markdown
Contributor

Motivation

In the PR #9302, the property backlog size of each subscription returned in the response of the API topics stats, by default this property is always equal to 0 in response, and this will confuse users. Since the calculation of backlog size is done in broker memory, there is no significant overhead(the process is described in the following section), so I think the correct values should be displayed by default.

Discuss in mail list

The following two APIs should be affected:

In Pulsar admin API

pulsar-admin topics stats persistent://test-tenant/ns1/tp1
--get-subscription-backlog-size
pulsar-admin topics stats persistent://test-tenant/ns1/tp1 -sbs

the default value of parameter --get-subscription-backlog-size will be true

In Pulsar Rest API

curl GET "http://127.0.0.1:8080/test-tenant/ns1/tp1/stats?subscriptionBacklogSize=true"

the default value of the parameter subscriptionBacklogSize will be true

The following is the process of calculating backlog size:

  • Divide PersistentTopc.ledgers into two parts according to the ledgerId of the mark delete position of the cursor. The second part is ledgers indicating the messages still need to be consumed, aka backlogSizeInLedgers.
  • Find the LedgerInfo whose ledgerId is the same as the ledgerId of the mark delete position of the cursor, and we can also divide the ledger into two parts, the second part is entries indicating the messages still need to be consumed, multiply the average size of each entry in metrics by the number of still need to be consumed entries we can get the backlog size in this ledger. aka backlogSizeInEntries.
  • backlogSizeInLedgers + backlogSizeInEntries

Modifications

  • Make the default value of param "--get-subscription-backlog-size" of admin API "topics stats" true
  • Make the attribute 'backlogSize' in the response to be -1 when -sbs is false, for distinguish whether --get-subscription-backlog-size is set to true

Documentation

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

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Jan 20, 2023

@gaoran10 gaoran10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, the calculation uses the data in memory, no IO operations, and maybe we can return -1 when the option param --get-subscription-backlog-size is false.

@poorbarcode
poorbarcode force-pushed the discuss/get_subscription_backlog_size branch from a11a246 to 7f572b3 Compare January 23, 2023 05:22
@poorbarcode

Copy link
Copy Markdown
Contributor Author

@gaoran10

the calculation uses the data in memory, no IO operations, and maybe we can return -1 when the option param --get-subscription-backlog-size is false.

Good idea. Already make the attribute 'backlogSize' in the response to be -1 when if -sbs is false. Please take a look again

@poorbarcode
poorbarcode requested a review from gaoran10 January 23, 2023 05:26
@codecov-commenter

codecov-commenter commented Jan 28, 2023

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.94%. Comparing base (457a0d5) to head (7f572b3).
⚠️ Report is 2952 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #19302      +/-   ##
============================================
+ Coverage     63.54%   64.94%   +1.40%     
- Complexity     3615    26379   +22764     
============================================
  Files          1895     1818      -77     
  Lines        137475   133776    -3699     
  Branches      15091    14692     -399     
============================================
- Hits          87355    86885     -470     
+ Misses        42240    39107    -3133     
+ Partials       7880     7784      -96     
Flag Coverage Δ
inttests 24.91% <100.00%> (+0.73%) ⬆️
systests 25.68% <100.00%> (-0.18%) ⬇️
unittests 62.28% <100.00%> (+0.70%) ⬆️

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

Files with missing lines Coverage Δ
...pache/pulsar/broker/admin/v2/PersistentTopics.java 75.44% <ø> (-0.08%) ⬇️
...ker/service/persistent/PersistentSubscription.java 69.93% <100.00%> (+1.33%) ⬆️
...in/java/org/apache/pulsar/admin/cli/CmdTopics.java 82.33% <ø> (+1.96%) ⬆️
...mon/policies/data/stats/SubscriptionStatsImpl.java 74.74% <ø> (ø)

... and 265 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.

@codelipenghui
codelipenghui merged commit e417fe7 into apache:master Jan 28, 2023
poorbarcode added a commit that referenced this pull request Feb 27, 2023
…backlog-size of admin API topics stats true (#19302)

(cherry picked from commit e417fe7)
@eolivelli

Copy link
Copy Markdown
Contributor

@poorbarcode this is a breaking change.
We should not commit it to released branches.

@eolivelli

Copy link
Copy Markdown
Contributor

cc @codelipenghui

@michaeljmarshall

Copy link
Copy Markdown
Member

I agree, this is a change in a default, we should not cherry pick it.

michaeljmarshall added a commit that referenced this pull request Feb 27, 2023
…ription-backlog-size of admin API topics stats true (#19302)"

This reverts commit 3095b6a.
michaeljmarshall added a commit that referenced this pull request Feb 27, 2023
…ription-backlog-size of admin API topics stats true (#19302)"

This reverts commit a863e7d.
@poorbarcode

Copy link
Copy Markdown
Contributor Author

@eolivelli @michaeljmarshall

Thanks for checking my mistakes

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.

8 participants