BewareMyPower commented on code in PR #23462: URL: https://github.com/apache/pulsar/pull/23462#discussion_r1825354846
########## pip/pip-387.md: ########## @@ -0,0 +1,94 @@ +# PIP-387: Modify interface TopicCompactionService to support cancelling an in-progress compaction task + +# Background knowledge + +- What is Topic Compaction: https://pulsar.apache.org/docs/3.3.x/cookbooks-compaction +- How it works: it reads messages from the target topic, and compacts them into a single ledger, which will be stored with cursor's properties. + +# Motivation + +- There is a bug that may lead a deadlock when deleting topic and topic compaction execute at the same time. + +| time | `deleting topic` | `compaction` | +| --- | --- | ---| +| 1 | | start to create the internal reader | +| 2 | mark the topic is deleting, and the deleting has not finished yet | | +| 3 | disconnect all client, which includes the internal reader for compaction| | +| 4 | | loop to reconnect | +| 5 | waiting for in-progress compaction, to delete the ledger that contains compacted messages | | +| 6 | keep waiting... | keeping reconecting | + +- And, there is another situation which is weird when unloading topic and compaction execute at the same time, and the result of this scenario is okay, because the fist compaction task will eventually succeed. + +| time | `broker-1` | `broker-2` | +| --- | --- | ---| +| 1 | starts compaction | | +| 2 | unload topic due to a load-balance | +| 3 | close the topic | +| 4 | the compaction is still running | +| 5 | | load up the topic | +| 6 | | starts compaction | +| 7 | | receive an error: "Exclusive consumer is already connected"| + +# Goals + +Modify interface `TopicCompactionService` to support cancelling an in-progress compaction task + +# API changes + +**TopicCompactionService.java** +```java +- CompletableFuture<Void> compact(); ++ CompactionTaskCtx compact(); +``` + +**CompactionTaskCtx.java** Review Comment: This class exposes too many details. Why not just add a `cancel()` to the `TopicCompactionService`? -- 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]
