当所有消费者死亡时,卡夫卡(0.9.0.1)抵消消失

时间:2016-05-19 15:55:32

标签: apache-kafka kafka-consumer-api

据我从Kafka 0.9.0.1了解,偏移是在Kafka的主题中管理的。 奇怪的是,当消费者群体死亡时,从主题中删除偏移量。下次我从同一个consumerGroupId开始 - 偏移量从最早的时候开始重置。

这是预期的吗?即使消费者群体完全死亡,我希望抵消能够保持不变,并且当它重新开始时,它会从它停止的偏移处继续。

以下是consumer.config中的设置:

metric.reporters = []
metadata.max.age.ms = 300000
value.deserializer = classfk.el.client.mappers.kafka.KafkaDeserializer
group.id =testConsumerId
partition.assignment.strategy = [org.apache.kafka.clients.consumer.RangeAssignor]
reconnect.backoff.ms = 50
sasl.kerberos.ticket.renew.window.factor = 0.8
max.partition.fetch.bytes = 1048576
bootstrap.servers = [k1:9092]
retry.backoff.ms = 100
sasl.kerberos.kinit.cmd = /usr/bin/kinit
sasl.kerberos.service.name = null
sasl.kerberos.ticket.renew.jitter = 0.05
ssl.keystore.type = JKS
ssl.trustmanager.algorithm = PKIX
enable.auto.commit = false
ssl.key.password = null
fetch.max.wait.ms = 500
sasl.kerberos.min.time.before.relogin = 60000
connections.max.idle.ms = 540000
ssl.truststore.password = null
session.timeout.ms = 30000
metrics.num.samples = 2
client.id =testAppId1463671497716
ssl.endpoint.identification.algorithm = null
key.deserializer = classorg.apache.kafka.common.serialization.StringDeserializer
ssl.protocol = TLS
check.crcs = true
request.timeout.ms = 40000
ssl.provider = null
ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
ssl.keystore.location = null
heartbeat.interval.ms = 3000
auto.commit.interval.ms = 5000
receive.buffer.bytes = 32768
ssl.cipher.suites = null
ssl.truststore.type = JKS
security.protocol = PLAINTEXT
ssl.truststore.location = null
ssl.keystore.password = null
ssl.keymanager.algorithm = SunX509
metrics.sample.window.ms = 30000
fetch.min.bytes = 1
send.buffer.bytes = 131072
auto.offset.reset = earliest

我在日志中看到:

  

20:55:00.024 DEBUG o.a.k.c.c.i.AbstractCoordinator - 发布领导人   SyncGroup(SYNC_GROUP:   {GROUP_ID = testConsumerId,Gen​​eration ID的= 1,member_id = testAppId1463671497716-d1ce3669-b451-4197-a5dd-39dd38c61102,group_assignment = [{member_id = testAppId1463671497716-d1ce3669-b451-4197-a5dd-39dd38c61102,member_assignment = java.nio.HeapByteBuffer [POS = 0   lim = 36 cap = 36]}]})to coordinator 2147483647 20:55:00.379 DEBUG   o.a.k.c.c.i.AbstractCoordinator - 收到成功的同步组   组testConsumerId的响应:   {error_code = 0,member_assignment = java.nio.HeapByteBuffer [pos = 0 lim = 36   cap = 36]} 20:55:00.431 DEBUG o.a.k.c.c.i.ConsumerCoordinator - Setting   新分配的分区[sampleEntity-1,sampleEntity-0]   20:55:00.432 DEBUG o.a.k.c.c.i.ConsumerCoordinator - Fetching   为分区提交的偏移量:[sampleEntity-1,sampleEntity-0]   20:55:00.605 DEBUG o.a.k.c.c.i.ConsumerCoordinator - 没有承诺   分区sampleEntity-1 20:55:00.606的偏移量   o.a.k.c.consumer.internals.Fetcher - 重置分区的偏移量   sampleEntity-1到最早的偏移量。 20:55:00.732   o.a.k.c.consumer.internals.Fetcher - 获取分区的偏移量0   sampleEntity-1 20:55:00.732 o.a.k.c.consumer.internals.Fetcher -   将分区sampleEntity-0的偏移重置为已提交的偏移量   25

在服务器日志上,当消费者启动并死亡时[2016-05-19

  

16:09:50,113] INFO [GroupCoordinator 0]:准备重新稳定   group testConsumerId与老一代0   (kafka.coordinator.GroupCoordinator)[2016-05-19 16:09:50,114]信息   [GroupCoordinator 0]:稳定组testConsumerId第1代   (kafka.coordinator.GroupCoordinator)[2016-05-19 16:09:50,125]信息   [GroupCoordinator 0]:从组长带领的作业   第1代的testConsumerId(kafka.coordinator.GroupCoordinator)   [2016-05-19 16:09:50,158] TRACE [经纪人0上的组元数据管理器]:   获取组的偏移量Vector([sampleEntity,1],[sampleEntity,0])   testConsumerId。 (kafka.coordinator.GroupMetadataManager)[2016-05-19   16:10:3​​8,158] TRACE [GroupCoordinator 0]:会员   testAppId1463674187858-ea8c9c30-4c9d-4b52-bfef-44c299442d45 in group   testConsumerId失败了(kafka.coordinator.GroupCoordinator)   [2016-05-19 16:10:3​​8,158] INFO [GroupCoordinator 0]:准备   restabilize group testConsumerId with old generation 1   (kafka.coordinator.GroupCoordinator)[2016-05-19 16:10:3​​8,158] TRACE   [Broker 0上的Group Metadata Manager]:将testConsumerId标记为   删除。 (kafka.coordinator.GroupMetadataManager)[2016-05-19   16:10:3​​8,159] INFO [GroupCoordinator 0]:group testConsumerId   第1代已经死亡并被删除(kafka.coordinator.GroupCoordinator)

在它死亡并被删除后,我无法访问早期的偏移量。

1 个答案:

答案 0 :(得分:1)

实际上,事实证明正确记录了偏移量,只是分区太多而且大多数都是空的。当它们为空时,没有轮询,因此偏移不会被提交(例如,甚至为零),然后每次运行时 - 它们在日志中显示为“没有可用的偏移,因此使用RESET”。