Skip to content

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
@lhotari lhotari modified the milestones: 4.0.0, 4.1.0 Oct 14, 2024
@coderzc coderzc modified the milestones: 4.1.0, 4.2.0 Sep 1, 2025
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.

5 participants