-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[improve][broker] Allow deletion of empty persistent topics regardless of retention policy #24733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Technoboy-
merged 2 commits into
apache:master
from
codelipenghui:improve-inactive-topic-deletion-with-retention
Sep 17, 2025
Merged
[improve][broker] Allow deletion of empty persistent topics regardless of retention policy #24733
Technoboy-
merged 2 commits into
apache:master
from
codelipenghui:improve-inactive-topic-deletion-with-retention
Sep 17, 2025
+38
−1
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…s of retention policy This change improves the inactive topic deletion behavior for persistent topics by allowing empty topics (no entries and no backlog) to be deleted even when retention policies are configured. Previously, any retention policy would prevent topic deletion, even for completely empty topics that have no data to retain. This caused metadata bloat as unused topics would accumulate. Changes: - Modified shouldTopicBeRetained() to bypass retention checks for empty topics - Added comprehensive tests to verify both deletion of empty topics and retention of topics with data - Maintains backward compatibility for topics that actually contain data This addresses the issue where persistent topics with retention policies were not being auto-deleted despite having no subscriptions, no data, and meeting all other deletion criteria. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
|
/pulsarbot run-failure-checks |
poorbarcode
approved these changes
Sep 12, 2025
15 tasks
Technoboy-
added a commit
that referenced
this pull request
Sep 18, 2025
…s of retention policy (#24733) Co-authored-by: Jiwe Guo <technoboy@apache.org>
ganesh-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Sep 18, 2025
…s of retention policy (apache#24733) Co-authored-by: Jiwe Guo <technoboy@apache.org> (cherry picked from commit 437d9f6) (cherry picked from commit 789468f)
srinath-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Sep 18, 2025
…s of retention policy (apache#24733) Co-authored-by: Jiwe Guo <technoboy@apache.org> (cherry picked from commit 437d9f6) (cherry picked from commit 789468f)
KannarFr
pushed a commit
to CleverCloud/pulsar
that referenced
this pull request
Sep 22, 2025
…s of retention policy (apache#24733) Co-authored-by: Jiwe Guo <technoboy@apache.org>
walkinggo
pushed a commit
to walkinggo/pulsar
that referenced
this pull request
Oct 8, 2025
…s of retention policy (apache#24733) Co-authored-by: Jiwe Guo <technoboy@apache.org>
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cherry-picked/branch-4.0
cherry-picked/branch-4.1
doc-not-needed
Your PR changes do not impact docs
ready-to-test
release/4.0.7
release/4.1.1
type/enhancement
The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the inactive topic deletion behavior for persistent topics by allowing empty topics (no entries and no backlog) to be deleted even when retention policies are configured.
Motivation
Previously, any retention policy would prevent topic deletion, even for completely empty topics that have no data to retain. This caused several issues:
Changes
shouldTopicBeRetained(): Added check to bypass retention policies for empty topics (getNumberOfEntries() == 0)testDeleteEmptyTopicWithRetentionPolicy(): Verifies empty topics are deleted despite retention policiestestRetainTopicWithDataAndRetentionPolicy(): Ensures topics with data still respect retention policiesBehavior Changes
Before
After
Documentation
docdoc-requireddoc-not-neededdoc-complete