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

NetworkClient should not send nil in case of failure #275

Merged
merged 1 commit into from
Mar 5, 2018

Conversation

ashwini709
Copy link
Contributor

@ashwini709 ashwini709 commented Mar 3, 2018

As pointed out by @dantswain Swallowing nil in #272 was not a good idea. It leads to further crashes in here
response |> hd |> Map.get(:partitions) |> hd |> Map.get(:last_offset)

screen shot 2018-02-26 at 17 25 03

If we return the {:error, reason} in case of network_client's send_sync_reuqest failure, it leads to the genserver crashing but with a valid reason.
screen shot 2018-03-03 at 10 17 01

I would like to fix the issues related to #233 as much as possible.
@joshuawscott @dantswain would appreciate the guidance/suggestions to fix this behaviour. Thank you.

  1. Should the network_client retry the connection?
  2. If the network_client continues to timeout, should the genconsumer's consume/1 handle the result and reply with error?

While we are at it, I would like to send {:ok, response} in case of success if thats ok.

response = broker
|> NetworkClient.send_sync_request(offset_commit_request_payload, config_sync_timeout())
|> OffsetCommit.parse_response
response = case NetworkClient.send_sync_request(broker, offset_commit_request_payload, config_sync_timeout()) do

Choose a reason for hiding this comment

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

Line is too long (max is 80, was 116).

@ashwini709 ashwini709 force-pushed the network_client branch 3 times, most recently from 4fee1be to 5ca5132 Compare March 3, 2018 03:18
@@ -526,7 +532,10 @@ defmodule KafkaEx.Server do
defp first_broker_response(request, brokers, sync_timeout) do
Enum.find_value(brokers, fn(broker) ->
if Broker.connected?(broker) do
NetworkClient.send_sync_request(broker, request, sync_timeout)
case NetworkClient.send_sync_request(broker, request, sync_timeout) do

Choose a reason for hiding this comment

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

Function body is nested too deep (max depth is 2, was 3).

@@ -526,7 +532,10 @@ defmodule KafkaEx.Server do
defp first_broker_response(request, brokers, sync_timeout) do
Enum.find_value(brokers, fn(broker) ->
if Broker.connected?(broker) do
NetworkClient.send_sync_request(broker, request, sync_timeout)
case NetworkClient.send_sync_request(broker, request, sync_timeout) do

Choose a reason for hiding this comment

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

Function body is nested too deep (max depth is 2, was 3).

@@ -304,8 +304,12 @@ defmodule KafkaEx.Server do
0 -> NetworkClient.send_async_request(broker, produce_request_data)
_ ->
response = broker
|> NetworkClient.send_sync_request(produce_request_data, config_sync_timeout())
|> Produce.parse_response
|> NetworkClient.send_sync_request(produce_request_data, config_sync_timeout())

Choose a reason for hiding this comment

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

Line is too long (max is 80, was 95).

@@ -334,8 +338,12 @@ defmodule KafkaEx.Server do
{:topic_not_found, state}
_ ->
response = broker
|> NetworkClient.send_sync_request(offset_request, config_sync_timeout())
|> Offset.parse_response
|> NetworkClient.send_sync_request(offset_request, config_sync_timeout())

Choose a reason for hiding this comment

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

Line is too long (max is 80, was 87).

do: module.parse_response(response),
else: nil
response = broker
|> NetworkClient.send_sync_request(wire_request, config_sync_timeout())

Choose a reason for hiding this comment

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

Line is too long (max is 80, was 85).

@@ -526,7 +532,10 @@ defmodule KafkaEx.Server do
defp first_broker_response(request, brokers, sync_timeout) do
Enum.find_value(brokers, fn(broker) ->
if Broker.connected?(broker) do
NetworkClient.send_sync_request(broker, request, sync_timeout)
case NetworkClient.send_sync_request(broker, request, sync_timeout) do

Choose a reason for hiding this comment

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

Line is too long (max is 80, was 82).

config_sync_timeout())
|> case do
{:error, reason} -> {:error, reason}
response -> OffsetFetch.parse_response(response)
Copy link
Member

@joshuawscott joshuawscott Mar 3, 2018

Choose a reason for hiding this comment

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

I think this should be OffsetCommit.parse_response?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. My Bad. I have updated the PR. Thanks.

@sourcelevel-bot
Copy link

Ebert has finished reviewing this Pull Request and has found:

  • 1 possible new issue (including those that may have been commented here).
  • 2 fixed issues! 🎉

You can see more details about this review at https://ebertapp.io/github/kafkaex/kafka_ex/pulls/275.

Copy link
Member

@joshuawscott joshuawscott left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@ashwini709
Copy link
Contributor Author

@joshuawscott When can we get this merged?

@joshuawscott joshuawscott requested a review from dantswain March 5, 2018 03:26
@joshuawscott
Copy link
Member

Going to give the other maintainers a chance to weigh in and then merge tomorrow U.S. time

@joshuawscott joshuawscott merged commit 872c842 into kafkaex:master Mar 5, 2018
@joshuawscott
Copy link
Member

Thanks again for the PR @ashwini709 !

@ashwini709 ashwini709 deleted the network_client branch March 6, 2018 01:34
robotarmy pushed a commit to RAM9/kafka_ex that referenced this pull request Apr 7, 2025
NetworkClient should not send nil in case of failure
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.

4 participants