Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 144CF200C3F for ; Tue, 7 Mar 2017 12:36:45 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 12E1A160B68; Tue, 7 Mar 2017 11:36:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 672FD160B74 for ; Tue, 7 Mar 2017 12:36:44 +0100 (CET) Received: (qmail 26865 invoked by uid 500); 7 Mar 2017 11:36:43 -0000 Mailing-List: contact dev-help@kafka.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@kafka.apache.org Delivered-To: mailing list dev@kafka.apache.org Received: (qmail 26837 invoked by uid 99); 7 Mar 2017 11:36:43 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Mar 2017 11:36:43 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id AF4881806A5 for ; Tue, 7 Mar 2017 11:36:42 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.547 X-Spam-Level: X-Spam-Status: No, score=-1.547 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-2.999, SPF_NEUTRAL=0.652] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 0F-uZ_c7u31e for ; Tue, 7 Mar 2017 11:36:41 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 7460B61E28 for ; Tue, 7 Mar 2017 11:36:41 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 1F75FE0AB0 for ; Tue, 7 Mar 2017 11:36:40 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 89CAB2418C for ; Tue, 7 Mar 2017 11:36:38 +0000 (UTC) Date: Tue, 7 Mar 2017 11:36:38 +0000 (UTC) From: "Dan (JIRA)" To: dev@kafka.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (KAFKA-4845) KafkaConsumer.seekToEnd cannot take effect when integrating with spark streaming MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 07 Mar 2017 11:36:45 -0000 [ https://issues.apache.org/jira/browse/KAFKA-4845?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15899299#comment-15899299 ] Dan commented on KAFKA-4845: ---------------------------- I checked 0.10.2.0 again and it was indeed fixed. Thanks a lot! > KafkaConsumer.seekToEnd cannot take effect when integrating with spark streaming > -------------------------------------------------------------------------------- > > Key: KAFKA-4845 > URL: https://issues.apache.org/jira/browse/KAFKA-4845 > Project: Kafka > Issue Type: Bug > Components: clients > Affects Versions: 0.10.1.0, 0.10.1.1, 0.10.2.0 > Reporter: Dan > Assignee: Vahid Hashemian > > When integrating with spark streaming, kafka consumer cannot get the latest offsets except for one partition. The code snippet is as follows: > {code} > protected def latestOffsets(): Map[TopicPartition, Long] = { > val c = consumer > c.poll(0) > val parts = c.assignment().asScala > val newPartitions = parts.diff(currentOffsets.keySet) > currentOffsets = currentOffsets ++ newPartitions.map(tp => tp -> c.position(tp)).toMap > c.pause(newPartitions.asJava) > c.seekToEnd(currentOffsets.keySet.asJava) > parts.map(tp => tp -> c.position(tp)).toMap > } > {code} > When calling consumer.position(topicPartition), it will call updateFetchPositions(Collections.singleton(partition)): > The bug lies in updateFetchPositions(Set partitions): > {code} > fetcher.resetOffsetsIfNeeded(partitions); // reset to latest offset for current partition > if (!subscriptions.hasAllFetchPositions()) { // called seekToEnd for all partitions before, so this sentence will be true > coordinator.refreshCommittedOffsetsIfNeeded(); > fetcher.updateFetchPositions(partitions); // reset to committed offsets for current partition > } > {code} > So eventually there is only one partition(the last partition in assignment) can get latest offset while all the others get the committed offset. -- This message was sent by Atlassian JIRA (v6.3.15#6346)