[ https://issues.apache.org/jira/browse/KAFKA-19434?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bill Bejeck updated KAFKA-19434: -------------------------------- Description: When starting a Kafka Streams instance, if it has pre-existing state, the state stores are initialized on the main thread. Part of this initialization registers the stateful metrics with the JMX thread-id tag of {{{}main{}}}. This breaks the KIP-1076 implementation where need to register metrics with thread-id tags of {{{}xxxStreamThread-N{}}}. This is necessary due to the fact that the {{StreamsMetric}} is a singleton shared by all {{StreamThread}} instances, so we need to make sure only add metrics for the current {{StreamThread}} otherwise duplicate metrics are registered. So the task is to move state store initialization to the point when the main thread hands the store over to the assigned `StreamThread` was: When starting a Kafka Streams instance, if it has pre-existing state, the state stores are initialized on the main thread. Part of this initialization registers the stateful metrics with the JMX thread-id tag of {{{}main{}}}. This breaks the KIP-1076 implementation where need to register metrics with thread-id tags of {{{}xxxStreamThread-N{}}}. This is necessary due to the fact that the {{StreamsMetric}} is a singleton shared by all {{StreamThread}} instances, so we need to make sure only add metrics for the current {{StreamThread}} otherwise duplicate metrics are registered. So the task is to move state store initialization to the point when the main thread hands the store over to the assigned `StreamThread` > Move logic for for state store initiation to StreamThread handover > ------------------------------------------------------------------ > > Key: KAFKA-19434 > URL: https://issues.apache.org/jira/browse/KAFKA-19434 > Project: Kafka > Issue Type: Task > Components: streams > Reporter: Bill Bejeck > Assignee: Bill Bejeck > Priority: Major > Fix For: 4.2.0 > > > When starting a Kafka Streams instance, if it has pre-existing state, the > state stores are initialized on the main thread. Part of this > initialization registers the stateful metrics with the JMX thread-id tag of > {{{}main{}}}. This breaks the KIP-1076 implementation where need to > register metrics with thread-id tags of {{{}xxxStreamThread-N{}}}. This is > necessary due to the fact that the {{StreamsMetric}} is a singleton shared > by all {{StreamThread}} instances, so we need to make sure only add metrics > for the current {{StreamThread}} otherwise duplicate metrics are > registered. So the task is to move state store initialization to the point > when the main thread hands the store over to the assigned `StreamThread` -- This message was sent by Atlassian Jira (v8.20.10#820010)