vinkal-chudgar commented on PR #24965:
URL: https://github.com/apache/pulsar/pull/24965#issuecomment-3515428703

   > Why could take the method params into account ? There will be more request 
to the broker, but the result is the same.
   
   
   @Technoboy- The reason we must include these parameters in the key is that 
they can lead to fundamentally different outcomes for the caller, breaking the 
API contract if not handled separately. The logic within 
`getPartitionedTopicMetadataAsync` demonstrates this.
   
   ```
   if (!metadataAutoCreationEnabled && 
!clientCnx.isSupportsGetPartitionedMetadataWithoutAutoCreation()) {
       if (useFallbackForNonPIP344Brokers) {
           // Fall back to old behavior
           finalAutoCreationEnabled = true;
       } else {
           // This path fails immediately
           partitionFuture.completeExceptionally(new 
PulsarClientException.FeatureNotSupportedException(...));
           return;
       }
   }
   // This path sends a request to the broker
   ByteBuf request = Commands.newPartitionMetadataRequest(topicName.toString(), 
requestId, finalAutoCreationEnabled);
   ```
   
   Here is a practical example of why caching them separately is critical, as 
two calls with the same `TopicName` but different parameters can produce 
completely different results:
   
   - **When the broker does not support PIP-344**, the outcome depends entirely 
on the `useFallbackForNonPIP344Brokers` flag:
       *   One call might fail immediately with a 
`FeatureNotSupportedException`.
       *   Another might fall back to the old behavior and succeed.
   
       If we only deduped by `TopicName`, a caller that expects a failure could 
incorrectly receive a successful result from the other caller. **This breaks 
the method contract for that caller.**
   
   - **Even when the broker supports PIP-344**, the 
`metadataAutoCreationEnabled` flag changes the request sent. Coalescing 
requests with different values for this flag hides the caller’s chosen behavior 
and side effects (like topic auto-creation).
   
   Regarding your point about increasing request volume: this change still 
correctly deduplicates all concurrent calls that use the exact same parameters. 
A new request is only sent when the parameters are different, ensuring we 
respect the caller's intent while still preventing redundant traffic for 
identical calls.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to