cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William R. Speirs (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CASSANDRA-13368) Exception Stack not Printed as Intended in Error Logs
Date Wed, 22 Mar 2017 21:10:41 GMT

     [ https://issues.apache.org/jira/browse/CASSANDRA-13368?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

William R. Speirs updated CASSANDRA-13368:
------------------------------------------
    Fix Version/s: 2.1.x
    Reproduced In: 2.1.x
           Status: Patch Available  (was: Open)

diff --git a/src/java/org/apache/cassandra/auth/CassandraAuthorizer.java b/src/java/org/apache/cassandra/auth/CassandraAuthorizer.java
index 49eefb1..4f8c721 100644
--- a/src/java/org/apache/cassandra/auth/CassandraAuthorizer.java
+++ b/src/java/org/apache/cassandra/auth/CassandraAuthorizer.java
@@ -187,7 +187,8 @@ public class CassandraAuthorizer implements IAuthorizer
         }
         catch (RequestExecutionException e)
         {
-            logger.warn("CassandraAuthorizer failed to revoke all permissions of {}: {}",
droppedUser, e);
+            logger.warn("CassandraAuthorizer failed to revoke all permissions of {}", droppedUser);
+            logger.warn(e.getMessage(), e);
         }
     }
 
@@ -206,7 +207,8 @@ public class CassandraAuthorizer implements IAuthorizer
         }
         catch (RequestExecutionException e)
         {
-            logger.warn("CassandraAuthorizer failed to revoke all permissions on {}: {}",
droppedResource, e);
+            logger.warn("CassandraAuthorizer failed to revoke all permissions on {}", droppedResource);
+            logger.warn(e.getMessage(), e);
             return;
         }
 
@@ -222,7 +224,8 @@ public class CassandraAuthorizer implements IAuthorizer
             }
             catch (RequestExecutionException e)
             {
-                logger.warn("CassandraAuthorizer failed to revoke all permissions on {}:
{}", droppedResource, e);
+                logger.warn("CassandraAuthorizer failed to revoke all permissions on {}",
droppedResource);
+                logger.warn(e.getMessage(), e);
             }
         }
     }
diff --git a/src/java/org/apache/cassandra/db/BatchlogManager.java b/src/java/org/apache/cassandra/db/BatchlogManager.java
index 4588156..ebc64e3 100644
--- a/src/java/org/apache/cassandra/db/BatchlogManager.java
+++ b/src/java/org/apache/cassandra/db/BatchlogManager.java
@@ -235,7 +235,8 @@ public class BatchlogManager implements BatchlogManagerMBean
             }
             catch (IOException e)
             {
-                logger.warn("Skipped batch replay of {} due to {}", id, e);
+                logger.warn("Skipped batch replay of {} due to:", id);
+                logger.warn(e.getMessage(), e);
                 deleteBatch(id);
             }
         }
diff --git a/src/java/org/apache/cassandra/db/BlacklistedDirectories.java b/src/java/org/apache/cassandra/db/BlacklistedDirectories.java
index f47fd57..d985e65 100644
--- a/src/java/org/apache/cassandra/db/BlacklistedDirectories.java
+++ b/src/java/org/apache/cassandra/db/BlacklistedDirectories.java
@@ -51,7 +51,8 @@ public class BlacklistedDirectories implements BlacklistedDirectoriesMBean
         catch (Exception e)
         {
             JVMStabilityInspector.inspectThrowable(e);
-            logger.error("error registering MBean {}", MBEAN_NAME, e);
+            logger.error("error registering MBean {}", MBEAN_NAME);
+            logger.error(e.getMessage(), e);
             //Allow the server to start even if the bean can't be registered
         }
     }
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 6e82745..e083c6c 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -442,7 +442,8 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         {
             JVMStabilityInspector.inspectThrowable(e);
             // this shouldn't block anything.
-            logger.warn("Failed unregistering mbean: {}", mbeanName, e);
+            logger.warn("Failed unregistering mbean: {}", mbeanName);
+            logger.warn(e.getMessage(), e);
         }
 
         latencyCalculator.cancel(false);
diff --git a/src/java/org/apache/cassandra/db/Directories.java b/src/java/org/apache/cassandra/db/Directories.java
index 35aa447..38e7171 100644
--- a/src/java/org/apache/cassandra/db/Directories.java
+++ b/src/java/org/apache/cassandra/db/Directories.java
@@ -686,7 +686,8 @@ public class Directories
         }
         catch (IOException e)
         {
-            logger.error("Could not calculate the size of {}. {}", input, e);
+            logger.error("Could not calculate the size of {}", input);
+            logger.error(e.getMessage(), e);
         }
     
         return visitor.getAllocatedSize();
