You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by zh...@apache.org on 2020/10/16 12:56:44 UTC
[pulsar] branch branch-2.6 updated (3e65a6c -> 3b8ce21)
This is an automated email from the ASF dual-hosted git repository.
zhaijia pushed a change to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/pulsar.git.
from 3e65a6c Replace com.ning.asynchttpclient with org.asynchttpclient (#8099)
new 9d02404 [issue 7851][C++] Make clear() thread-safe (#7862)
new 3b8ce21 Set dryrun of KubernetesRuntime is null (#8064)
The 2 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:
pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc | 1 +
pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.cc | 6 +++++-
pulsar-client-cpp/tests/BasicEndToEndTest.cc | 2 ++
.../pulsar/functions/runtime/kubernetes/KubernetesRuntime.java | 8 ++++----
4 files changed, 12 insertions(+), 5 deletions(-)
[pulsar] 01/02: [issue 7851][C++] Make clear() thread-safe (#7862)
Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
zhaijia pushed a commit to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 9d024040499805a0536d745b2f9ddce3da9ca983
Author: Yunze Xu <xy...@163.com>
AuthorDate: Mon Aug 24 07:39:32 2020 +0800
[issue 7851][C++] Make clear() thread-safe (#7862)
Fixes #7851
### Motivation
`clear()` methods of `BatchAcknowledgementTracker` and `UnAckedMessageTrackerEnabled` are not thread-safe.
### Modifications
Acquire a mutex in these `clear()` methods.
(cherry picked from commit 97f41120b9691474f0038b220f3204fa69e48257)
---
pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc | 1 +
pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.cc | 6 +++++-
pulsar-client-cpp/tests/BasicEndToEndTest.cc | 2 ++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc b/pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc
index df15119..3d6d920 100644
--- a/pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc
+++ b/pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc
@@ -33,6 +33,7 @@ BatchAcknowledgementTracker::BatchAcknowledgementTracker(const std::string topic
}
void BatchAcknowledgementTracker::clear() {
+ Lock lock(mutex_);
trackerMap_.clear();
sendList_.clear();
}
diff --git a/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.cc b/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.cc
index 9185dba..e280dba 100644
--- a/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.cc
+++ b/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.cc
@@ -39,7 +39,7 @@ void UnAckedMessageTrackerEnabled::timeoutHandler() {
}
void UnAckedMessageTrackerEnabled::timeoutHandlerHelper() {
- std::lock_guard<std::mutex> acquire(lock_);
+ std::unique_lock<std::mutex> acquire(lock_);
LOG_DEBUG("UnAckedMessageTrackerEnabled::timeoutHandlerHelper invoked for consumerPtr_ "
<< consumerReference_.getName().c_str());
@@ -60,6 +60,9 @@ void UnAckedMessageTrackerEnabled::timeoutHandlerHelper() {
timePartitions.push_back(headPartition);
if (msgIdsToRedeliver.size() > 0) {
+ // redeliverUnacknowledgedMessages() may call clear() that acquire the lock again, so we should unlock
+ // here to avoid deadlock
+ acquire.unlock();
consumerReference_.redeliverUnacknowledgedMessages(msgIdsToRedeliver);
}
}
@@ -148,6 +151,7 @@ void UnAckedMessageTrackerEnabled::removeTopicMessage(const std::string& topic)
}
void UnAckedMessageTrackerEnabled::clear() {
+ std::lock_guard<std::mutex> acquire(lock_);
messageIdPartitionMap.clear();
for (auto it = timePartitions.begin(); it != timePartitions.end(); it++) {
it->clear();
diff --git a/pulsar-client-cpp/tests/BasicEndToEndTest.cc b/pulsar-client-cpp/tests/BasicEndToEndTest.cc
index cc71a35..acad16a 100644
--- a/pulsar-client-cpp/tests/BasicEndToEndTest.cc
+++ b/pulsar-client-cpp/tests/BasicEndToEndTest.cc
@@ -1748,6 +1748,8 @@ TEST(BasicEndToEndTest, testPartitionTopicUnAckedMessageTimeout) {
std::this_thread::sleep_for(std::chrono::milliseconds(500));
timeWaited += 500;
}
+
+ client.close();
}
TEST(BasicEndToEndTest, testUnAckedMessageTimeoutListener) {
[pulsar] 02/02: Set dryrun of KubernetesRuntime is null (#8064)
Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
zhaijia pushed a commit to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 3b8ce21c5ec7b64b17c357088d82c268a0003477
Author: xiaolong ran <rx...@apache.org>
AuthorDate: Fri Sep 18 10:45:04 2020 +0800
Set dryrun of KubernetesRuntime is null (#8064)
Signed-off-by: xiaolong.ran <rx...@apache.org>
### Motivation
In #7994, we upgrade the `client-java` of Kubernetes to `0.9.2`, this will cause the following error. During the creation of statefulsets, secrets and services, the code has been configured to set the "dryrun" value of "true". "true" is not accepted by Kubernetes. Only "All" is allowed. So the value should be set to null.
### Modifications
- Set the `dryrun` of KubernetesRuntime is null.
(cherry picked from commit ad8abd5d2605f621c32a316f7a415f1ba00df130)
---
.../pulsar/functions/runtime/kubernetes/KubernetesRuntime.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java
index aff638c..16bfd74 100644
--- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java
+++ b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java
@@ -419,7 +419,7 @@ public class KubernetesRuntime implements Runtime {
.supplier(() -> {
final V1Service response;
try {
- response = coreClient.createNamespacedService(jobNamespace, service, null, "true", null);
+ response = coreClient.createNamespacedService(jobNamespace, service, null, null, null);
} catch (ApiException e) {
// already exists
if (e.getCode() == HTTP_CONFLICT) {
@@ -504,7 +504,7 @@ public class KubernetesRuntime implements Runtime {
.supplier(() -> {
final V1StatefulSet response;
try {
- response = appsClient.createNamespacedStatefulSet(jobNamespace, statefulSet, null, "true", null);
+ response = appsClient.createNamespacedStatefulSet(jobNamespace, statefulSet, null, null, null);
} catch (ApiException e) {
// already exists
if (e.getCode() == HTTP_CONFLICT) {
@@ -555,7 +555,7 @@ public class KubernetesRuntime implements Runtime {
// https://github.com/kubernetes-client/java/issues/86
response = appsClient.deleteNamespacedStatefulSetCall(
statefulSetName,
- jobNamespace, null, "true",
+ jobNamespace, null, null,
5, null, "Foreground",
null, null)
.execute();
@@ -706,7 +706,7 @@ public class KubernetesRuntime implements Runtime {
// https://github.com/kubernetes-client/java/issues/86
response = coreClient.deleteNamespacedServiceCall(
serviceName,
- jobNamespace, null, "true",
+ jobNamespace, null, null,
0, null,
"Foreground", null, null).execute();
} catch (ApiException e) {