[
https://issues.apache.org/jira/browse/KAFKA-21557?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andras Katona updated KAFKA-21557:
----------------------------------
Summary: Connect continues without its internal topic when it can't create
it (was: Connect internal topics can be auto-created by the broker with the
wrong cleanup policy)
> Connect continues without its internal topic when it can't create it
> --------------------------------------------------------------------
>
> Key: KAFKA-21557
> URL: https://issues.apache.org/jira/browse/KAFKA-21557
> Project: Kafka
> Issue Type: Bug
> Components: connect
> Reporter: Andras Katona
> Assignee: Andras Katona
> Priority: Major
>
> When a Connect worker starts, it tries to create its internal topics (config,
> offsets, status) with {{cleanup.policy=compact}}. If CreateTopics fails with
> an authorization error, {{TopicAdmin}} logs it at DEBUG and Connect carries
> on, assuming the topic exists or will be auto-created.
> If the topic doesn't exist, {{KafkaBasedLog.start()}} then calls
> {{consumer.partitionsFor(topic)}} for up to 30s. The internal consumer uses
> the default {{allow.auto.create.topics=true}}, so with
> {{auto.create.topics.enable=true}} on the broker this metadata request can
> create the topic with the broker's defaults, usually
> {{cleanup.policy=delete}} and {{num.partitions=1}}.
> The cleanup policy check doesn't catch this on the worker that triggered the
> auto-create: it runs before the topic exists, finds no config, and only logs
> at INFO. That worker keeps running on a non-compacted topic, and retention
> can delete its data, such as source offsets. Every other worker then fails at
> startup with:
> {noformat}
> ConfigException: Topic '...' supplied via the 'offset.storage.topic' property
> is required to have 'cleanup.policy=compact' ... but found the topic
> currently has 'cleanup.policy=delete'.
> {noformat}
> *When it happens:* CREATE is checked on the active controller for Connect's
> CreateTopics, but on the broker first (then on the controller) for an
> auto-create. If the broker denies, the consumer gets
> {{TOPIC_AUTHORIZATION_FAILED}} and the worker fails cleanly. The topic is
> auto-created only if the controller denies Connect's CreateTopics, the broker
> already allows CREATE, and the controller starts allowing it within the 30s
> retry loop. We hit this with an authorizer whose nodes load their policies
> independently at startup, so the active controller was the last to allow.
> With {{StandardAuthorizer}} it's hard to reproduce, because the controller
> applies ACL changes before the brokers. It can be reproduced by making the
> Connect principal a super user on the brokers only and adding a CREATE ACL
> while the worker is starting.
> The connector-specific offsets topics (KIP-618) have the same problem.
> *Fix:*
> # If a missing internal topic can't be created, check whether it exists; if
> it doesn't, retry the creation until {{default.api.timeout.ms}}, then fail
> with a clear error ({{KafkaTopicBasedBackingStore}}). Setups where the topic
> is created manually and the worker has no CREATE permission keep working as
> before.
> # Set {{allow.auto.create.topics=false}} on the consumers of Connect's
> internal topics, so the broker can never create them with its defaults
> ({{KafkaBasedLog.createConsumer()}};
> {{Worker.regularSourceOffsetsConsumerConfigs}} and
> {{Worker.exactlyOnceSourceOffsetsConsumerConfigs}} for connector-specific
> offsets topics).
> MirrorMaker 2 in dedicated mode uses the same backing stores for its
> {{mm2-*.internal}} topics, so this likely causes KAFKA-13465, KAFKA-17101,
> KAFKA-17784 and KAFKA-19046.
> *Not covered:* MM2's connector-level topics (offset-syncs, checkpoints,
> heartbeats) are created by {{MirrorUtils.createCompactedTopic}}, which has
> the same fallback, and are read by consumers with the same default. This can
> be a follow-up.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)