BewareMyPower opened a new pull request, #25119: URL: https://github.com/apache/pulsar/pull/25119
Fixes #25118 ### Motivation The steps of compaction phase two are: 1. Seek the compacted reader to the position of the 1st retained entry 2. Read to latest 3. Acknowledge the last compacted message id (horizon) as well as the compacted ledger's id in properties However, if broker is closing during phase two, the pending `readNextAsync` call could fail with `CancellationException`. In this case, when the managed ledger is closed, the position of the 1st retained entry will be persisted as the `__compaction` cursor's mark-delete position. As a result, during the next compaction, the horizon will be very early, and phase one will read too many entries from original ledgers. This issue could get into a bad state when the original ledgers are not deleted, typically due to improper retention policy or unexpected large backlog from another durable subscription. ### Modifications Specially for `__compaction` cursor, do not modify the mark-delete position in `internalResetCursor` (triggered by client seek API). Add `testPhaseTwoInterruption` to reproduce this issue by injecting topic close in compaction phase two. Additionally, speed up the whole `CompactionTest`. It should be noted that the original behavior also makes `testCompactorReadsCompacted` incorrect. This test sends two messages to two ledgers and compacted them. Then it sends the third message and trigger the compaction. However, it assumes the 2nd ledger will be opened. Technically, the 2nd ledger has only 1 entry that has been compacted, so it should not be opened. The entries from first two ledgers should be read directly from the compacted ledger. This test is fixed by adding another more message before creating the 3rd ledger. ### Documentation <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> - [ ] `doc` <!-- Your PR contains doc changes. --> - [ ] `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: <!-- ENTER URL HERE --> <!-- After opening this PR, the build in apache/pulsar will fail and instructions will be provided for opening a PR in the PR author's forked repository. apache/pulsar pull requests should be first tested in your own fork since the apache/pulsar CI based on GitHub Actions has constrained resources and quota. GitHub Actions provides separate quota for pull requests that are executed in a forked repository. The tests will be run in the forked repository until all PR review comments have been handled, the tests pass and the PR is approved by a reviewer. --> -- 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]
