Skip to content

Conversation

@BewareMyPower
Copy link
Contributor

Motivation

See https://lists.apache.org/thread/tpd2kgl4v3x8bkw0skv0nj38rzrk56t7

Modifications

Set the 3rd argument of getPartitionedTopicMetadata to true in PulsarClientImpl#getPartitionsForTopic, which is used to query the number of partitions.

Add testAutoPartitionsUpdate to cover the case. Specially, it tests a consumer that subscribes two partitioned topics to cover the path here:

.map(t -> subscribeAsync(t, createTopicIfDoesNotExist))

P.S. This test is only added to ClientTest25, which runs tests against apachepulsar/pulsar:2.5.0 image. The current backward compatibility test strategy is ambiguous that only 2.2.0, 2.3.0, 2.4.0, 2.5.0 are tested. It's hard to cover all old versions, but only choose these 4 versions does not make sense. This topic should be out of the scope of this PR. Anyway, the test on 2.5.0 can already prevent regression on the fix.

Documentation

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

Matching PR in forked repository

PR in forked repository:

@BewareMyPower BewareMyPower self-assigned this Oct 4, 2025
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Oct 4, 2025
Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for addressing this

@lhotari lhotari added this to the 4.2.0 milestone Oct 7, 2025
@lhotari
Copy link
Member

lhotari commented Oct 7, 2025

There seems to be a test that explicitly tests for the behavior that connecting to an older broker fails:

  Error:  Tests run: 6, Failures: 1, Errors: 0, Skipped: 1, Time elapsed: 32.05 s <<< FAILURE! -- in org.apache.pulsar.client.impl.ClientCnxTest
  Error:  org.apache.pulsar.client.impl.ClientCnxTest.testSupportsGetPartitionedMetadataWithoutAutoCreation -- Time elapsed: 0.255 s <<< FAILURE!
  java.lang.AssertionError: Expected an error that the broker version is too old.
  	at org.testng.Assert.fail(Assert.java:110)
  	at org.apache.pulsar.client.impl.ClientCnxTest.testSupportsGetPartitionedMetadataWithoutAutoCreation(ClientCnxTest.java:264)
  	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
  	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
  	at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
  	at org.testng.internal.invokers.InvokeMethodRunnable.runOne(InvokeMethodRunnable.java:47)
  	at org.testng.internal.invokers.InvokeMethodRunnable.call(InvokeMethodRunnable.java:76)
  	at org.testng.internal.invokers.InvokeMethodRunnable.call(InvokeMethodRunnable.java:11)
  	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
  	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
  	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
  	at java.base/java.lang.Thread.run(Thread.java:1583)

This test was added in #22773 and it seems to test what is defined in PIP-344 Backward and Forward compatibility:

  • New version client and Old version Broker: The feature flag supports_binary_api_get_partitioned_meta_with_param_created_false will be false. The client will get a not-support error if the param createIfAutoCreationEnabled is false.

@poorbarcode would it be possible to explain the reason why the client should fail in this case?

@BewareMyPower
Copy link
Contributor Author

I think it has been explained in #23136. I updated the test and the PIP document now.

@github-actions github-actions bot added the PIP label Oct 8, 2025
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.29%. Comparing base (008e4eb) to head (6086925).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24822      +/-   ##
============================================
- Coverage     74.42%   74.29%   -0.13%     
- Complexity    33488    33801     +313     
============================================
  Files          1912     1912              
  Lines        149077   149089      +12     
  Branches      17300    17300              
============================================
- Hits         110950   110769     -181     
- Misses        29331    29482     +151     
- Partials       8796     8838      +42     
Flag Coverage Δ
inttests 26.38% <0.00%> (-0.33%) ⬇️
systests 22.71% <0.00%> (-0.18%) ⬇️
unittests 73.83% <100.00%> (-0.11%) ⬇️

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

Files with missing lines Coverage Δ
...rg/apache/pulsar/client/impl/PulsarClientImpl.java 76.11% <100.00%> (ø)

... and 91 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.

@lhotari lhotari merged commit 5e59d0e into apache:master Oct 8, 2025
52 checks passed
lhotari pushed a commit that referenced this pull request Oct 8, 2025
lhotari pushed a commit that referenced this pull request Oct 8, 2025
lhotari pushed a commit that referenced this pull request Oct 8, 2025
lhotari pushed a commit that referenced this pull request Oct 8, 2025
@BewareMyPower BewareMyPower deleted the bewaremypower/fix-pip-344-compatibility branch October 8, 2025 11:02
walkinggo pushed a commit to walkinggo/pulsar that referenced this pull request Oct 8, 2025
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Oct 15, 2025
…t PIP-344 (apache#24822)

(cherry picked from commit 5e59d0e)
(cherry picked from commit 708feff)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Oct 15, 2025
…t PIP-344 (apache#24822)

(cherry picked from commit 5e59d0e)
(cherry picked from commit 6da23ff)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Oct 30, 2025
…t PIP-344 (apache#24822)

(cherry picked from commit 5e59d0e)
(cherry picked from commit 708feff)
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Oct 30, 2025
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 6, 2025
…t PIP-344 (apache#24822)

(cherry picked from commit 5e59d0e)
(cherry picked from commit 6da23ff)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants