This is an automated email from the ASF dual-hosted git repository.

brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit fafd88e717eec071559c3b141cde8eb9801a4234
Merge: b1c3755 4e77cc8
Author: Brandon Williams <[email protected]>
AuthorDate: Wed Oct 20 11:01:22 2021 -0500

    Merge branch 'cassandra-4.0' into trunk

 src/java/org/apache/cassandra/transport/ExceptionHandlers.java | 6 ++++++
 1 file changed, 6 insertions(+)

diff --cc src/java/org/apache/cassandra/transport/ExceptionHandlers.java
index 377b640,1c5c976..e2c570d
--- a/src/java/org/apache/cassandra/transport/ExceptionHandlers.java
+++ b/src/java/org/apache/cassandra/transport/ExceptionHandlers.java
@@@ -34,8 -32,7 +34,9 @@@ import io.netty.channel.Channel
  import io.netty.channel.ChannelHandlerContext;
  import io.netty.channel.ChannelInboundHandlerAdapter;
  import io.netty.channel.ChannelPromise;
+ import io.netty.channel.unix.Errors;
 +import org.apache.cassandra.exceptions.OverloadedException;
 +import org.apache.cassandra.config.DatabaseDescriptor;
  import org.apache.cassandra.metrics.ClientMetrics;
  import org.apache.cassandra.net.FrameEncoder;
  import org.apache.cassandra.transport.messages.ErrorMessage;
@@@ -110,44 -118,6 +111,49 @@@ public class ExceptionHandler
          }
      }
  
 +    static void logClientNetworkingExceptions(Throwable cause)
 +    {
 +        if (Throwables.anyCauseMatches(cause, t -> t instanceof 
ProtocolException))
 +        {
 +            // if any ProtocolExceptions is not silent, then handle
 +            if (Throwables.anyCauseMatches(cause, t -> t instanceof 
ProtocolException && !((ProtocolException) t).isSilent()))
 +            {
 +                ClientMetrics.instance.markProtocolException();
 +                // since protocol exceptions are expected to be client 
issues, not logging stack trace
 +                // to avoid spamming the logs once a bad client shows up
 +                NoSpamLogger.log(logger, NoSpamLogger.Level.WARN, 1, 
TimeUnit.MINUTES, "Protocol exception with client networking: " + 
cause.getMessage());
 +            }
 +        }
 +        else if (Throwables.anyCauseMatches(cause, t -> t instanceof 
OverloadedException))
 +        {
 +            // Once the threshold for overload is breached, it will very 
likely spam the logs...
 +            NoSpamLogger.log(logger, NoSpamLogger.Level.INFO, 1, 
TimeUnit.MINUTES, cause.getMessage());
 +        }
++        else if (Throwables.anyCauseMatches(cause, t -> t instanceof 
Errors.NativeIoException))
++        {
++            ClientMetrics.instance.markUnknownException();
++            logger.trace("Native exception in client networking", cause);
++        }
 +        else
 +        {
 +            ClientMetrics.instance.markUnknownException();
 +            logger.warn("Unknown exception in client networking", cause);
 +        }
 +    }
 +
 +    static Predicate<Throwable> getUnexpectedExceptionHandler(Channel 
channel, boolean alwaysLogAtError)
 +    {
 +        SocketAddress address = channel.remoteAddress();
 +        if 
(DatabaseDescriptor.getClientErrorReportingExclusions().contains(address))
 +        {
 +            return cause -> {
 +                logger.debug("Excluding client exception for {}; address 
contained in client_error_reporting_exclusions", address, cause);
 +                return true;
 +            };
 +        }
 +        return new UnexpectedChannelExceptionHandler(channel, 
alwaysLogAtError);
 +    }
 +
      /**
       * Include the channel info in the logged information for unexpected 
errors, and (if {@link #alwaysLogAtError} is
       * false then choose the log level based on the type of exception (some 
are clearly client issues and shouldn't be

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to