diff --git a/src/java/org/apache/cassandra/db/HintedHandOffManager.java b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
index 0d3ef39..1f1f54e 100644
--- a/src/java/org/apache/cassandra/db/HintedHandOffManager.java
+++ b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
@@ -235,7 +235,8 @@ public class HintedHandOffManager implements HintedHandOffManagerMBean
                 catch (Exception e)
                 {
                     JVMStabilityInspector.inspectThrowable(e);
-                    logger.warn("Could not delete hints for {}: {}", endpoint, e);
+                    logger.warn("Could not delete hints for {}:", endpoint);
+                    logger.warn(e.getMessage(), e);
                 }
             }
         };
diff --git a/src/java/org/apache/cassandra/hadoop/AbstractColumnFamilyInputFormat.java b/src/java/org/apache/cassandra/hadoop/AbstractColumnFamilyInputFormat.java
index e8de0f2..dd9d880 100644
--- a/src/java/org/apache/cassandra/hadoop/AbstractColumnFamilyInputFormat.java
+++ b/src/java/org/apache/cassandra/hadoop/AbstractColumnFamilyInputFormat.java
@@ -303,7 +303,8 @@ public abstract class AbstractColumnFamilyInputFormat<K, Y> extends
InputFormat<
             }
             catch (IOException e)
             {
-                logger.debug("failed connect to endpoint {}", host, e);
+                logger.debug("failed connect to endpoint {}", host);
+                logger.debug(e.getMessage(), e);
             }
             catch (InvalidRequestException e)
             {
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
index 2680125..246d7fb 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
@@ -509,7 +509,8 @@ public class SSTableReader extends SSTable implements SelfRefCounted<SSTableRead
         if (e instanceof FileNotFoundException)
             logger.error("Missing sstable component in {}; skipped because of {}", descriptor,
e.getMessage());
         else
-            logger.error("Corrupt sstable {}; skipped", descriptor, e);
+            logger.error("Corrupt sstable {}; skipped", descriptor);
+            logger.error(e.getMessage(), e);
     }
 
     public static Collection<SSTableReader> openAll(Set<Map.Entry<Descriptor,
Set<Component>>> entries,
diff --git a/src/java/org/apache/cassandra/io/util/FileUtils.java b/src/java/org/apache/cassandra/io/util/FileUtils.java
index f69ed01..6bf2d01 100644
--- a/src/java/org/apache/cassandra/io/util/FileUtils.java
+++ b/src/java/org/apache/cassandra/io/util/FileUtils.java
@@ -225,7 +225,8 @@ public final class FileUtils
         }
         catch (Exception e)
         {
-            logger.warn("Failed closing {}", c, e);
+            logger.warn("Failed closing {}", c);
+            logger.warn(e.getMessage(), e);
         }
     }
 
diff --git a/src/java/org/apache/cassandra/net/OutboundTcpConnection.java b/src/java/org/apache/cassandra/net/OutboundTcpConnection.java
index ff2d929..3f289c4 100644
--- a/src/java/org/apache/cassandra/net/OutboundTcpConnection.java
+++ b/src/java/org/apache/cassandra/net/OutboundTcpConnection.java
@@ -233,7 +233,8 @@ public class OutboundTcpConnection extends Thread
                     JVMStabilityInspector.inspectThrowable(e);
                     // really shouldn't get here, as exception handling in writeConnected()
is reasonably robust
                     // but we want to catch anything bad we don't drop the messages in the
current batch
-                    logger.error("error processing a message intended for {}", poolReference.endPoint(),
e);
+                    logger.error("error processing a message intended for {}", poolReference.endPoint());
+                    logger.error(e.getMessage(), e);
                 }
                 currentMsgBufferCount = --count;
             }
@@ -319,7 +320,8 @@ public class OutboundTcpConnection extends Thread
             else
             {
                 // Non IO exceptions are likely a programming error so let's not silence
them
-                logger.error("error writing to {}", poolReference.endPoint(), e);
+                logger.error("error writing to {}", poolReference.endPoint());
+                logger.error(e.getMessage(), e);
             }
         }
     }
diff --git a/src/java/org/apache/cassandra/service/CassandraDaemon.java b/src/java/org/apache/cassandra/service/CassandraDaemon.java
index dc22834..9f35929 100644
--- a/src/java/org/apache/cassandra/service/CassandraDaemon.java
+++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java
@@ -559,7 +559,8 @@ public class CassandraDaemon
             }
             catch (Exception e)
             {
-                logger.error("error registering MBean {}", MBEAN_NAME, e);
+                logger.error("error registering MBean {}", MBEAN_NAME);
+                logger.error(e.getMessage(), e);
                 //Allow the server to start even if the bean can't be registered
             }
 
