+1 for the motivation We should not create partitioned topics when calling `pulsarClient.getPartitionsForTopic`
The tricky part is the broker doesn't know if the partition metadata getting request is from create produce/consumer or just from pulsarClient.getPartitionsForTopic(topicName). We can follow the same way that Admin API does to have a field `createIfAutoCreationEnabled` in the `CommandPartitionedTopicMetadata` The producer/consumer will set this flag to true to create partitioned topics if topic auto-creation is enabled. We will use false as the default value. Regards, Penghui On Thu, Feb 29, 2024 at 11:05 AM Yubiao Feng <yubiao.f...@streamnative.io.invalid> wrote: > Hi all > > ### Background > - When calling `pulsarClient.getPartitionsForTopic(topicName)`, Pulsar will > automatically create the partitioned topic metadata if it does not exist, > either using `HttpLookupService` or `BinaryProtoLookupService`. > - The partitioned topic auto-creation is dependent on > `pulsarClient.getPartitionsForTopic` > - It triggers partitioned metadata creation by > `pulsarClient.getPartitionsForTopic` > - And triggers the topic partition creation by producers' registration > and consumers' registration. > > ### Issue > Since the method `pulsarClient.getPartitionsForTopic` is a public API, and > it is named `getxxx,` it should edit nothing. > > ### Solution > - Solution-1: remove the public API `pulsarClient.getPartitionsForTopic` > and only use it internally. > - Solution-2: provide an internal API to trigger partitioned metadata > creation and make the public API `pulsarClient.getPartitionsForTopic` edit > nothing. > - Solution-3: redesign the flow of partitioned topic auto-creation. > > I would like to recommend solution 2, and hope to hear more voices. > > Thanks > Yubiao Feng >