Skip to content
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

[improve][broker] Add an option to return 0 when querying partitions of a nonexistent topic #18594

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BewareMyPower
Copy link
Contributor

Motivation

#10601 (comment)

#10601 changes the behavior when querying partitions of a topic that is not created. Before #10601, 0 is returned. After #10601, an exception will be thrown to indicate the topic does not exist. It leads to the incompatibility with some old Pulsar clients that do not add the "checkAllowAutoCreation=true" query param. If they use HTTP service URL like "http://localhost:8080", when accessing a topic that does not exist, the client will fail.

The affected Pulsar clients include Java client <= 2.4.2 and C++/Python client <= 2.8.0.

Modifications

Add an option checkTopicExistsWhenQueryPartitions (default: true) to determine the behavior. Disable this option to keep the original behavior that 0 will be returned when querying partitions of a nonexistent topic.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added HttpPartitionMetadataLookupTest to show the behavior when checkTopicExistsWhenQueryPartitions is true or false.

Documentation

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

Matching PR in forked repository

PR in forked repository: BewareMyPower#10

…of a nonexistent topic

### Motivation

apache#10601 (comment)

apache#10601 changes the behavior when querying partitions of a topic that is
not created. Before apache#10601, 0 is returned. After apache#10601, an exception
will be thrown to indicate the topic does not exist. It leads to the
incompatibility with some old Pulsar clients that do not add the
"checkAllowAutoCreation=true" query param. If they use HTTP service URL
like "http://localhost:8080", when accessing a topic that does not
exist, the client will fail.

The affected Pulsar clients include Java client <= 2.4.2 and C++/Python
client <= 2.8.0.

### Modifications

Add an option `checkTopicExistsWhenQueryPartitions` (default: true) to
determine the behavior. Disable this option to keep the original
behavior that 0 will be returned when querying partitions of a
nonexistent topic.
@BewareMyPower BewareMyPower added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Nov 24, 2022
@BewareMyPower BewareMyPower self-assigned this Nov 24, 2022
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Nov 24, 2022
@BewareMyPower
Copy link
Contributor Author

This PR also fixes the incompatibility issue of allowAutoTopicCreationType. Adding the following configs to run a standalone of 2.7.5.

allowAutoTopicCreationType=partitioned
defaultNumPartitions=4

Then producing a message to a topic named "my-topic", you can see the created topic is still non-partitioned.

$ ./bin/pulsar-admin topics list public/default
"persistent://public/default/my-topic"

However, with the standalone that includes this patch.

checkTopicExistsWhenQueryPartitions=false
allowAutoTopicCreationType=partitioned
defaultNumPartitions=4

The created topic is a partitioned topic:

$ ./bin/pulsar-admin topics list public/default
"persistent://public/default/my-topic-partition-0"
"persistent://public/default/my-topic-partition-3"
"persistent://public/default/my-topic-partition-1"
"persistent://public/default/my-topic-partition-2"

@eolivelli
Copy link
Contributor

@rdhabalia PTAL

@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions bot added the Stale label Dec 25, 2022
@Technoboy- Technoboy- added this to the 3.2.0 milestone Jul 31, 2023
@Technoboy- Technoboy- modified the milestones: 3.2.0, 3.3.0 Dec 22, 2023
@coderzc coderzc modified the milestones: 3.3.0, 3.4.0 May 8, 2024
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 Stale type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants