You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Konstantin Smirnov (JIRA)" <ji...@apache.org> on 2017/05/17 15:37:04 UTC

[jira] [Comment Edited] (KAFKA-5263) kakfa-clients consume 100% CPU with manual partition assignment

    [ https://issues.apache.org/jira/browse/KAFKA-5263?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16014226#comment-16014226 ] 

Konstantin Smirnov edited comment on KAFKA-5263 at 5/17/17 3:36 PM:
--------------------------------------------------------------------

Sample code leading to the trouble:
{code}
public static void main(String[] args) {
        System.out.println("Starting consumer");
        Properties props = new Properties();
        props.put("bootstrap.servers", "localhost:9092");
        props.put("group.id", "test12345");
        props.put("reconnect.backoff.ms", "1000");
        props.put("retry.backoff.ms", "1000");
        props.put("session.timeout.ms", "10000");
        props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
        props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
        
        try (KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props)) {
            String topic = "test-topic"; 
//            consumer.subscribe(Arrays.asList(topic));
            List<TopicPartition> partitions = new ArrayList<>();
            for (PartitionInfo partition : consumer.partitionsFor(topic)) {
                partitions.add(new TopicPartition(topic, partition.partition()));
            }
            consumer.assign(partitions);
            for (;;) {
                ConsumerRecords<String, String> records = consumer.poll(1000);
                if (!records.isEmpty()) {
                    System.out.println("Records aren't empty!");
                }
                records.forEach(System.out::println);
            }
        }
    }
{code}
Steps to reproduce:
* Start Kafka broker
* Run the sample code
* Stop Kafka broker


was (Author: kosm):
Sample code leading to the trouble:
{code}
public static void main(String[] args) {
        System.out.println("Starting consumer");
        Properties props = new Properties();
        props.put("bootstrap.servers", "localhost:9092");
        props.put("group.id", "test12345");
        props.put("reconnect.backoff.ms", "1000");
        props.put("retry.backoff.ms", "1000");
        props.put("session.timeout.ms", "10000");
        props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
        props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
        
        try (KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props)) {
            String topic = "test-topic"; 
//            consumer.subscribe(Arrays.asList(topic));
            List<TopicPartition> partitions = new ArrayList<>();
            for (PartitionInfo partition : consumer.partitionsFor(topic)) {
                partitions.add(new TopicPartition(topic, partition.partition()));
            }
            consumer.assign(partitions);
            for (;;) {
                ConsumerRecords<String, String> records = consumer.poll(1000);
                if (!records.isEmpty()) {
                    System.out.println("Records aren't empty!");
                }
                records.forEach(System.out::println);
            }
        }
    }
{code}

> kakfa-clients consume 100% CPU with manual partition assignment
> ---------------------------------------------------------------
>
>                 Key: KAFKA-5263
>                 URL: https://issues.apache.org/jira/browse/KAFKA-5263
>             Project: Kafka
>          Issue Type: Bug
>          Components: clients
>    Affects Versions: 0.10.1.0, 0.10.1.1, 0.10.2.0, 0.10.2.1
>            Reporter: Konstantin Smirnov
>
> Noticed that lose of the connection to Kafka broker leads kafka-clients to consume 100% CPU. The bug only appears when the manual partition assignmet is used. It appears since the version 0.10.1.0. The bug is quite similar to KAFKA-1642.



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