sometimes msgbacklog size is not correct when restart
- Dominant language
- Java
- Stars
- 15.3k
- Forks
- 3.8k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 160
Description
**Describe the bug**
we restart a broker, then one topic in the broker msgbacklog is wrong
**Expected behavior**
**Screenshots**
If applicable, add screenshots to help explain your problem.

```
"cursors" : {
"C_tort_url_patrol_formal" : {
"markDeletePosition" : "13438589:33134",
"readPosition" : "13487114:46889",
"waitingReadOp" : false,
"pendingReadOps" : 0,
"messagesConsumedCounter" : -9139902,
"cursorLedger" : 13685682,
"cursorLedgerLastEntry" : 12009,
"individuallyDeletedMessages" : "[(13438589:33135..13438589:49999],(13439440:-1..13439440:13991],(13439440:13992..13439440:14059],(13439440:14060..13439440:14093],(13439440:14094..13439440:14233],(13439440:14234..13439440:49999],(13440145:-1..13440145:18170],(13440145:18171..13440145:18221],(13440145:18222..13440145:18340],(13440145:18341..13440145:19341],(13440145:19342..13440145:19346],(13440145:19349..13440145:19351],(13440145:19352..13440145:19353],(13440145:19354..13440145:19355],(13440145:19357..13440145:19360],(13440145:19368..13440145:19370],(13440145:19373..13440145:19377],(13440145:19378..13440145:19379],(13440145:19381..13440145:19387],(13440145:19388..13440145:19389],(13440145:19393..13440145:19396],(13440145:19397..13440145:19398],(13440145:19407..13440145:19409],(13440145:19410..13440145:19412],(13440145:19
```
as we can see messagesConsumedCounter is negative number.
then we unload the topic , expect this will recover, but messagesConsumedCounter maybe more small

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
**Additional context**
Add any other context about the problem here.
Contributor guide
Research direction
Start by reproducing the broker restart scenario for a topic and inspect the reported msgbacklog and cursor state, especially messagesConsumedCounter. Compare the values before and after restarting and unloading the topic. Done means the backlog and consumed counter remain correct rather than becoming negative or decreasing further.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100