sjhajharia opened a new pull request, #22714: URL: https://github.com/apache/kafka/pull/22714
### Summary When a share group heartbeat detects subscribed-but-uninitialized topic-partitions, the group coordinator builds an `InitializeShareGroupStateParameters` request. Previously it sent `startOffset = -1` (`PartitionFactory.UNINITIALIZED_START_OFFSET`) for *every* partition. `-1` is a sentinel meaning "not yet decided": `SharePartition.startOffsetDuringInitialization()` resolves the real offset from the group's `share.auto.offset.reset` strategy (default `LATEST`). This is correct for a brand-new topic subscription, but incorrect when **new partitions are added to a topic the group already knows about**. Resolving those new partitions via `LATEST` can skip records produced before initialization completes, causing data loss. This change makes newly initialized partitions of an **already-known topic** (present in the group's `initializedTopics` or `initializingTopics`) start at offset `0`, guaranteeing no records are missed. Partitions of a topic seen for the first time keep `-1` so that `share.auto.offset.reset` still applies to fresh subscriptions. ### Change In `GroupMetadataManager`: - `maybeCreateInitializeShareGroupStateRequest` computes the set of already-known topics (`initializedTopics ∪ initializingTopics`) from the current persisted metadata. This is read before the heartbeat's records are replayed, so a brand-new topic is correctly absent. - `buildInitializeShareGroupStateRequest` selects the start offset per topic: `0` for an already-known topic, `-1` for a first-sighting topic. ### Testing - Added `testShareGroupHeartbeatInitializeMixedNewAndExpandedTopics`: a single heartbeat that both adds a brand-new topic and expands an already-initialized topic produces one request where the new topic uses `-1` and the expanded topic's new partitions use `0` — verifying the decision is per-topic, not per-request. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