diff --git a/src/java/org/apache/cassandra/streaming/StreamSession.java b/src/java/org/apache/cassandra/streaming/StreamSession.java
index 273631c..1f1b45b 100644
--- a/src/java/org/apache/cassandra/streaming/StreamSession.java
+++ b/src/java/org/apache/cassandra/streaming/StreamSession.java
@@ -509,7 +509,8 @@ public class StreamSession implements IEndpointStateChangeSubscriber
         }
         else
         {
-            logger.error("[Stream #{}] Streaming error occurred", planId(), e);
+            logger.error("[Stream #{}] Streaming error occurred", planId());
+            logger.error(e.getMessage(), e);
         }
         // send session failure message
         if (handler.isOutgoingConnected())
@@ -632,7 +633,8 @@ public class StreamSession implements IEndpointStateChangeSubscriber
 
     public void doRetry(FileMessageHeader header, Throwable e)
     {
-        logger.warn("[Stream #{}] Retrying for following error", planId(), e);
+        logger.warn("[Stream #{}] Retrying for following error", planId());
+        logger.warn(e.getMessage(), e);
         // retry
         retries++;
         if (retries > DatabaseDescriptor.getMaxStreamingRetries())
diff --git a/src/java/org/apache/cassandra/transport/Server.java b/src/java/org/apache/cassandra/transport/Server.java
index 02f17b0..447396f 100644
--- a/src/java/org/apache/cassandra/transport/Server.java
+++ b/src/java/org/apache/cassandra/transport/Server.java
@@ -439,7 +439,8 @@ public class Server implements CassandraDaemon.Server
             {
                 // That should not happen, so log an error, but return the
                 // endpoint address since there's a good change this is right
-                logger.error("Problem retrieving RPC address for {}", endpoint, e);
+                logger.error("Problem retrieving RPC address for {}", endpoint);
+                logger.error(e.getMessage(), e);
                 return endpoint;
             }
         }


> Exception Stack not Printed as Intended in Error Logs
> -----------------------------------------------------
>
>                 Key: CASSANDRA-13368
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-13368
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: William R. Speirs
>            Priority: Trivial
>              Labels: lhf
>             Fix For: 2.1.x
>
>         Attachments: cassandra-13368-2.1.patch
>
>
> There are a number of instances where it appears the programmer intended to print a stack
trace in an error message, but it is not actually being printed. For example, in {{BlacklistedDirectories.java:54}}:
> {noformat}
>         catch (Exception e)
>         {
>             JVMStabilityInspector.inspectThrowable(e);
>             logger.error("error registering MBean {}", MBEAN_NAME, e);
>             //Allow the server to start even if the bean can't be registered
>         }
> {noformat}
> The logger will use the second argument for the braces, but will ignore the exception
{{e}}. It would be helpful to have the stack traces of these exceptions printed. I propose
adding a second line that prints the full stack trace: {{logger.error(e.getMessage(), e);}}
> On the 2.1 branch, I found 8 instances of these types of messages:
> {noformat}
> db/BlacklistedDirectories.java:54:            logger.error("error registering MBean {}",
MBEAN_NAME, e);
> io/sstable/SSTableReader.java:512:            logger.error("Corrupt sstable {}; skipped",
descriptor, e);
> net/OutboundTcpConnection.java:228:                    logger.error("error processing
a message intended for {}", poolReference.endPoint(), e);
> net/OutboundTcpConnection.java:314:                logger.error("error writing to {}",
poolReference.endPoint(), e);
> service/CassandraDaemon.java:231:                logger.error("Exception in thread {}",
t, e);
> service/CassandraDaemon.java:562:                logger.error("error registering MBean
{}", MBEAN_NAME, e);
> streaming/StreamSession.java:512:            logger.error("[Stream #{}] Streaming error
occurred", planId(), e);
> transport/Server.java:442:                logger.error("Problem retrieving RPC address
for {}", endpoint, e);
> {noformat}
> And one where it'll print the {{toString()}} version of the exception:
> {noformat}
> db/Directories.java:689:            logger.error("Could not calculate the size of {}.
{}", input, e);
> {noformat}
> I'm happy to create a patch for each branch, just need a little guidance on how to do
so. We're currently running 2.1 so I started there.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message