Skip to content

Conversation

@nodece
Copy link
Member

@nodece nodece commented Mar 25, 2025

Motivation

In Apache Pulsar, clients can produce or consume messages using a fully qualified partition topic name (public/default/test-partitioned-topic-partition-N). However, if the topic metadata does not exist and allowAutoTopicCreationType=non-partitioned is enabled, Pulsar automatically creates the topic as non-partitioned. This leads to inconsistencies when listing topics, as the expected partitioned topic structure is not maintained.

This issue is especially prevalent in geo-replicated environments, where topic metadata may not be fully synchronized across all regions. Currently, Pulsar lacks validation to ensure that the topic type (partitioned or non-partitioned) matches the actual partition metadata.

Modifications

  • Added a topic consistency check:
    • For non-partitioned topic: If partition metadata exists (which shouldn't be there), the broker will reject message produce and consume operations.
    • For partitioned topic: If partition metadata is missing (which should be there), the broker will reject message produce and consume operations.
  • Fixed affected tests to align with the new validation logic.
  • Added testGetPartitionedTopicMetadataByPulsarClient and testGetPartitionedTopicMedataByAdmin instead of testCompatibilityWithPartitionKeyword because the broker rejects message produce and consume operations when no metadata. Note: we still allow user lookup topic name with -partition- but no metadata: [fix][broker] Allow user lookup topic name with -partition- but no metadata #19171.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Mar 25, 2025
@nodece nodece self-assigned this Mar 25, 2025
@nodece nodece force-pushed the add-topic-consistency-check-master branch from 7426799 to 40fb779 Compare March 25, 2025 05:10
@nodece nodece closed this Mar 25, 2025
@nodece nodece force-pushed the add-topic-consistency-check-master branch from 40fb779 to d7962a1 Compare March 25, 2025 07:11
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
@nodece nodece reopened this Mar 25, 2025
nodece added 3 commits March 25, 2025 17:19
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
@nodece nodece added this to the 4.1.0 milestone Mar 25, 2025
nodece added 9 commits March 25, 2025 20:38
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
…umerWhenSinglePartitionIsDeleted

Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
@nodece nodece force-pushed the add-topic-consistency-check-master branch from 88ab8db to 4b3a6ab Compare March 25, 2025 16:20
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Mar 26, 2025

Codecov Report

Attention: Patch coverage is 98.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.27%. Comparing base (bbc6224) to head (cb09e93).
Report is 993 commits behind head on master.

Files with missing lines Patch % Lines
...rg/apache/pulsar/broker/service/BrokerService.java 96.96% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24118      +/-   ##
============================================
+ Coverage     73.57%   74.27%   +0.70%     
+ Complexity    32624    32117     -507     
============================================
  Files          1877     1864      -13     
  Lines        139502   144437    +4935     
  Branches      15299    16473    +1174     
============================================
+ Hits         102638   107286    +4648     
+ Misses        28908    28702     -206     
- Partials       7956     8449     +493     
Flag Coverage Δ
inttests 26.93% <68.00%> (+2.34%) ⬆️
systests 23.16% <28.00%> (-1.17%) ⬇️
unittests 73.78% <98.00%> (+0.93%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ache/pulsar/broker/namespace/NamespaceService.java 73.61% <100.00%> (+1.38%) ⬆️
...pache/pulsar/client/api/PulsarClientException.java 61.63% <100.00%> (-1.41%) ⬇️
...rg/apache/pulsar/broker/service/BrokerService.java 84.26% <96.96%> (+3.48%) ⬆️

... and 1060 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodece nodece requested a review from lhotari March 26, 2025 02:11
@lhotari
Copy link
Member

lhotari commented Apr 23, 2025

Reverted from branch-3.0, branch-3.3 and branch-4.0 as per this dev mailing list message.

ganesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 24, 2025
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
(cherry picked from commit 7f0429c)
(cherry picked from commit 7671275)
ganesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 24, 2025
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
(cherry picked from commit 7f0429c)
(cherry picked from commit 7671275)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 25, 2025
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
(cherry picked from commit 7f0429c)
(cherry picked from commit 7671275)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 25, 2025
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
(cherry picked from commit 7f0429c)
(cherry picked from commit 7671275)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 27, 2025
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
(cherry picked from commit 7f0429c)
(cherry picked from commit 7671275)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 27, 2025
ganesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 30, 2025
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
(cherry picked from commit 7f0429c)
(cherry picked from commit 7671275)
ganesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 30, 2025
ganesh-ctds pushed a commit to datastax/pulsar that referenced this pull request May 1, 2025
ganesh-ctds pushed a commit to datastax/pulsar that referenced this pull request May 1, 2025
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request May 2, 2025
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
(cherry picked from commit 7f0429c)
(cherry picked from commit 7671275)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request May 2, 2025
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request May 2, 2025
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
(cherry picked from commit 7f0429c)
(cherry picked from commit ed64bf9)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request May 2, 2025
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request May 6, 2025
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
(cherry picked from commit 7f0429c)
(cherry picked from commit ed64bf9)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request May 6, 2025
nborisov pushed a commit to nborisov/pulsar that referenced this pull request Sep 12, 2025
walkinggo pushed a commit to walkinggo/pulsar that referenced this pull request Oct 8, 2025
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants