Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

This page is meant as a template for writing a KIP. To create a KIP choose Tools->Copy on this page and modify with your content and replace the heading with the next KIP number and a description of your issue. Replace anything in italics with your own description.

Status

Current state: [One of "Under Discussion", "Accepted", "Rejected"]

Discussion thread: here [Change the link from the KIP proposal email archive to your own email thread]

JIRA: here [Change the link from KAFKA-1 to your own ticket]

Jira
serverASF JIRA
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyKAFKA-4862

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

Describe the problems you are trying to solve.

Public Interfaces

Briefly list any new interfaces that will be introduced as part of this proposal or any existing interfaces that will be removed or changed. The purpose of this section is to concisely call out the public contract that will come along with this feature.

A public interface is any change to the following:

  • Binary log format

  • The network protocol and api behavior

  • Any class in the public packages under clientsConfiguration, especially client configuration

    • org/apache/kafka/common/serialization

    • org/apache/kafka/common

    • org/apache/kafka/common/errors

    • org/apache/kafka/clients/producer

    • org/apache/kafka/clients/consumer (eventually, once stable)

  • Monitoring

  • Command line tools and arguments

  • Anything else that will likely break existing users in some way when they upgrade

Proposed Changes

Describe the new thing you want to do in appropriate detail. This may be fairly extensive and have large subsections of its own. Or it may be a few sentences. Use judgement based on the scope of the change.

Compatibility, Deprecation, and Migration Plan

  • What impact (if any) will there be on existing users?
  • If we are changing behavior how will we phase out the older behavior?
  • If we need special migration tools, describe them here.
  • When will we remove the existing behavior?

Rejected Alternatives

...

Currently the kafka client will non-blocking connect to the broker, but if the broker’s OS system  shuts down or crashes, and the client is connecting to that node, it will waste a long time for the client to be aware of the connection can’t be reached. If the client is connecting the node to update metadata it will not connect to another node unless the previous connection is closed, then the client can’t send or receive message until it is aware of the connection is broken and try other node. This time is determined by the TCP connection parameters in the environment, sometime maybe several minutes.

 

So we want to add a connecting timeout to the client in this situation, it will timeout in a specified time and try to connect to other node to update metadata to avoid this issue.

Public Interfaces

This KIP will add a configuration in the client’s configuration file(both producer and consumer):

connect.timeout.ms: the connecting time out of one connection, default is 5000.

Proposed Changes

The change is as follow:

(1)     Add a connecting time to the network client.

(2)     Whenever a connection is trying to connect, we save the connecting channel in a hash map.

(3)     At the end of every poll in the selector, we check if there are any connecting channels timeout, if so we will close these the connecting channels, then the client will try to select other node to connect.

(4)     If a channel is connected or closed, we will remove it from the connecting channel hash map.

.

Compatibility, Deprecation, and Migration Plan

The proposed change is backward compatible.


Rejected Alternatives

  1. Use connections.max.idle.ms to instead of connect.timeout.ms:  it will close idle connections after the number of milliseconds specified by this config, default is 9 minutes
    But this parameter is only work for the connection phase, if the channel is connecting, this parameter can not close the channel.

  2. Enhanced request.timeout.ms to support the connecting timeout:  we are using request.timeout.ms to control not only for the request(produce request or fetch request), but also for the connecting phase.
    If we only use the request.timeout for the connect and process request,  it is not flexible for some case:  for example we need the connecting phase to a short time(5s), and the request for a longer time(40s).