pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

Fix metric messagesConsumedCounter calculation error

Open lordcheng10 opened this issue 3 years ago • 2 comments

Motivation

Fix metric messagesConsumedCounter calculation error. In the ManagedCursorImpl#setAcknowledgedPosition method, we will calculate skippedEntries based on newMarkDeletePosition and oldMarkDeletePosition, and then accumulate skippedEntries into MSG_CONSUMED_COUNTER_UPDATER: MSG_CONSUMED_COUNTER_UPDATER.addAndGet(this, skippedEntries); But the newMarkDeletePosition here is not the final value, newMarkDeletePosition may change between calculating skippedEntries and accumulating to MSG_CONSUMED_COUNTER_UPDATER: https://github.com/apache/pulsar/blob/bf6e815767c89512e0689562fbba0c2c453ff081/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java#L1769-L1802

Modifications

Therefore, skippedEntries should only be calculated after newMarkDeletePosition has changed: image

Documentation

  • [ ] doc-required (Your PR needs to update docs and you will update later)

  • [x] doc-not-needed (Please explain why)

  • [ ] doc (Your PR contains doc changes)

  • [ ] doc-complete (Docs have been already added)

lordcheng10 avatar Sep 20 '22 02:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 20 '22 10:09 lordcheng10

@lordcheng10 Is it possible to add an unit test?

OK

lordcheng10 avatar Sep 20 '22 12:09 lordcheng10