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/03/01 08:09:51 UTC

[GitHub] [pulsar] nodece opened a new pull request #13535: Improve print log when the topic does not exist

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


   Signed-off-by: Zixuan Liu <no...@gmail.com>
   
   ### Motivation
    
   When updating a topic policy that does not exist, the exception thrown should not be recorded as an error log. 
   
   ### Modifications
   
   Use `log.warn` to record the exceptions that the topic does not exist.
   
   ### Documentation
   
   Check the box below and label this PR (if you have committer privilege).
   
   Need to update docs? 
   
   - [x] `no-need-doc` 
   Just improve the print log.
   
     
   


-- 
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 pull request #13535: Improve print log when the topic does not exist

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#issuecomment-1002361323


   /pulsarbot run-failure-checks


-- 
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 pull request #13535: [Broker] Ignore the print the log that the topic does not exist

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#issuecomment-1062984080


   /pulsarbot rerun-failure-checks


-- 
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] codelipenghui commented on pull request #13535: [Broker] Throw a warning log when update a topic level policy on non-exist topic

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#issuecomment-1062577457


   > I'm not sure why need to record a warning log for non-existing topics
   
   After checking the operation for namespaces, if the namespace does not exist,
   we will not print any logs, we can remove the warn log for topics not existing @nodece 


-- 
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 removed a comment on pull request #13535: Improve print log when the topic does not exist

Posted by GitBox <gi...@apache.org>.
nodece removed a comment on pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#issuecomment-1002120178






-- 
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 pull request #13535: [Broker] Ignore the print the log that the topic does not exist

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#issuecomment-1063594775


   /pulsarbot rerun-failure-checks


-- 
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 pull request #13535: [Broker] Throw a warning log when update a topic level policy on non-exist topic

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#issuecomment-1058774184


   /pulsarbot rerun-failure-checks


-- 
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 closed pull request #13535: Improve print log when the topic does not exist

Posted by GitBox <gi...@apache.org>.
nodece closed pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535


   


-- 
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] codelipenghui merged pull request #13535: [Broker] Ignore the print the log that the topic does not exist

Posted by GitBox <gi...@apache.org>.
codelipenghui merged pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535


   


-- 
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 pull request #13535: Improve print log when the topic does not exist

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#issuecomment-1002120178


   /pulsarbot run-failure-checks


-- 
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] michaeljmarshall commented on a change in pull request #13535: [Broker] Throw a warning log when update a topic level policy on non-exist topic

Posted by GitBox <gi...@apache.org>.
michaeljmarshall commented on a change in pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#discussion_r822318974



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -4554,10 +4555,28 @@ protected void internalGetLastMessageId(AsyncResponse asyncResponse, boolean aut
 
     protected void handleTopicPolicyException(String methodName, Throwable thr, AsyncResponse asyncResponse) {
         Throwable cause = thr.getCause();
-        if (!(cause instanceof WebApplicationException)
-                || !(((WebApplicationException) cause).getResponse().getStatus() == 307)) {
-            log.error("[{}] Failed to perform {} on topic {}",
-                    clientAppId(), methodName, topicName, cause);
+
+        Level logLevel = null;
+        if (cause instanceof WebApplicationException) {
+            int statusCode = ((WebApplicationException) cause).getResponse().getStatus();
+            if (statusCode == Status.NOT_FOUND.getStatusCode()) {
+                logLevel = Level.WARN;
+            } else if (statusCode != Status.TEMPORARY_REDIRECT.getStatusCode()) {
+                logLevel = Level.ERROR;
+            }
+        } else {
+            logLevel = Level.ERROR;
+        }
+
+        if (logLevel != null) {
+            switch (logLevel) {
+                case WARN:
+                    log.warn("[{}] Failed to perform {} on topic {}", clientAppId(), methodName, topicName, cause);

Review comment:
       It seems like we could avoid logging the stack trace. What do you think @nodece?




-- 
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 pull request #13535: [Broker] Throw a warning log when update a topic level policy on non-exist topic

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#issuecomment-1062598755


   > > I'm not sure why need to record a warning log for non-existing topics
   > 
   > After checking the operation for namespaces, if the namespace does not exist, we will not print any logs, we can remove the warn log for topics not existing @nodece
   
   OK, Let me update this.


-- 
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 pull request #13535: [Broker] Throw a warning log when update a topic level policy on non-exist topic

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#issuecomment-1056075523


   /pulsarbot rerun-failure-checks


-- 
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] michaeljmarshall commented on pull request #13535: Improve print log when the topic does not exist

Posted by GitBox <gi...@apache.org>.
michaeljmarshall commented on pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#issuecomment-1036618907


   Removing release label and milestone since the PR is closed. Please re-add if we need to open the PR.


-- 
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] codelipenghui commented on a change in pull request #13535: Improve print log when the topic does not exist

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on a change in pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#discussion_r775844799



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -4363,11 +4363,20 @@ protected void internalHandleResult(AsyncResponse asyncResponse,
 
     protected void handleTopicPolicyException(String methodName, Throwable thr, AsyncResponse asyncResponse) {
         Throwable cause = thr.getCause();
-        if (!(cause instanceof WebApplicationException)
-                || !(((WebApplicationException) cause).getResponse().getStatus() == 307)) {
-            log.error("[{}] Failed to perform {} on topic {}",
-                    clientAppId(), methodName, topicName, cause);
+
+        if (cause instanceof WebApplicationException) {
+            int statusCode = ((WebApplicationException) cause).getResponse().getStatus();
+
+            // Print a warning level log when the topic does not exist, otherwise print an error level log.

Review comment:
       Nit: the code is very easy to understand, instead, bringing this description has a counterproductive effect, because TEMPORARY_REDIRECT will not print any logs.




-- 
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] gaoran10 commented on pull request #13535: [Broker] Throw a warning log when update a topic level policy on non-exist topic

Posted by GitBox <gi...@apache.org>.
gaoran10 commented on pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#issuecomment-1062535046


   I'm not sure why need to record a warning log for non-existing topics.


-- 
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 change in pull request #13535: [Broker] Throw a warning log when update a topic level policy on non-exist topic

Posted by GitBox <gi...@apache.org>.
nodece commented on a change in pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#discussion_r822326287



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -4554,10 +4555,28 @@ protected void internalGetLastMessageId(AsyncResponse asyncResponse, boolean aut
 
     protected void handleTopicPolicyException(String methodName, Throwable thr, AsyncResponse asyncResponse) {
         Throwable cause = thr.getCause();
-        if (!(cause instanceof WebApplicationException)
-                || !(((WebApplicationException) cause).getResponse().getStatus() == 307)) {
-            log.error("[{}] Failed to perform {} on topic {}",
-                    clientAppId(), methodName, topicName, cause);
+
+        Level logLevel = null;
+        if (cause instanceof WebApplicationException) {
+            int statusCode = ((WebApplicationException) cause).getResponse().getStatus();
+            if (statusCode == Status.NOT_FOUND.getStatusCode()) {
+                logLevel = Level.WARN;
+            } else if (statusCode != Status.TEMPORARY_REDIRECT.getStatusCode()) {
+                logLevel = Level.ERROR;
+            }
+        } else {
+            logLevel = Level.ERROR;
+        }
+
+        if (logLevel != null) {
+            switch (logLevel) {
+                case WARN:
+                    log.warn("[{}] Failed to perform {} on topic {}", clientAppId(), methodName, topicName, cause);

Review comment:
       Yes, we can avoid this. 




-- 
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