[ 
https://issues.apache.org/jira/browse/KAFKA-21604?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

jiwook choi reassigned KAFKA-21604:
-----------------------------------

    Assignee: jiwook choi

> Improved changelog config documentation
> ---------------------------------------
>
>                 Key: KAFKA-21604
>                 URL: https://issues.apache.org/jira/browse/KAFKA-21604
>             Project: Kafka
>          Issue Type: Improvement
>          Components: docs, streams
>            Reporter: Matthias J. Sax
>            Assignee: jiwook choi
>            Priority: Minor
>
> TLDR: Global topic.* configs do not override retention.ms for windowed 
> changelog topics or min.compaction.lag.ms for versioned changelog topics. We 
> should document this explicitly.
> Long version:
> Internal topic configs are merged in three layers: type defaults < global 
> topic.* configs < per-store configs (withLoggingEnabled(Map)). This is stated 
> in the code comment in each InternalTopicConfig#properties() and in the docs 
> ("Override default for both changelog and repartition topics", 
> config-streams.md).
> Two values do not follow this rule:
>  * windowed changelog: retention.ms = store retention + 
> windowstore.changelog.additional.retention.ms
>  * versioned changelog: min.compaction.lag.ms = history retention + 24h 
> (hard-coded)
> Both are written _after_ the merge, unless the _per-store_ map contains the 
> key. A global topic.retention.ms / topic.min.compaction.lag.ms is overwritten 
> without any message.
>  
> {code:java}
> // WindowedChangelogTopicConfig#properties()
> topicConfig.putAll(defaultProperties);   // global topic.*
> topicConfig.putAll(topicConfigs);        // per-store
> if (!topicConfigs.containsKey(TopicConfig.RETENTION_MS_CONFIG)) {  // checks 
> per-store map only
>     topicConfig.put(TopicConfig.RETENTION_MS_CONFIG, ...);          // 
> overwrites global value
> }
> {code}
> VersionedChangelogTopicConfig#properties() does the same for 
> min.compaction.lag.ms.
>  
> A per-store value replaces the derived value as given, with no additional 
> retention or compaction lag added.
> This applies to both group.protocol=classic and group.protocol=streams: the 
> merge happens on the client for both.
> The behavior itself is reasonable: a single global value cannot fit stores 
> with different retention periods, and a value that is too small loses data 
> when the store restores. But it is not documented, and the code comment 
> states the opposite.
> Suggested fix:
>  * Document the exception (docs + topic.* prefix Javadoc), and correct the 
> code comments.
>  * Log a WARN when a global topic.retention.ms / topic.min.compaction.lag.ms 
> is ignored for a store.
>  * Extend test coverage for these case in InternalTopicConfigTest
> *Side finding:* VersionedKeyValueStoreIntegrationTest sets 
> TopicConfig.MIN_COMPACTION_LAG_MS_CONFIG _without_ the topic. prefix. The 
> comment there says it is meant to "prevent premature compaction ... while 
> using timestamped store". But both places that read topic configs 
> (StreamThread.java:745, InternalTopicManager.java:119) only use 
> originalsWithPrefix(TOPIC_PREFIX), so the setting never reaches the changelog.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to