kafka-python icon indicating copy to clipboard operation
kafka-python copied to clipboard

Kafka linux server power off restart ,consumer can't get message.

Open Ronniexie opened this issue 8 years ago • 8 comments

We use 1.4.3 version. How to solve this problem? Our problem is similar to this one, https://github.com/dpkp/kafka-python/issues/1477

Ronniexie avatar Dec 01 '18 02:12 Ronniexie

Have you tried 1.4.4?

On Fri, Nov 30, 2018, 6:35 PM Ronniexie <[email protected] wrote:

We use 1.4.3 version. How to solve this problem? Our problem is similar to this one, #1477 https://github.com/dpkp/kafka-python/issues/1477

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dpkp/kafka-python/issues/1664, or mute the thread https://github.com/notifications/unsubscribe-auth/AAzetGqGsvTeOat8bYjDETKz5yvYK9Gmks5u0ercgaJpZM4Y8q8J .

dpkp avatar Dec 01 '18 03:12 dpkp

When kafka's Linux server is powered off and restarted, it will reproduce this problem. consumer deadlock.it cannot join group;

consumer log: Marking the coordinator dead (node 3) for group test_group_id: Heartbeat session expired. Group coordinator for test_group_id is BrokerMetadata(nodeId=3, host=u'kafka', port=9092, rack=None) Discovered coordinator 3 for group test_group_id <BrokerConnection node_id=3 host=kafka:9092 [IPv4 ('', 9092)]>: Error receiving network data closing socket <BrokerConnection node_id=3 host=kafka:9092 [IPv4 ('', 9092)]>: Closing connection. ConnectionError: [Errno 104] Connection reset by peer Node 3 connection failed -- refreshing metadata Fetch to node 3 failed: ConnectionError: [Errno 104] Connection reset by peer Error sending HeartbeatRequest_v1 to node 3 [ConnectionError: [Errno 104] Connection reset by peer]

I use kafka-consumer-groups.sh check groupId. Note: This will not show information about old Zookeeper-based consumers. Consumer group 'test_group_id' has no active members. TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID kafka-test 1 3610957 5215901 1604944 - - - kafka-test 0 3605160 5210503 1605343 - - - kafka-test 2 3607305 5217421 1610116 - - -

Ronniexie avatar Dec 04 '18 14:12 Ronniexie

This problem only occurs in python kafka sdk. Logstash get kafka massage is ok.

Ronniexie avatar Dec 04 '18 14:12 Ronniexie

It is deadlock Code.“self._pending_completion.extend(conn.recv()) ”

if not conn.in_flight_requests:
            # if we got an EVENT_READ but there were no in-flight requests, one of
            # two things has happened:
            #
            # 1. The remote end closed the connection (because it died, or because
            #    a firewall timed out, or whatever)
            # 2. The protocol is out of sync.
            #
            # either way, we can no longer safely use this connection
            #
            # Do a 1-byte read to check protocol didnt get out of sync, and then close the conn
            try:
                unexpected_data = key.fileobj.recv(1)
                if unexpected_data:  # anything other than a 0-byte read means protocol issues
                    log.warning('Protocol out of sync on %r, closing', conn)
            except socket.error:
                pass
            conn.close(Errors.ConnectionError('Socket EVENT_READ without in-flight-requests'))
            continue
        self._idle_expiry_manager.update(conn.node_id)
        self._pending_completion.extend(conn.recv())

Ronniexie avatar Dec 07 '18 14:12 Ronniexie

log: <BrokerConnection node_id=2 host=kafka-2:9092 [IPv4 ('', 9092)]>: Error receiving network data closing socket <BrokerConnection node_id=2 host=kafka-2:9092 [IPv4 ('', 9092)]>: Closing connection. ConnectionError: [Errno 104] Connection reset by peer Node 2 connection failed -- refreshing metadata <BrokerConnection node_id=2 host=kafka-2:9092 [IPv4 ('', 9092)]>: reconnect backoff 0.0439208678617 after 1 failures Fetch to node 2 failed: ConnectionError: [Errno 104] Connection reset by peer Error sending HeartbeatRequest_v1 to node 2 [ConnectionError: [Errno 104] Connection reset by peer]

Ronniexie avatar Dec 08 '18 01:12 Ronniexie

Have you tried 1.4.4? … On Fri, Nov 30, 2018, 6:35 PM Ronniexie @.*** wrote: We use 1.4.3 version. How to solve this problem? Our problem is similar to this one, #1477 <#1477> — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#1664>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAzetGqGsvTeOat8bYjDETKz5yvYK9Gmks5u0ercgaJpZM4Y8q8J .

It is no good,when I use 1.4.4.

Ronniexie avatar Dec 08 '18 03:12 Ronniexie

Can you try this with 2.0.0? There have been a lot of changes since even 1.4.4 to cleanup connection handling, and those may fix this.

jeffwidman avatar Feb 12 '20 20:02 jeffwidman

I believe this is fixed in latest release(s)

dpkp avatar Feb 14 '25 23:02 dpkp