-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[C++] Fix Consumer send redeliverMessages repeatedly #9072
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
Conversation
|
@BewareMyPower Please help review this PR. |
BewareMyPower
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test like #4595 did?
|
@BewareMyPower Is it necessary to reset the batchIndex of pulsar/pulsar-client-cpp/lib/ConsumerImpl.cc Lines 808 to 817 in b09c0d7
But the param pulsar/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.cc Lines 93 to 102 in b09c0d7
|
|
@saosir Yeah, your concern is right. |
|
@BewareMyPower Can you review this PR again? |
|
@BewareMyPower Test cases have been added, and the test cases use gtest to access private member variables. I don’t know if this is appropriate. Help review it, thanks! |
|
@saosir It's not a problem to access private members in tests. I'll take a look. |
|
I will submit another pr to deal with this problem later. |
BewareMyPower
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code itself looks good to me. However, introducing FRIEND_TEST to code under lib/ is not a good way.
Currently, users could define -DBUILD_TESTS=OFF in the CMake build phase to skip tests and build libraries only. However, after changes of this PR, the build will fail because it added an extra dependency (GTest) to lib/ subdirectory.
I think you can find an alternative way of FRIEND_TEST or use a conditional macro to hide the gtest codes under lib/. Though you can also just add the GTest dependency in CMakeLists.txt, it's not recommended because the source code without tests should not depend on GTest.
How about add Gtest header |
Yeah, it's a simple and good solution. |
|
@BewareMyPower I have a question. Why default router policy of
but in pulsar-client-java is pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerBuilderImpl.java Lines 317 to 319 in afe6af2
|
|
@saosir I'm also not sure why it's the default routing mode. It could make pulsar beginners confused like I've experienced before. But considering the change of default behavior may affect existed applications, I'd like to keep it as default. |
CI will check license header, but
|
|
@saosir You can add this file to <plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>${license-maven-plugin.version}</version>
<configuration>
<licenseSets>
<licenseSet>
<header>${pulsar.basedir}/src/license-header.txt</header>
<excludes>
<!-- TODO: add it here --> |
|
why pulsar/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.cc Lines 84 to 88 in afe6af2
|
I think It's just a mistake. I guess the original author intended to do: int blankPartitions = (timeoutMs_ / tickDurationInMs_) + ((timeoutMs_ % tickDurationInMs_ == 0) ? 0 : 1);
for (int i = 0; i < blankPartitions; i++) { |
|
Agree with you, java-client has same problem: pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/UnAckedMessageTracker.java Lines 116 to 119 in afe6af2
|
|
/pulsarbot run-failure-checks |
|
/pulsarbot run-failure-checks |
Fixes #9028 Both PartitionedConsumerImpl and ConsumerImpl have member variable unAckedMessageTrackerPtr_ (class UnAckedMessageTrackerEnabled), and PartitionedConsumerImpl is composed of ConsumerImpl. If the acknowledgement times out, they will send redeliverMessages repeatedly, MultiTopicsConsumerImpl has same problem. - add `hasParent_` field to whether there is a parent in ConsumerImpl - add unit test verify the redelivery request won't be sent repeatedly - add GTest header `gtest/gtest_prod.h` to access private members in unit tests - fix typo (cherry picked from commit 9894b99)
--- **Motivation** PR apache#9072 introduces the gtest file but does not exclude for apache-rat check. So that causes the apache-rat check to fail.
* Fix the apache-rat check --- **Motivation** PR #9072 introduces the gtest file but does not exclude for apache-rat check. So that causes the apache-rat check to fail. * Move the test to the another file * Address comments
* Fix the apache-rat check --- **Motivation** PR apache#9072 introduces the gtest file but does not exclude for apache-rat check. So that causes the apache-rat check to fail. * Move the test to the another file * Address comments
* Fix the apache-rat check --- **Motivation** PR apache#9072 introduces the gtest file but does not exclude for apache-rat check. So that causes the apache-rat check to fail. * Move the test to the another file * Address comments (cherry picked from commit 0d5f070) (cherry picked from commit c568834)
Fixes #9028
Motivation
Both PartitionedConsumerImpl and ConsumerImpl have member variable unAckedMessageTrackerPtr_ (class UnAckedMessageTrackerEnabled), and PartitionedConsumerImpl is composed of ConsumerImpl. If the acknowledgement times out, they will send redeliverMessages repeatedly, MultiTopicsConsumerImpl has same problem.
Modifications
hasParent_field to whether there is a parent in ConsumerImplgtest/gtest_prod.hto access private members in unit testsDoes this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation