[ 
https://issues.apache.org/jira/browse/GOBBLIN-1260?focusedWorklogId=483507&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-483507
 ]

ASF GitHub Bot logged work on GOBBLIN-1260:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 12/Sep/20 22:01
            Start Date: 12/Sep/20 22:01
    Worklog Time Spent: 10m 
      Work Description: sv2000 commented on a change in pull request #3100:
URL: https://github.com/apache/incubator-gobblin/pull/3100#discussion_r487138511



##########
File path: 
gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixTask.java
##########
@@ -213,9 +213,17 @@ private Integer getPartitionForHelixTask(TaskDriver 
taskDriver) {
 
   @Override
   public void cancel() {
-    log.info("Gobblin helix task cancellation invoked.");
+    log.info("Gobblin helix task cancellation invoked for jobId {}.", jobId);
     if (this.task != null ) {
-      this.task.cancel();
+      try {
+        this.task.cancel();
+        log.info("Gobblin helix task cancellation completed for jobId {}.", 
jobId);
+      } catch (Throwable t) {
+        log.info("Gobblin helix task cancellation for jobId {} failed with 
exception.", jobId, t);

Review comment:
       As @autumnust has pointed out to me, the pattern of catching an 
exception to log and re-throw the same exception is an anti-pattern. I would 
recommend reading this SO post: 
https://softwareengineering.stackexchange.com/questions/365427/try-catch-log-rethrow-is-anti-pattern
   In your case, I think you are catching the exception to log the jobId. In 
this case, per the SO post, it is recommended to wrap the original exception 
into another exception with the additional context and propagate it up the call 
stack. 

##########
File path: 
gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixTask.java
##########
@@ -213,9 +213,17 @@ private Integer getPartitionForHelixTask(TaskDriver 
taskDriver) {
 
   @Override
   public void cancel() {
-    log.info("Gobblin helix task cancellation invoked.");
+    log.info("Gobblin helix task cancellation invoked for jobId {}.", jobId);
     if (this.task != null ) {
-      this.task.cancel();
+      try {
+        this.task.cancel();
+        log.info("Gobblin helix task cancellation completed for jobId {}.", 
jobId);
+      } catch (Throwable t) {
+        log.info("Gobblin helix task cancellation for jobId {} failed with 
exception.", jobId, t);
+        throw new RuntimeException("Gobblin helix task cancellation for jobId 
" + jobId + " failed with exception.", t);

Review comment:
       Why not wrap it into a Throwable instead of a RuntimeException?

##########
File path: 
gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixTask.java
##########
@@ -213,9 +213,17 @@ private Integer getPartitionForHelixTask(TaskDriver 
taskDriver) {
 
   @Override
   public void cancel() {
-    log.info("Gobblin helix task cancellation invoked.");
+    log.info("Gobblin helix task cancellation invoked for jobId {}.", jobId);
     if (this.task != null ) {
-      this.task.cancel();
+      try {
+        this.task.cancel();
+        log.info("Gobblin helix task cancellation completed for jobId {}.", 
jobId);
+      } catch (Throwable t) {
+        log.info("Gobblin helix task cancellation for jobId {} failed with 
exception.", jobId, t);

Review comment:
       I don't think this log line is needed, given that the RuntimeException 
already has the context. This will pollute the logs with duplicate stacktraces.

##########
File path: 
gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixTask.java
##########
@@ -213,9 +213,17 @@ private Integer getPartitionForHelixTask(TaskDriver 
taskDriver) {
 
   @Override
   public void cancel() {
-    log.info("Gobblin helix task cancellation invoked.");
+    log.info("Gobblin helix task cancellation invoked for jobId {}.", jobId);
     if (this.task != null ) {
-      this.task.cancel();
+      try {
+        this.task.cancel();
+        log.info("Gobblin helix task cancellation completed for jobId {}.", 
jobId);
+      } catch (Throwable t) {
+        log.info("Gobblin helix task cancellation for jobId {} failed with 
exception.", jobId, t);
+        throw new RuntimeException("Gobblin helix task cancellation for jobId 
" + jobId + " failed with exception.", t);

Review comment:
       Ah I see. Makes sense.

##########
File path: 
gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixTask.java
##########
@@ -213,9 +213,17 @@ private Integer getPartitionForHelixTask(TaskDriver 
taskDriver) {
 
   @Override
   public void cancel() {
-    log.info("Gobblin helix task cancellation invoked.");
+    log.info("Gobblin helix task cancellation invoked for jobId {}.", jobId);
     if (this.task != null ) {
-      this.task.cancel();
+      try {
+        this.task.cancel();
+        log.info("Gobblin helix task cancellation completed for jobId {}.", 
jobId);
+      } catch (Throwable t) {
+        log.info("Gobblin helix task cancellation for jobId {} failed with 
exception.", jobId, t);
+        throw new RuntimeException("Gobblin helix task cancellation for jobId 
" + jobId + " failed with exception.", t);

Review comment:
       Can we just do Throwables.propagate(t), which essentially wraps the 
throwable into a RuntimeException?




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

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 483507)
    Time Spent: 1h 50m  (was: 1h 40m)

> add some log messages in GobblinHelixTask
> -----------------------------------------
>
>                 Key: GOBBLIN-1260
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1260
>             Project: Apache Gobblin
>          Issue Type: Improvement
>            Reporter: Arjun Singh Bora
>            Priority: Major
>          Time Spent: 1h 50m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to