poorbarcode opened a new pull request, #19302:
URL: https://github.com/apache/pulsar/pull/19302

   ### Motivation
   
   In the PR https://github.com/apache/pulsar/pull/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
   - https://lists.apache.org/thread/wvjrp3co9fyl596onwv037944kdz000d
   
   #### 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`
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. Please attach the local 
preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR 
description, or else your PR might not get merged. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: 
   - https://github.com/poorbarcode/pulsar/pull/54
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to