poorbarcode commented on PR #19344:
URL: https://github.com/apache/pulsar/pull/19344#issuecomment-1407557307

   Hi @mattisonchao 
   
   This will lose the atomicity of `ledgers`, `currentLedger`, 
`currentLedgerEntries`, and `currentLedgerSize`, leading to incorrect 
calculation results. For example: 
    - current ML stat is: `{currentLedgerEntries=1,  currentLedgerSize=100}`
    - thread-1 increase two fields `currentLedgerEntries` and 
`currentLedgerSize`
      -  `currentLedgerEntries += 100`
    - thread-2 calculate the backlog size
      - avg size per entry is 
`currentLedgerEntries/currentLedgerEntries`(result is `200/1`), but the 
expected result is `100/1` or `200/2`
    
   The example shows what might happen if `currentLedgerEntries` and 
`currentLedgerSize` don't match, and there should be other cases:
   - `currentLedger` and `currentLedgerSize` don't match
   - the last ledger in`ledgers` does not match `currentLedger`
   - and so on
   
   Maybe we can find a solution to fit all scenarios, but that solution is 
bound to be extremely complex and difficult to maintain, and since 
`pulsar-admin topics stats` don't get called very often, I thought it would be 
better to keep it simple.


-- 
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