poorbarcode opened a new pull request, #17380: URL: https://github.com/apache/pulsar/pull/17380
### Motivation  <strong>(High light)</strong> The `reader` created later than calling `triggerCompaction`. Before the reader creates, the task “Clear the ledger that has been consumed” maybe already executed asynchronously. https://github.com/apache/pulsar/blob/d4beae72d608bafaebe7ac1cff0a258238e84f10/pulsar-broker/src/test/java/org/apache/pulsar/compaction/CompactedTopicTest.java#L754-L778 The error execution flow is as follows: producer: - send 1000 messages ( ledger-1 ) - unload the topic. - send 1000 messages (ledger-2) reader: - read 500 messages - auto acknowledgment - calculate the next read position: - `getNextValidPosition(position)` At this time the ledger-1 has been deleted, so `getNextValidPosition(position)` will return `(originalLedger+1:0)` - read `(ledger-2:0)`, then error occur ### Modifications - Create a consumer to generate a durable cursor, to avoid deleting the ledger before the reader receives. - Make the reader creates before calling `triggerCompaction` ### Documentation - [ ] `doc-required` - [x] `doc-not-needed` - [ ] `doc` - [ ] `doc-complete` -- 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]
