Status
Current state: Under Discussion
Discussion thread: TBD
JIRA: - KAFKA-8285Getting issue details... STATUS
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Motivation
As we are rolling out static membership for general Kafka client applications, we need to have persistent `group.instance.id` throughout restarts. One of the edge case is that we are currently using shared static integer field for thread-id incrementation for multiple stream instances on one single JVM. So it is very easily to fall into this example scenario with two stream instance A, B:
Instance A init one stream thread → Instance A init one stream thread → Instance B init one stream thread → Instance B init one stream thread
So instance ids being generated when two instances starts are : A-1, A-2, B-3, B-4
During one bounce, the order of initialization could change to:
Instance A init one stream thread → Instance B init one stream thread → Instance A init one stream thread → Instance B init one stream thread
And then change instance ids to : A-1, A-3, B-2, B-4
This means we are creating 4 new instance ids compared with previous round, so broker could no longer leverage the static information it stored. Basically, the scenario invalidates static membership effectiveness.
Proposed Changes
Each stream instance will use local counter to create stream thread name. So the above example will be always generating instance ids as: A-1, A-2, B-1, B-2. By persisting instance ids generation, the static membership will still behave as expected when we configure > 1 stream instances in one JVM.
Public Interfaces
This change is internal, however it will affect KStream external information exposure. See next section.
Compatibility, Deprecation, and Migration Plan
- There is no anticipated negative impact. The thread-id is used to construct many stream component identifiers such as producer/consumer/stream thread names. If user exposes these information in their production environment, upgraded service may see different composed ids from previous round. Note that this only applies to multi-instance one JVM scenario and only one time, thus not going to globally affect things too much in general.
Rejected Alternatives
N/A