You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/06/28 08:09:19 UTC

[GitHub] [pulsar] nodece opened a new pull request, #16264: [improve][functions] Check whether the resource exists and create it

nodece opened a new pull request, #16264:
URL: https://github.com/apache/pulsar/pull/16264

   Signed-off-by: Zixuan Liu <no...@gmail.com>
   
   ### Motivation
   
   Avoid printing the resource exists exception, the log like:
   ```
   2022-06-28T15:36:13,509+0800 [broker-topic-workers-OrderedExecutor-2-0] ERROR org.apache.pulsar.broker.admin.v2.PersistentTopics - [null] Failed to create non-partitioned topic persistent://public/functions/coordinate
   java.util.concurrent.CompletionException: org.apache.pulsar.broker.web.RestException: This topic already exists
           at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) ~[?:?]
           at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320) ~[?:?]
           at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1159) ~[?:?]
           at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[?:?]
           at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147) ~[?:?]
           at org.apache.pulsar.broker.service.BrokerService$2.lambda$openLedgerComplete$4(BrokerService.java:1426) ~[pulsar-broker.jar:2.11.0-SNAPSHOT]
           at java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:787) ~[?:?]
           at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[?:?]
           at java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:614) ~[?:?]
           at java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:795) ~[?:?]
           at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?]
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
           at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.77.Final.jar:4.1.77.Final]
           at java.lang.Thread.run(Thread.java:833) [?:?]
   Caused by: org.apache.pulsar.broker.web.RestException: This topic already exists
           at org.apache.pulsar.broker.admin.impl.PersistentTopicsBase.lambda$internalCreateNonPartitionedTopicAsync$36(PersistentTopicsBase.java:389) ~[pulsar-broker.jar:2.11.0-SNAPSHOT]
           at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150) ~[?:?]
           ... 12 more
   ```
   
   ### Modifications
   
   - Add the tenant, cluster, and topic check
   
   ### Documentation
   
   - [x] `doc-not-needed` 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] tisonkun commented on pull request #16264: [improve][functions] Check whether the resource exists and create it

Posted by GitBox <gi...@apache.org>.
tisonkun commented on PR #16264:
URL: https://github.com/apache/pulsar/pull/16264#issuecomment-1345421999

   Closed as stale and no consensus. Please rebase and resubmit the patch if it's still relevant.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] github-actions[bot] commented on pull request #16264: [improve][functions] Check whether the resource exists and create it

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #16264:
URL: https://github.com/apache/pulsar/pull/16264#issuecomment-1200066500

   The pr had no activity for 30 days, mark with Stale label.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] nodece commented on a diff in pull request #16264: [improve][functions] Check whether the resource exists and create it

Posted by GitBox <gi...@apache.org>.
nodece commented on code in PR #16264:
URL: https://github.com/apache/pulsar/pull/16264#discussion_r908207591


##########
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/PulsarWorkerService.java:
##########
@@ -389,7 +397,11 @@ private static Policies createFunctionsNamespacePolicies(String pulsarFunctionsC
 
     private void tryCreateNonPartitionedTopic(final String topic) throws PulsarAdminException {
         try {
-            getBrokerAdmin().topics().createNonPartitionedTopic(topic);
+            TopicName topicName = TopicName.get(topic);
+            List<String> topics = getBrokerAdmin().topics().getList(topicName.getNamespace());
+            if (topics.stream().noneMatch(n -> TopicName.get(n).equals(topicName))) {
+                getBrokerAdmin().topics().createNonPartitionedTopic(topic);
+            }
         } catch (PulsarAdminException e) {
             if (e instanceof PulsarAdminException.ConflictException) {
                 log.warn("Failed to create topic '{}': {}", topic, e.getMessage());

Review Comment:
   Switch to the "debug" level is easier, but you can still see some logs in the broker.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] github-actions[bot] commented on pull request #16264: [improve][functions] Check whether the resource exists and create it

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #16264:
URL: https://github.com/apache/pulsar/pull/16264#issuecomment-1169616743

   @nodece Please provide a correct documentation label for your PR.
   Instructions see [Pulsar Documentation Label Guide](https://docs.google.com/document/d/1Qw7LHQdXWBW9t2-r-A7QdFDBwmZh6ytB4guwMoXHqc0).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] eolivelli commented on a diff in pull request #16264: [improve][functions] Check whether the resource exists and create it

Posted by GitBox <gi...@apache.org>.
eolivelli commented on code in PR #16264:
URL: https://github.com/apache/pulsar/pull/16264#discussion_r908191136


##########
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/PulsarWorkerService.java:
##########
@@ -389,7 +397,11 @@ private static Policies createFunctionsNamespacePolicies(String pulsarFunctionsC
 
     private void tryCreateNonPartitionedTopic(final String topic) throws PulsarAdminException {
         try {
-            getBrokerAdmin().topics().createNonPartitionedTopic(topic);
+            TopicName topicName = TopicName.get(topic);
+            List<String> topics = getBrokerAdmin().topics().getList(topicName.getNamespace());
+            if (topics.stream().noneMatch(n -> TopicName.get(n).equals(topicName))) {
+                getBrokerAdmin().topics().createNonPartitionedTopic(topic);
+            }
         } catch (PulsarAdminException e) {
             if (e instanceof PulsarAdminException.ConflictException) {
                 log.warn("Failed to create topic '{}': {}", topic, e.getMessage());

Review Comment:
   this is the only line you want to change.
   you can switch this to DEBUG



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] tisonkun closed pull request #16264: [improve][functions] Check whether the resource exists and create it

Posted by GitBox <gi...@apache.org>.
tisonkun closed pull request #16264: [improve][functions] Check whether the resource exists and create it
URL: https://github.com/apache/pulsar/pull/16264


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org