Apache Kafka - 重置上次看到的分区纪元。为什么?

FrV*_*aBe 9 apache-kafka kafka-producer-api

我们使用 Kafka Mirror Maker Version 1 在 Kafka 集群之间镜像数据。我知道 MM1 已被弃用,但它是一款可靠的软件,完全可以满足我们的需求。我们在专用的 Kafka 安装中使用它,该安装独立于我们存储数据的集群(目前正在运行 Kafka 2.6 版本)。

我们使用 Kafka 2.7.x 作为“MirrorMaker-Kafka”,最近将其更新到 3.3.1。从那时起,我们的MM日志中就有很多以下消息:

2022-12-01 15:07:45,368 INFO Metadata - [Producer clientId=*****] Resetting the last seen epoch of partition MyTopic-5 to 87 since the associated topicId changed from null to c59OzubzRAO-yhA72TSFEw
2022-12-01 15:12:45,373 INFO Metadata - [Producer clientId=*****] Resetting the last seen epoch of partition MyTopic-5 to 87 since the associated topicId changed from null to c59OzubzRAO-yhA72TSFEw
2022-12-01 15:22:45,388 INFO Metadata - [Producer clientId=*****] Resetting the last seen epoch of partition MyTopic-5 to 87 since the associated topicId changed from null to c59OzubzRAO-yhA72TSFEw
2022-12-01 15:37:45,394 INFO Metadata - [Producer clientId=*****] Resetting the last seen epoch of partition MyTopic-5 to 87 since the associated topicId changed from null to c59OzubzRAO-yhA72TSFEw
2022-12-01 15:42:45,398 INFO Metadata - [Producer clientId=*****] Resetting the last seen epoch of partition MyTopic-5 to 87 since the associated topicId changed from null to c59OzubzRAO-yhA72TSFEw
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,该消息每 5 分钟重复一次。我们镜像了数百个分区,并记录了许多(也许是所有)分区的消息。

据我所知,该消息是在此提交的KAFKA-12257修复中引入的。

不幸的是,我不清楚该消息的含义。以一定的间隔不断重复也让我感到好奇。可能我的(生产者)配置仍然存在弱点。

如果有人能解释这个现象并知道我可以采取哪些措施来改善它,我会非常高兴。

dan*_*ion 4

您看到的消息与 KAFKA-12257 修复相关,该修复是为了解决生产者客户端无法正确跟踪主题分区的纪元的问题而实现的。具体来说,该修复确保生产者客户端能够通过将唯一标识符(“topicId”)与其关联来跟踪分区的纪元。

在您的情况下,该消息每 5 分钟记录一次,因为生产者客户端将特定分区 (MyTopic-5) 的最后一次看到的纪元重置为 87,因为关联的 topicId 从 null 更改为 c59OzubzRAO-yhA72TSFEw。

为了确保生产者能够正确跟踪分区的纪元,您应该检查生产者配置并确保“topicId”设置正确。此外,您还应该确保生产者客户端配置为正确处理分区重新分配事件,因为这可能会导致 topicId 发生更改。

最后,如果您仍然遇到生产者客户端无法正确跟踪分区纪元的问题,您可能需要考虑升级到 Kafka Mirror Maker 的新版本,因为 MM1 现已弃用。

  • 感谢您的澄清。我只是想知道我(作为制作人)可以在哪里影响 topicId。在 Kafka 文档和 Producer API 中几乎没有任何关于“topicId”的内容。对我来说,它看起来像是一个我(作为 API 用户)没有接触过的内部概念。另外,每 5 分钟将最后一次看到的纪元从“null”重置为相同的 topicId 看起来很奇怪,因为 topicId 没有任何变化。对我来说这也不像 MM1 问题。仅使用常用的生产者 API。 (5认同)
  • 您能否详细说明“生产者配置并确保正确设置“topicId””,我已查看文档,但没有找到任何有关的信息:https://docs.confluence.io/platform/current/installation /configuration/ Producer-configs.html#client-id (5认同)