Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-5976: RequestChannel.sendResponse should record correct size for NetworkSend. #3961

Closed
wants to merge 4 commits into from

Conversation

huxihx
Copy link
Contributor

@huxihx huxihx commented Sep 26, 2017

When TRACE logging is enabled, RequestChannel.sendResponse records incorrect size for Send due to the fact that response.responseSend is of scala.Option type.

…r NetworkSend.

When TRACE logging is enabled, RequestChannel.sendResponse records incorrect size for `Send` due to the fact that `response.responseSend` is of scala.Option type.
@huxihx
Copy link
Contributor Author

huxihx commented Sep 26, 2017

@ijuma Please review this tiny patch. Thanks.

@@ -247,7 +247,7 @@ class RequestChannel(val numProcessors: Int, val queueSize: Int) extends KafkaMe
if (isTraceEnabled) {
val requestHeader = response.request.header
trace(s"Sending ${requestHeader.apiKey} response to client ${requestHeader.clientId} of " +
s"${response.responseSend.size} bytes.")
s"${response.responseSend.get.size} bytes.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. However, this could be None, so we should probably log something different if responseAction is NoOp or Close.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already added code to handle such situation. Please review.

case Some(send) => send.size
case None => 0
}
trace(s"Sending ${requestHeader.apiKey} response[action=${response.responseAction}, size=$size] to client")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we are not necessarily sending a response. I was thinking of something like:

response.responseAction match {
  case SendAction => // like now
  case NoOpAction => // log that no response is being sent
  case CloseConnectionAction => // log that the connection is being closed

Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. It's clear to do trace logs for different response actions.

trace(s"No need to send ${requestHeader.apiKey} response to client ${requestHeader.clientId}.")
case CloseConnectionAction =>
trace("The connection is being closed since request handler encountered an error.")
case _ => // it should not happen

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not clear why you shadow impossible case? I would remove it or throw something like IllegalArgurmentException

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should remove it and make ResponseAction sealed.

trace(s"No need to send ${requestHeader.apiKey} response to client ${requestHeader.clientId}.")
case CloseConnectionAction =>
trace("The connection is being closed since request handler encountered an error.")
case _ => // it should not happen

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val message = response.responseAction match ...
trace(message)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would compute the message even if trace logging is not enabled.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not clear how it possible, it with in if (isTraceEnabled) scope.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I had missed the if. In that case, your suggestion sounds good.

@huxihx
Copy link
Contributor Author

huxihx commented Sep 27, 2017

@ijuma @dbolshak Thanks for the comments. Please review again.

Copy link

@dbolshak dbolshak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@huxihx but I am not in list of committers.

Copy link
Contributor

@ijuma ijuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM. I tweaked the message a little:

case SendAction =>
          s"Sending ${requestHeader.apiKey} response to client ${requestHeader.clientId} of ${response.responseSend.get.size} bytes."
        case NoOpAction =>
          s"Not sending ${requestHeader.apiKey} response to client ${requestHeader.clientId} as it's not required."
        case CloseConnectionAction =>
          s"Closing connection for client ${requestHeader.clientId} due to error during handling of ${requestHeader.apiKey}."

@asfgit asfgit closed this in 983280c Sep 28, 2017
@huxihx huxihx deleted the KAFKA-5976 branch October 9, 2017 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants