-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[fix][client] Fix RawReader hasMessageAvailable returns true when no messages #21032
Conversation
Codecov Report
@@ Coverage Diff @@
## master #21032 +/- ##
=============================================
+ Coverage 33.56% 73.11% +39.54%
- Complexity 12198 32262 +20064
=============================================
Files 1621 1875 +254
Lines 126970 139505 +12535
Branches 13857 15344 +1487
=============================================
+ Hits 42618 101999 +59381
+ Misses 78748 29436 -49312
- Partials 5604 8070 +2466
Flags with carried forward coverage won't be shown. Click here to find out more.
|
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/MultiTopicsReaderTest.java
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/NegativeAcksTest.java
Show resolved
Hide resolved
Set<String> keys = publishMessages(topic, numKeys, true); | ||
RawReader reader = RawReader.create(pulsarClient, topic, subscription).get(); | ||
int messageCount = 0; | ||
while (true) { | ||
boolean hasMsg = reader.hasMessageAvailableAsync().get(); | ||
if (hasMsg && (messageCount == numKeys)) { |
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.
Why remove the original checks? It changes the original testing purpose, no?
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.
It may be blocked at the readNextAsync
without any information until the test timeout.
@Technoboy- Can you help create a PR to cherry-pick this change to |
Motivation
Related #16443
When runs testHasMessageAvailableWithBatch, there is a race condition between
test-thread
andpulsar-client-internal-thread
test-thread
pulsar-client-internal-4082-1
3:0:-1:0
to3:0:-1:9
lastDequeuedMessageId: 3:0:-1:9
3:1:-1:0
to3:1:-1:9
lastDequeuedMessageId: 3:0:-1:9
lastDequeuedMessageId: 3:1:-1:9
So we should update
lastDequeuedMessageId
beforefuture.complete
:pulsar/pulsar-broker/src/main/java/org/apache/pulsar/client/impl/RawReaderImpl.java
Lines 154 to 161 in d06cda6
Add related codes and logs:
This also fix #20998
Documentation
doc
doc-required
doc-not-needed
doc-complete