You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by xy...@apache.org on 2025/06/23 09:56:35 UTC
(pulsar-client-cpp) branch branch-3.7 updated (1021d06 -> dba2752)
This is an automated email from the ASF dual-hosted git repository.
xyz pushed a change to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
from 1021d06 Fix TableView's existing key-value will never be updated (#487)
new 77de765 Fix stage-release.sh does not delete the Windows temporary directories (#488)
new 95b5e71 Avoid getLastMessageId RPC when calling hasMessageAvailable after seek by timestamp (#491)
new fb3cbd4 Fix acknowledgeCumulative never returns when accepting an invalid message id for a multi-topics consumer (#492)
new dba2752 Remove static link to libstdc++ to avoid conflicts (#493)
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
build-support/stage-release.sh | 4 ++--
lib/CMakeLists.txt | 5 -----
lib/ConsumerImpl.cc | 5 +++++
lib/MultiTopicsConsumerImpl.cc | 28 +++++++++++++++++-----------
pkg/deb/build-deb.sh | 2 +-
pkg/rpm/SPECS/pulsar-client.spec | 1 -
tests/MultiTopicsConsumerTest.cc | 39 +++++++++++++++++++++++++++++++++++++++
tests/ReaderTest.cc | 30 +++++++++++++++++++++++-------
8 files changed, 87 insertions(+), 27 deletions(-)
(pulsar-client-cpp) 03/04: Fix acknowledgeCumulative never returns when accepting an invalid message id for a multi-topics consumer (#492)
Posted by xy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
commit fb3cbd4dfab81416ca95f232af7a4f369605a7fd
Author: Yunze Xu <xy...@163.com>
AuthorDate: Wed Jun 11 05:49:18 2025 +0800
Fix acknowledgeCumulative never returns when accepting an invalid message id for a multi-topics consumer (#492)
(cherry picked from commit 9e119cee53199da5694cd59491d097399ba67a1f)
---
lib/MultiTopicsConsumerImpl.cc | 28 +++++++++++++++++-----------
tests/MultiTopicsConsumerTest.cc | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 11 deletions(-)
diff --git a/lib/MultiTopicsConsumerImpl.cc b/lib/MultiTopicsConsumerImpl.cc
index 8a43173..ff793fb 100644
--- a/lib/MultiTopicsConsumerImpl.cc
+++ b/lib/MultiTopicsConsumerImpl.cc
@@ -650,6 +650,14 @@ void MultiTopicsConsumerImpl::notifyPendingReceivedCallback(Result result, const
callback(result, msg);
}
+static void logErrorTopicNameForAcknowledge(const std::string& topic) {
+ if (topic.empty()) {
+ LOG_ERROR("MessageId without a topic name cannot be acknowledged for a multi-topics consumer");
+ } else {
+ LOG_ERROR("Message of topic: " << topic << " not in consumers");
+ }
+}
+
void MultiTopicsConsumerImpl::acknowledgeAsync(const MessageId& msgId, ResultCallback callback) {
if (state_ != Ready) {
interceptors_->onAcknowledge(Consumer(shared_from_this()), ResultAlreadyClosed, msgId);
@@ -658,19 +666,14 @@ void MultiTopicsConsumerImpl::acknowledgeAsync(const MessageId& msgId, ResultCal
}
const std::string& topicPartitionName = msgId.getTopicName();
- if (topicPartitionName.empty()) {
- LOG_ERROR("MessageId without a topic name cannot be acknowledged for a multi-topics consumer");
- callback(ResultOperationNotSupported);
- return;
- }
auto optConsumer = consumers_.find(topicPartitionName);
if (optConsumer) {
unAckedMessageTrackerPtr_->remove(msgId);
optConsumer.value()->acknowledgeAsync(msgId, callback);
} else {
- LOG_ERROR("Message of topic: " << topicPartitionName << " not in unAckedMessageTracker");
- callback(ResultUnknownError);
+ logErrorTopicNameForAcknowledge(topicPartitionName);
+ callback(ResultOperationNotSupported);
}
}
@@ -684,7 +687,7 @@ void MultiTopicsConsumerImpl::acknowledgeAsync(const MessageIdList& messageIdLis
for (const MessageId& messageId : messageIdList) {
auto topicName = messageId.getTopicName();
if (topicName.empty()) {
- LOG_ERROR("MessageId without a topic name cannot be acknowledged for a multi-topics consumer");
+ logErrorTopicNameForAcknowledge(topicName);
callback(ResultOperationNotSupported);
return;
}
@@ -710,18 +713,21 @@ void MultiTopicsConsumerImpl::acknowledgeAsync(const MessageIdList& messageIdLis
unAckedMessageTrackerPtr_->remove(kv.second);
optConsumer.value()->acknowledgeAsync(kv.second, cb);
} else {
- LOG_ERROR("Message of topic: " << kv.first << " not in consumers");
- callback(ResultUnknownError);
+ logErrorTopicNameForAcknowledge(kv.first);
+ callback(ResultOperationNotSupported);
}
}
}
void MultiTopicsConsumerImpl::acknowledgeCumulativeAsync(const MessageId& msgId, ResultCallback callback) {
- msgId.getTopicName();
+ const auto& topic = msgId.getTopicName();
auto optConsumer = consumers_.find(msgId.getTopicName());
if (optConsumer) {
unAckedMessageTrackerPtr_->removeMessagesTill(msgId);
optConsumer.value()->acknowledgeCumulativeAsync(msgId, callback);
+ } else {
+ logErrorTopicNameForAcknowledge(topic);
+ callback(ResultOperationNotSupported);
}
}
diff --git a/tests/MultiTopicsConsumerTest.cc b/tests/MultiTopicsConsumerTest.cc
index 5aae1eb..6b9f3b3 100644
--- a/tests/MultiTopicsConsumerTest.cc
+++ b/tests/MultiTopicsConsumerTest.cc
@@ -103,3 +103,42 @@ TEST(MultiTopicsConsumerTest, testSeekToNewerPosition) {
client.close();
}
+
+TEST(MultiTopicsConsumerTest, testAcknowledgeInvalidMessageId) {
+ const std::string topicPrefix = "multi-topics-consumer-ack-invalid-msg-id";
+ Client client{lookupUrl};
+ std::vector<std::string> topics(2);
+ for (size_t i = 0; i < topics.size(); i++) {
+ Producer producer;
+ auto topic = topicPrefix + unique_str();
+ ASSERT_EQ(ResultOk, client.createProducer(topic, producer));
+ ASSERT_EQ(ResultOk, producer.send(MessageBuilder().setContent("msg-" + std::to_string(i)).build()));
+ topics[i] = std::move(topic);
+ }
+
+ Consumer consumer;
+ ConsumerConfiguration conf;
+ conf.setSubscriptionInitialPosition(InitialPositionEarliest);
+ ASSERT_EQ(ResultOk, client.subscribe(topics, "sub", conf, consumer));
+
+ std::vector<MessageId> msgIds(topics.size());
+ for (size_t i = 0; i < topics.size(); i++) {
+ Message msg;
+ ASSERT_EQ(ResultOk, consumer.receive(msg, 3000));
+ std::string serialized;
+ msg.getMessageId().serialize(serialized);
+ msgIds[i] = MessageId::deserialize(serialized);
+ }
+
+ ASSERT_EQ(ResultOperationNotSupported, consumer.acknowledge(msgIds[0]));
+ ASSERT_EQ(ResultOperationNotSupported, consumer.acknowledge(msgIds));
+ ASSERT_EQ(ResultOperationNotSupported, consumer.acknowledgeCumulative(msgIds[1]));
+
+ msgIds[0].setTopicName("invalid-topic");
+ msgIds[1].setTopicName("invalid-topic");
+ ASSERT_EQ(ResultOperationNotSupported, consumer.acknowledge(msgIds[0]));
+ ASSERT_EQ(ResultOperationNotSupported, consumer.acknowledge(msgIds));
+ ASSERT_EQ(ResultOperationNotSupported, consumer.acknowledgeCumulative(msgIds[1]));
+
+ client.close();
+}
(pulsar-client-cpp) 04/04: Remove static link to libstdc++ to avoid conflicts (#493)
Posted by xy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
commit dba2752ce39d5d386e0008e64b3e0537e825fb10
Author: Yunze Xu <xy...@163.com>
AuthorDate: Mon Jun 23 17:45:20 2025 +0800
Remove static link to libstdc++ to avoid conflicts (#493)
(cherry picked from commit 639786f5ba579f7755f4220459bd613d89561617)
---
lib/CMakeLists.txt | 5 -----
pkg/deb/build-deb.sh | 2 +-
pkg/rpm/SPECS/pulsar-client.spec | 1 -
3 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 21b308c..e34555d 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -76,7 +76,6 @@ target_include_directories(PULSAR_OBJECT_LIB PUBLIC
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_BINARY_DIR}/include")
-option(LINK_STATIC_GCC_CXX "Link statically to libgcc and libstdc++" OFF)
include(CheckCXXSymbolExists)
if (BUILD_DYNAMIC_LIB)
add_library(pulsarShared SHARED $<TARGET_OBJECTS:PULSAR_OBJECT_LIB>)
@@ -94,10 +93,6 @@ if (BUILD_DYNAMIC_LIB)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_options(pulsarShared PRIVATE -Wl,-Bsymbolic)
endif ()
- check_cxx_symbol_exists(__GLIBCXX__ iostream GLIBCXX)
- if (GLIBCXX AND LINK_STATIC_GCC_CXX)
- target_link_libraries(pulsarShared PUBLIC -static-libgcc -static-libstdc++)
- endif ()
endif()
check_cxx_symbol_exists(getauxval sys/auxv.h HAVE_AUXV_GETAUXVAL)
diff --git a/pkg/deb/build-deb.sh b/pkg/deb/build-deb.sh
index 1dabb9f..8415056 100755
--- a/pkg/deb/build-deb.sh
+++ b/pkg/deb/build-deb.sh
@@ -41,7 +41,7 @@ pushd $CPP_DIR
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
chmod +x $(find . -name "*.sh")
-cmake . -DBUILD_TESTS=OFF -DBUILD_PERF_TOOLS=OFF -DLINK_STATIC=ON -DLINK_STATIC_GCC_CXX=ON
+cmake . -DBUILD_TESTS=OFF -DBUILD_PERF_TOOLS=OFF -DLINK_STATIC=ON
make -j 3
popd
diff --git a/pkg/rpm/SPECS/pulsar-client.spec b/pkg/rpm/SPECS/pulsar-client.spec
index 41a2e58..425eec5 100644
--- a/pkg/rpm/SPECS/pulsar-client.spec
+++ b/pkg/rpm/SPECS/pulsar-client.spec
@@ -55,7 +55,6 @@ static library.
%build
git clone https://github.com/microsoft/vcpkg.git
cmake -B build -DINTEGRATE_VCPKG=ON -DCMAKE_BUILD_TYPE=Release \
- -DLINK_STATIC_GCC_CXX=ON \
-DBUILD_TESTS=OFF -DBUILD_DYNAMIC_LIB=ON -DBUILD_STATIC_LIB=ON
cmake --build build -j8
./build-support/merge_archives_vcpkg.sh $PWD/build
(pulsar-client-cpp) 01/04: Fix stage-release.sh does not delete the Windows temporary directories (#488)
Posted by xy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
commit 77de76535d14a95dd4102dd178c623c7e1f59e14
Author: Yunze Xu <xy...@163.com>
AuthorDate: Tue May 6 09:17:08 2025 +0800
Fix stage-release.sh does not delete the Windows temporary directories (#488)
(cherry picked from commit 0d205096227323e37db173aa2e99a3eb76852d1b)
---
build-support/stage-release.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/build-support/stage-release.sh b/build-support/stage-release.sh
index ab0cc8f..ae2f687 100755
--- a/build-support/stage-release.sh
+++ b/build-support/stage-release.sh
@@ -40,11 +40,11 @@ build-support/generate-source-archive.sh $DEST_PATH
build-support/download-release-artifacts.py $WORKFLOW_ID $DEST_PATH
pushd "$DEST_PATH"
-if [[ -d x64-windows-static.tar.gz ]]; then
+if [[ -d x64-windows-static ]]; then
tar cvzf x64-windows-static.tar.gz x64-windows-static
rm -rf x64-windows-static/
fi
-if [[ -d x86-windows-static.tar.gz ]]; then
+if [[ -d x86-windows-static ]]; then
tar cvzf x86-windows-static.tar.gz x86-windows-static
rm -rf x86-windows-static/
fi
(pulsar-client-cpp) 02/04: Avoid getLastMessageId RPC when calling hasMessageAvailable after seek by timestamp (#491)
Posted by xy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
commit 95b5e71f72c2c7fcb4aa19e192dbf84da8053054
Author: Yunze Xu <xy...@163.com>
AuthorDate: Wed Jun 11 05:48:50 2025 +0800
Avoid getLastMessageId RPC when calling hasMessageAvailable after seek by timestamp (#491)
(cherry picked from commit 15e0b00d1115c05832f84491bd0a0f92560ee918)
---
lib/ConsumerImpl.cc | 5 +++++
tests/ReaderTest.cc | 30 +++++++++++++++++++++++-------
2 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/lib/ConsumerImpl.cc b/lib/ConsumerImpl.cc
index f429bfb..595183e 100644
--- a/lib/ConsumerImpl.cc
+++ b/lib/ConsumerImpl.cc
@@ -1561,6 +1561,10 @@ void ConsumerImpl::seekAsync(uint64_t timestamp, ResultCallback callback) {
bool ConsumerImpl::isReadCompacted() { return readCompacted_; }
void ConsumerImpl::hasMessageAvailableAsync(HasMessageAvailableCallback callback) {
+ if (!incomingMessages_.empty()) {
+ callback(ResultOk, true);
+ return;
+ }
bool compareMarkDeletePosition;
{
std::lock_guard<std::mutex> lock{mutexForMessageId_};
@@ -1726,6 +1730,7 @@ void ConsumerImpl::seekAsyncInternal(long requestId, SharedBuffer seek, const Se
hasSoughtByTimestamp_.store(true, std::memory_order_release);
} else {
seekMessageId_ = *boost::get<MessageId>(&seekArg);
+ hasSoughtByTimestamp_.store(false, std::memory_order_release);
}
seekStatus_ = SeekStatus::IN_PROGRESS;
seekCallback_ = std::move(callback);
diff --git a/tests/ReaderTest.cc b/tests/ReaderTest.cc
index ad81949..3e9dd39 100644
--- a/tests/ReaderTest.cc
+++ b/tests/ReaderTest.cc
@@ -21,7 +21,9 @@
#include <pulsar/Reader.h>
#include <time.h>
+#include <future>
#include <string>
+#include <thread>
#include "HttpHelper.h"
#include "PulsarFriend.h"
@@ -850,7 +852,7 @@ TEST_P(ReaderSeekTest, testHasMessageAvailableAfterSeekToEnd) {
ASSERT_FALSE(hasMessageAvailable);
}
-TEST_P(ReaderSeekTest, testHasMessageAvailableAfterSeekTimestamp) {
+TEST_F(ReaderSeekTest, testHasMessageAvailableAfterSeekTimestamp) {
using namespace std::chrono;
const auto topic = "test-has-message-available-after-seek-timestamp-" + std::to_string(time(nullptr));
Producer producer;
@@ -862,12 +864,10 @@ TEST_P(ReaderSeekTest, testHasMessageAvailableAfterSeekTimestamp) {
auto createReader = [this, &topic](Reader& reader, const MessageId& msgId) {
ASSERT_EQ(ResultOk, client.createReader(topic, msgId, {}, reader));
- if (GetParam()) {
- if (msgId == MessageId::earliest()) {
- EXPECT_HAS_MESSAGE_AVAILABLE(reader, true);
- } else {
- EXPECT_HAS_MESSAGE_AVAILABLE(reader, false);
- }
+ if (msgId == MessageId::earliest()) {
+ EXPECT_HAS_MESSAGE_AVAILABLE(reader, true);
+ } else {
+ EXPECT_HAS_MESSAGE_AVAILABLE(reader, false);
}
};
@@ -886,6 +886,22 @@ TEST_P(ReaderSeekTest, testHasMessageAvailableAfterSeekTimestamp) {
ASSERT_EQ(ResultOk, reader.seek(timestampBeforeSend));
EXPECT_HAS_MESSAGE_AVAILABLE(reader, true);
}
+
+ // Test `hasMessageAvailableAsync` will complete immediately if the incoming message queue is non-empty
+ Reader reader;
+ ASSERT_EQ(ResultOk, client.createReader(topic, MessageId::latest(), {}, reader));
+ reader.seek(timestampBeforeSend);
+ std::promise<std::thread::id> threadIdPromise;
+
+ waitUntil(seconds(3),
+ [&reader] { return PulsarFriend::getConsumer(reader)->getNumOfPrefetchedMessages() > 0; });
+ reader.hasMessageAvailableAsync([&threadIdPromise](Result result, bool hasMessageAvailable) {
+ ASSERT_EQ(ResultOk, result);
+ ASSERT_TRUE(hasMessageAvailable);
+ threadIdPromise.set_value(std::this_thread::get_id());
+ });
+ auto threadId = threadIdPromise.get_future().get();
+ ASSERT_EQ(threadId, std::this_thread::get_id());
}
TEST_F(ReaderSeekTest, testSeekInclusiveChunkMessage) {