-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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: ack timeout in pulsar cpp client when subscribing to regex topic #3879
fix: ack timeout in pulsar cpp client when subscribing to regex topic #3879
Conversation
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.
LGTM. Can you add a test case for this regex topic and ack timeout?
@merlimat i have added a test |
@@ -2940,3 +2940,50 @@ TEST(BasicEndToEndTest, testPreventDupConsumersAllowSameSubForDifferentTopics) { | |||
// consumer C should be a different instance from A and B and should be with open state. | |||
ASSERT_EQ(ResultOk, consumerC.close()); | |||
} | |||
|
|||
static long regexTestMessagesReceived = 0; |
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.
This gets updated from one thread and read from another. We should use std::atomic<long>
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.
I can but does it really matter since its only one writer? Also we doing the same thing in a couple places:
https://github.com/apache/pulsar/blob/master/pulsar-client-cpp/tests/BasicEndToEndTest.cc#L47
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.
Yes, the number will be correct because of the single writer, but the reader is technically not guaranteed to see the latest value. Though, yes, with sleep and retries it would settle anyway.
if (regexTestMessagesReceived >= 10 * 2) { | ||
break; | ||
} | ||
usleep(500000); |
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.
unistd.h
is only posix specific. std::this_thread::sleep
is the preferred c++ 11 way to sleep
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.
ok will update
rerun java8 tests |
rerun java8 tests |
rerun java8 tests |
rerun java8 tests |
Motivation
When subscribing to a regex in cpp/python client and using a message listener, ack timeout does work and unacked messages are not delivered.
This is because the unack message tracker is not call in one place