Hi Vinay,

I tried this out as you suggested by setting metadata.max.age.ms = 40000 
(session.timeout.ms=30000)
I then ran my consumer with a batch of 25 messages where each message takes 4 
seconds to process and I call commitSync(offsets) after each message to ensure 
the heartbeat keeps the consumer alive.

For the messages before metadata.max.age.ms expired I see as expected that the 
commitSync also logs the heartbeat.

2016-04-27 09:45:11,267 DEBUG [pool-3-thread-2] 
org.apache.kafka.clients.consumer.internals.AbstractCoordinator: Received 
successful heartbeat response.
2016-04-27 09:45:11,270 DEBUG [pool-3-thread-2] 
org.apache.kafka.clients.consumer.internals.ConsumerCoordinator: Committed 
offset 184 for partition phil-pa-1-device-update-1

Then the automatic metadata refresh is logged.

2016-04-27 09:45:15,276 DEBUG [pool-3-thread-2] 
org.apache.kafka.clients.NetworkClient: Sending metadata request 
ClientRequest(expectResponse=true, callback=null, 
request=RequestSend(header={api_key=3,api_                    
version=0,correlation_id=29,client_id=consumer-3}, 
body={topics=[phil-pa-1-device-update]}), isInitiatedByNetworkClient, 
createdTimeMs=1461746715276, sendTimeMs=0) to node 0
2016-04-27 09:45:15,277 DEBUG [pool-3-thread-2] 
org.apache.kafka.clients.Metadata: Updated cluster metadata version 3 to 
Cluster(nodes = [Node(0, ta-eng-kafka2, 9092)], partitions = [Partition(topic = 
phil                    -pa-1-device-update, partition = 0, leader = 0, 
replicas = [0,], isr = [0,], Partition(topic = phil-pa-1-device-update, 
partition = 1, leader = 0, replicas = [0,], isr = [0,]])

The very next commitSync call succeeds but as you said does not peform the 
heartbeat - we don't get the log message"Received successful heartbeat 
response". But we only miss the heartbeat on that one message, on the 
commitSync calls that follow that we get the heartbeat back again.

2016-04-27 09:45:23,301 DEBUG [pool-3-thread-2] 
org.apache.kafka.clients.consumer.internals.AbstractCoordinator: Received 
successful heartbeat response.
2016-04-27 09:45:23,309 DEBUG [pool-3-thread-2] 
org.apache.kafka.clients.consumer.internals.ConsumerCoordinator: Committed 
offset 187 for partition phil-pa-1-device-update-1

After another 40 seconds we see the next metadata refresh request and the same 
thing happens again. The first commmitSync after the metadata request does not 
perform the heartbeat but the ones that follow that do. This means in our case 
we call commitSync often enough that the metadata request does not cause us an 
issue.

Thanks,
Phil Luckhurst


-----Original Message-----
From: vinay sharma [mailto:vinsharma.t...@gmail.com] 
Sent: 26 April 2016 17:29
To: users@kafka.apache.org
Subject: Re: Detecting rebalance while processing ConsumerRecords (0.9.0.1)

Hi Phil,

Config ConsumerConfig.METADATA_MAX_AGE_CONFIG has default 300000 ms. This 
config drives a mechanism where a proactive meta data refresh request is issued 
by consumer periodically. i have seen that i get log about successful heartbeat 
along with commit only before this request. once this request is issued then 
next successful heartbeat is only after next poll.
This will cause a rebalance and mark current consumer dead if there is no poll 
in next 30 seconds after meta refresh (where session time is 30
seconds.)

Regards,
Vinay

Reply via email to