You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "zhaizhibo (via GitHub)" <gi...@apache.org> on 2026/02/16 10:41:02 UTC
[PR] feat: support write tombstone to a compactTopic. [pulsar]
zhaizhibo opened a new pull request, #25248:
URL: https://github.com/apache/pulsar/pull/25248
### Motivation
Currently, Pulsar's topic compaction process retains all keys, including those with null values. This creates a limitation where deleted keys (tombstones) are never removed from compacted ledgers, causing them to grow indefinitely over time. This behavior consumes unnecessary storage and impacts system performance for long-running topics with frequent key deletions.
### Modifications
Added a new optional broker configuration `topicCompactionRetainNullValue` to control whether null values should be retained during compaction.
**Default behavior**: `true` (retain null values) - maintains backward compatibility
**New option**: When set to `false`, keys with null values (tombstones) will be removed during compaction
**Backward compatibility**: If the configuration is not set, the system defaults to the original behavior (retain null values)
<!-- Describe the modifications you've done. -->
### Verifying this change
### Does this pull request potentially affect one of the following parts:
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
*If the box was checked, please highlight the changes*
- [ ] Dependencies (add or upgrade a dependency)
- [ ] The public API
- [ ] The schema
- [ ] The default values of configurations
- [ ] The threading model
- [ ] The binary protocol
- [ ] The REST endpoints
- [ ] The admin CLI options
- [ ] The metrics
- [ ] Anything that affects deployment
### 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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: support write tombstone to a compactTopic. [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #25248:
URL: https://github.com/apache/pulsar/pull/25248#discussion_r2812386849
##########
pulsar-broker/src/test/java/org/apache/pulsar/compaction/CompactionTest.java:
##########
@@ -748,6 +748,61 @@ public void testKeyLessMessagesPassThrough(boolean retainNullKey) throws Excepti
}
}
+ @Test(timeOut = 30000)
+ public void testNotToRetainNullValue() throws Exception {
+ conf.setTopicCompactionRetainNullValue(false);
+ conf.setTopicCompactionRetainNullKey(true);
+ restartBroker();
+ FieldUtils.writeField(compactor, "topicCompactionRetainNullValue", false, true);
+ FieldUtils.writeField(compactor, "topicCompactionRetainNullKey", true, true);
Review Comment:
It would be better to override `restartBroker` in this class so that it reinitializes `compactor` so that there wouldn't be a need to set the fields directly.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: support write tombstone to a compactTopic. [pulsar]
Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat commented on PR #25248:
URL: https://github.com/apache/pulsar/pull/25248#issuecomment-6182175381
Hi @zhaizhibo, thanks for the contribution. As pointed out in the review, compaction already treats a message with an empty payload as a deletion: on current master both compactMessage and compactBatchMessage in PublishingOrderCompactor remove the key from the compacted view. The review asked for a test case that reproduces the problem you were seeing. We're going through the backlog of open PRs (https://lists.apache.org/thread/cgy7w0qgnq8s7j0ykyzgrn3hj4nb67wf), so I'm closing this one. If you have a reproducer, feel free to reopen it with that test, or open an issue with the details.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: support write tombstone to a compactTopic. [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on PR #25248:
URL: https://github.com/apache/pulsar/pull/25248#issuecomment-3908523117
I looked into the change history and it looks like there used to be a related bug which was fixed a long time with #18877.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: support write tombstone to a compactTopic. [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on PR #25248:
URL: https://github.com/apache/pulsar/pull/25248#issuecomment-3908539755
There's also #24523 since Pulsar 4.1.0, implementing [PIP-429: Optimize Handling of Compacted Last Entry by Skipping Payload Buffer Parsing](https://github.com/apache/pulsar/blob/master/pip/pip-429.md)
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: support write tombstone to a compactTopic. [pulsar]
Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat closed pull request #25248: feat: support write tombstone to a compactTopic.
URL: https://github.com/apache/pulsar/pull/25248
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org