Skip to content

Conversation

arvi18
Copy link

@arvi18 arvi18 commented Apr 21, 2025

When fetching stable offsets in the group coordinator, we iterate over
all requested partitions. For each partition, we iterate over the
group's ongoing transactions to check if there is a pending
transactional offset commit for that partition.

This can get slow when there are a large number of partitions and a
large number of pending transactions. Instead, maintain a list of
pending transactions per partition to speed up lookups.

Summary by CodeRabbit

  • New Features

    • More granular tracking of open transactions by group, topic, and partition.
  • Bug Fixes

    • More accurate deletion and detection of pending transactional offsets to avoid leaving stale offsets.
  • Performance

    • Improved handling of transactional offset commits and transaction completion, reducing overhead in multi-topic/partition scenarios.

When fetching stable offsets in the group coordinator, we iterate over
all requested partitions. For each partition, we iterate over the
group's ongoing transactions to check if there is a pending
transactional offset commit for that partition.

This can get slow when there are a large number of partitions and a
large number of pending transactions. Instead, maintain a list of
pending transactions per partition to speed up lookups.
@arvi18
Copy link
Author

arvi18 commented Apr 21, 2025

@squah-confluent Thanks for the patch. Could we write a micro benchmark to demonstrate the gain?

Copy link

coderabbitai bot commented Apr 21, 2025

Walkthrough

Added a nested timeline map in OffsetMetadataManager to track open transactional producerIds by group → topic → partition, and updated offset deletion, pending-offset checks, replay, and transaction-completion logic to maintain and prune this structure alongside existing group-level tracking. (47 words)

Changes

Cohort / File(s) Change Summary
Offset metadata manager
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java
Added openTransactionsByGroupTopicAndPartition (TimelineHashMap<String, TimelineHashMap<String, TimelineHashMap<Integer, TimelineHashSet>>>); initialized it; updated deleteAllOffsets, hasPendingTransactionalOffsets, replay, replayEndTransactionMarker and tombstone handling to update/prune the nested map; added @SuppressWarnings("NPathComplexity").

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant OffsetMetadataManager
    participant Storage

    Client->>OffsetMetadataManager: Commit transactional offset (group,topic,partition,producerId)
    Note right of OffsetMetadataManager: record producerId in\nopenTransactionsByGroup and\nopenTransactionsByGroupTopicAndPartition
    OffsetMetadataManager->>Storage: append transactional offset record

    Client->>OffsetMetadataManager: DeleteAllOffsets (group)
    OffsetMetadataManager->>OffsetMetadataManager: iterate nested map for group\n( topic -> partition -> producerIds )
    OffsetMetadataManager->>Storage: emit tombstone if no committed offset

    Client->>OffsetMetadataManager: Replay offset commit / tombstone
    OffsetMetadataManager->>OffsetMetadataManager: update nested maps or remove producerId\nand prune empty maps

    Client->>OffsetMetadataManager: EndTransaction (producerId)
    OffsetMetadataManager->>OffsetMetadataManager: remove producerId from group set\nand group→topic→partition nested map, prune empties
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

In a burrow of maps I quietly hop,
Group, topic, partition — each has its spot.
I tuck in producerIds, prune what’s not right,
Replay, delete, tidy — snug through the night.
Hooray for small maps that keep offsets tight! 🥕

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch clone-squah-improve-stable-offset-fetch-performance

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java (3)

290-292: Consider initial capacity hint

While the new map is created with default capacity, we already know the upper bound equals the number of groups in the shard.
Passing an estimated initial capacity (e.g. new TimelineHashMap<>(snapshotRegistry, expectedGroupCount)) would avoid internal re‑hashing during warm‑up and complement the performance goal.


690-699: Minor micro‑optimisation opportunity

hasPendingTransactionalOffsets currently performs two nested look‑ups even when the group isn’t present.
Inlining the fast‑fail path keeps the common case cheap:

TimelineHashMap<String, TimelineHashMap<Integer, TimelineHashSet<Long>>> topics =
        openTransactionsByGroupTopicAndPartition.get(groupId);
if (topics == null) return false;
TimelineHashMap<Integer, TimelineHashSet<Long>> partitions = topics.get(topic);
return partitions != null && !partitions.getOrDefault(partition, TimelineHashSet.empty()).isEmpty();

Not critical, but consistent with the goal of shaving latency off hot paths.


1008-1012: Helper method could improve readability & symmetry

The three‑level computeIfAbsent chain is repeated in multiple places (here, plus future writes).
Encapsulating it in a private addOpenTransaction(groupId, topic, partition, producerId) helper removes duplication and lowers the cognitive load for future maintainers.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed79212 and ba872aa.

📒 Files selected for processing (1)
  • group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java (7 hunks)
🔇 Additional comments (2)
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java (2)

201-205: 👍 Valuable fine‑grained tracking added

Introducing openTransactionsByGroupTopicAndPartition is a solid design choice that avoids repeatedly scanning every producer of a group when we only care about a single partition.
This lays the groundwork for the performance win described in the PR objective.


1067-1100: Edge‑case: stale openTransactionsByGroup entry

replayEndTransactionMarker correctly removes a producer‑id from both structures, but replay’s tombstone path (lines 1020‑1041) updates only the partition‑level map.
If that tombstone happens to clear the last pending offset for the producer, the group‑level set will still contain an orphaned producer id until the transaction eventually ends.
This can postpone group cleanup via cleanupExpiredOffsets.

If intentional, a comment explaining the lifecycle would help; otherwise consider synchronising removals in both places.

Comment on lines +661 to 674
TimelineHashMap<String, TimelineHashMap<Integer, TimelineHashSet<Long>>> openTransactionsByTopic =
openTransactionsByGroupTopicAndPartition.get(groupId);
if (openTransactionsByTopic != null) {
openTransactionsByTopic.forEach((topic, openTransactionsByPartition) -> {
openTransactionsByPartition.forEach((partition, producerIds) -> {
producerIds.forEach(producerId -> {
if (!hasCommittedOffset(groupId, topic, partition)) {
records.add(GroupCoordinatorRecordHelpers.newOffsetCommitTombstoneRecord(groupId, topic, partition));
numDeletedOffsets.getAndIncrement();
}
});
});
});
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Duplicate tombstones may be emitted for the same partition

producerIds.forEach(...) iterates once per producer id, potentially adding the same tombstone several times when multiple producers have pending offsets for the identical <group, topic, partition>.
This inflates records and over‑counts numDeletedOffsets, causing needless log traffic and skewed metrics.

- openTransactionsByPartition.forEach((partition, producerIds) -> {
-     producerIds.forEach(producerId -> {
-         if (!hasCommittedOffset(groupId, topic, partition)) {
-             records.add(GroupCoordinatorRecordHelpers
-                 .newOffsetCommitTombstoneRecord(groupId, topic, partition));
-             numDeletedOffsets.getAndIncrement();
-         }
-     });
- });
+ openTransactionsByPartition.keySet().forEach(partition -> {
+     if (!hasCommittedOffset(groupId, topic, partition)) {
+         records.add(GroupCoordinatorRecordHelpers
+             .newOffsetCommitTombstoneRecord(groupId, topic, partition));
+         numDeletedOffsets.getAndIncrement();
+     }
+ });

This preserves the original semantics while guaranteeing a single tombstone per partition.

@visz11
Copy link
Collaborator

visz11 commented Apr 24, 2025

/gemini review

Copy link

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@visz11
Copy link
Collaborator

visz11 commented Apr 24, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a performance improvement for fetching stable offsets by maintaining a list of pending transactions per partition. The changes seem well-structured and address the identified bottleneck. However, some areas could benefit from further clarification and potential optimization.

Summary of Findings

  • Missing null check: In replayEndTransactionMarker, there's a potential null pointer exception if openTransactionsByTopic is null after removing a topic. A null check before proceeding with further operations would enhance robustness.
  • Potential memory leak: In replay, when removing pending offset commits, the code removes partitions and topics from openTransactionsByGroupTopicAndPartition. However, it's crucial to ensure that the Offsets object associated with pendingTransactionalOffsets is also cleaned up to prevent a potential memory leak.

Merge Readiness

The pull request introduces a significant performance improvement and appears to be well-structured. However, the potential null pointer exception and memory leak should be addressed before merging. I am unable to approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity issues should be addressed before merging.

@atharvsabdeai
Copy link

testing

@arvi18
Copy link
Author

arvi18 commented Sep 2, 2025

/refacto-test

Copy link

refacto-test bot commented Sep 2, 2025

Refacto is reviewing this PR. Please wait for the review comments to be posted.

@arvi18
Copy link
Author

arvi18 commented Sep 2, 2025

@coderabbitai full review

Copy link

coderabbitai bot commented Sep 2, 2025

✅ Actions performed

Full review triggered.

Copy link

refacto-test bot commented Sep 2, 2025

Code Review: Offset Tracking Implementation

👍 Well Done
Performance Optimization

Added efficient offset tracking structure improves system reliability under load.

Memory Management

Proper cleanup of transaction resources prevents memory leaks.

Clear Documentation

Added comments explain purpose of new data structure and implementation details.

📌 Files Processed
  • group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java
📝 Additional Comments
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java (6)
Nested Data Structure Cleanup

The nested cleanup logic creates unnecessary map traversals when removing empty collections. Consider extracting this cleanup pattern into a helper method since it's repeated in multiple places (also at lines 1090-1096). This would improve code maintainability and ensure consistent cleanup behavior across the codebase.

Standards:

  • ISO-IEC-25010-Performance-Maintainability
  • Algorithm-Opt-Code-Reuse
Inconsistent Data Structures

Data structure synchronization between openTransactionsByGroup and openTransactionsByGroupTopicAndPartition relies on manual maintenance. Inconsistency risk if one structure is updated without the other during error conditions.

Standards:

  • ISO-IEC-25010-Reliability-Maturity
  • ISO-IEC-25010-Functional-Correctness-Appropriateness
Complex Cleanup Logic

Deeply nested cleanup logic with multiple conditional checks increases code complexity. Future maintenance could introduce reliability issues through incomplete cleanup or race conditions in transaction management.

Standards:

  • ISO-IEC-25010-Reliability-Maturity
  • ISO-IEC-25010-Maintainability-Modifiability
Redundant Data Structure

The openTransactionsByGroup data structure is partially redundant with openTransactionsByGroupTopicAndPartition. While both serve different purposes, the code doesn't maintain perfect consistency between them, potentially leading to data discrepancies.

Standards:

  • Algorithm-Correctness-Data-Structure
  • Logic-Verification-Redundancy
  • Design-Consistency
Complex Nested Maps

Triple-nested map structure creates cognitive complexity and makes traversal operations verbose. While the structure improves lookup performance, it increases code complexity when accessing or modifying nested values.

Standards:

  • Clean-Code-Simplicity
  • Design-Pattern-Composite
Potential Race Condition

Nested forEach operations with side effects may create race conditions during concurrent execution. Multiple threads could simultaneously evaluate the condition and add tombstone records, potentially causing duplicate records or inconsistent state.

Standards:

  • CWE-362
  • OWASP-A10

Comment on lines +1033 to +1040

openTransactionsByPartition.remove(partition);
if (openTransactionsByPartition.isEmpty()) {
openTransactionsByTopic.remove(topic);
}
if (openTransactionsByTopic.isEmpty()) {
openTransactionsByGroupTopicAndPartition.remove(groupId);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete Resource Cleanup

Nested resource cleanup doesn't check if openTransactionsByPartition exists before removing. If null, NullPointerException could occur during transaction completion, potentially causing transaction processing failures.

Standards
  • ISO-IEC-25010-Reliability-Fault-Tolerance
  • ISO-IEC-25010-Functional-Correctness-Appropriateness
  • DbC-Resource-Mgmt

Comment on lines +1034 to 1041
openTransactionsByPartition.remove(partition);
if (openTransactionsByPartition.isEmpty()) {
openTransactionsByTopic.remove(topic);
}
if (openTransactionsByTopic.isEmpty()) {
openTransactionsByGroupTopicAndPartition.remove(groupId);
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete Transaction Cleanup

The cleanup logic removes entries from openTransactionsByGroupTopicAndPartition but fails to check if the producer still has other pending offsets before removing it from openTransactionsByGroup. This can leave stale entries in openTransactionsByGroup causing memory leaks.

Standards
  • Logic-Verification-Completeness
  • Algorithm-Correctness-Resource-Management
  • Business-Rule-Consistency

Comment on lines +1020 to +1042
TimelineHashMap<String, TimelineHashMap<Integer, TimelineHashSet<Long>>> openTransactionsByTopic =
openTransactionsByGroupTopicAndPartition.get(groupId);
if (openTransactionsByTopic != null) {
TimelineHashMap<Integer, TimelineHashSet<Long>> openTransactionsByPartition = openTransactionsByTopic.get(topic);
if (openTransactionsByPartition != null) {
TimelineHashSet<Long> openTransactions = openTransactionsByPartition.get(partition);
if (openTransactions != null) {
openTransactions.forEach(openProducerId -> {
Offsets pendingOffsets = pendingTransactionalOffsets.get(openProducerId);
if (pendingOffsets != null) {
pendingOffsets.remove(groupId, topic, partition);
}
});

openTransactionsByPartition.remove(partition);
if (openTransactionsByPartition.isEmpty()) {
openTransactionsByTopic.remove(topic);
}
if (openTransactionsByTopic.isEmpty()) {
openTransactionsByGroupTopicAndPartition.remove(groupId);
}
}
});
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate Code Paths

Similar nested map traversal and cleanup logic appears multiple times in the code. This duplication increases maintenance burden as any change to the cleanup logic must be applied consistently across all occurrences.

Standards
  • Clean-Code-DRY
  • Design-Pattern-Extract-Method

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java (1)

661-674: Duplicate tombstones may be emitted for the same partition.

producerIds.forEach(...) iterates once per producer id, potentially adding the same tombstone several times when multiple producers have pending offsets for the identical <group, topic, partition>.
This inflates records and over‑counts numDeletedOffsets, causing needless log traffic and skewed metrics.

Apply this diff to ensure a single tombstone per partition:

-                openTransactionsByPartition.forEach((partition, producerIds) -> {
-                    producerIds.forEach(producerId -> {
-                        if (!hasCommittedOffset(groupId, topic, partition)) {
-                            records.add(GroupCoordinatorRecordHelpers.newOffsetCommitTombstoneRecord(groupId, topic, partition));
-                            numDeletedOffsets.getAndIncrement();
-                        }
-                    });
-                });
+                openTransactionsByPartition.keySet().forEach(partition -> {
+                    if (!hasCommittedOffset(groupId, topic, partition)) {
+                        records.add(GroupCoordinatorRecordHelpers.newOffsetCommitTombstoneRecord(groupId, topic, partition));
+                        numDeletedOffsets.getAndIncrement();
+                    }
+                });
🧹 Nitpick comments (3)
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java (3)

197-197: Improve documentation clarity.

Consider making the comment more explicit about what "whether groups have any open transactions" means in this context.

-     * Tracks whether groups have any open transactions.
+     * Tracks groups that have pending transactional offsets.

1020-1043: Consider refactoring for better readability.

The nested conditionals for pruning empty maps can be simplified using a helper method.

Consider extracting the pruning logic to a helper method:

+    private void pruneEmptyPartitionMaps(String groupId, String topic, int partition) {
+        TimelineHashMap<String, TimelineHashMap<Integer, TimelineHashSet<Long>>> openTransactionsByTopic =
+            openTransactionsByGroupTopicAndPartition.get(groupId);
+        if (openTransactionsByTopic == null) return;
+        
+        TimelineHashMap<Integer, TimelineHashSet<Long>> openTransactionsByPartition = openTransactionsByTopic.get(topic);
+        if (openTransactionsByPartition == null) return;
+        
+        openTransactionsByPartition.remove(partition);
+        if (openTransactionsByPartition.isEmpty()) {
+            openTransactionsByTopic.remove(topic);
+        }
+        if (openTransactionsByTopic.isEmpty()) {
+            openTransactionsByGroupTopicAndPartition.remove(groupId);
+        }
+    }

             // Remove all the pending offset commits related to the tombstone.
             TimelineHashMap<String, TimelineHashMap<Integer, TimelineHashSet<Long>>> openTransactionsByTopic =
                 openTransactionsByGroupTopicAndPartition.get(groupId);
             if (openTransactionsByTopic != null) {
                 TimelineHashMap<Integer, TimelineHashSet<Long>> openTransactionsByPartition = openTransactionsByTopic.get(topic);
                 if (openTransactionsByPartition != null) {
                     TimelineHashSet<Long> openTransactions = openTransactionsByPartition.get(partition);
                     if (openTransactions != null) {
                         openTransactions.forEach(openProducerId -> {
                             Offsets pendingOffsets = pendingTransactionalOffsets.get(openProducerId);
                             if (pendingOffsets != null) {
                                 pendingOffsets.remove(groupId, topic, partition);
                             }
                         });
-
-                        openTransactionsByPartition.remove(partition);
-                        if (openTransactionsByPartition.isEmpty()) {
-                            openTransactionsByTopic.remove(topic);
-                        }
-                        if (openTransactionsByTopic.isEmpty()) {
-                            openTransactionsByGroupTopicAndPartition.remove(groupId);
-                        }
+                        pruneEmptyPartitionMaps(groupId, topic, partition);
                     }
                 }
             }

1067-1099: Good implementation, but consider extracting complexity.

The logic correctly maintains consistency between both tracking structures, but the deeply nested loops make the code hard to follow.

Consider extracting the partition-level cleanup into a helper method:

+    private void removeProducerFromPartitionTracking(String groupId, Long producerId, 
+                                                     TimelineHashMap<String, TimelineHashMap<Integer, OffsetAndMetadata>> topicOffsets) {
+        TimelineHashMap<String, TimelineHashMap<Integer, TimelineHashSet<Long>>> openTransactionsByTopic =
+            openTransactionsByGroupTopicAndPartition.get(groupId);
+        if (openTransactionsByTopic == null) return;
+
+        topicOffsets.forEach((topic, partitionOffsets) -> {
+            TimelineHashMap<Integer, TimelineHashSet<Long>> openTransactionsByPartition = openTransactionsByTopic.get(topic);
+            if (openTransactionsByPartition == null) return;
+
+            partitionOffsets.keySet().forEach(partitionId -> {
+                TimelineHashSet<Long> partitionTransactions = openTransactionsByPartition.get(partitionId);
+                if (partitionTransactions != null) {
+                    partitionTransactions.remove(producerId);
+                    if (partitionTransactions.isEmpty()) {
+                        openTransactionsByPartition.remove(partitionId);
+                    }
+                    if (openTransactionsByPartition.isEmpty()) {
+                        openTransactionsByTopic.remove(topic);
+                    }
+                    if (openTransactionsByTopic.isEmpty()) {
+                        openTransactionsByGroupTopicAndPartition.remove(groupId);
+                    }
+                }
+            });
+        });
+    }

         pendingOffsets.offsetsByGroup.forEach((groupId, topicOffsets) -> {
             TimelineHashSet<Long> groupTransactions = openTransactionsByGroup.get(groupId);
             if (groupTransactions != null) {
                 groupTransactions.remove(producerId);
                 if (groupTransactions.isEmpty()) {
                     openTransactionsByGroup.remove(groupId);
                 }
             }
 
-            TimelineHashMap<String, TimelineHashMap<Integer, TimelineHashSet<Long>>> openTransactionsByTopic =
-                openTransactionsByGroupTopicAndPartition.get(groupId);
-            if (openTransactionsByTopic == null) return;
-
-            topicOffsets.forEach((topic, partitionOffsets) -> {
-                TimelineHashMap<Integer, TimelineHashSet<Long>> openTransactionsByPartition = openTransactionsByTopic.get(topic);
-                if (openTransactionsByPartition == null) return;
-
-                partitionOffsets.keySet().forEach(partitionId -> {
-                    TimelineHashSet<Long> partitionTransactions = openTransactionsByPartition.get(partitionId);
-                    if (partitionTransactions != null) {
-                        partitionTransactions.remove(producerId);
-                        if (partitionTransactions.isEmpty()) {
-                            openTransactionsByPartition.remove(partitionId);
-                        }
-                        if (openTransactionsByPartition.isEmpty()) {
-                            openTransactionsByTopic.remove(topic);
-                        }
-                        if (openTransactionsByTopic.isEmpty()) {
-                            openTransactionsByGroupTopicAndPartition.remove(groupId);
-                        }
-                    }
-                });
-            });
+            removeProducerFromPartitionTracking(groupId, producerId, topicOffsets);
         });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ed79212 and 463632a.

📒 Files selected for processing (1)
  • group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java (8 hunks)
🔇 Additional comments (5)
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java (5)

9-9: LGTM!

The URL fix is correct.


201-206: LGTM!

Good implementation. The nested map structure efficiently tracks open transactions at the partition level, which directly addresses the performance issue described in the PR.


685-699: LGTM!

Good implementation using the new nested map for efficient partition-level lookups. This is the key improvement that resolves the performance issue by avoiding iteration over all group transactions.


1008-1012: LGTM!

Correct implementation of updating both the group-level and partition-level tracking structures when replaying transactional offset commits.


1054-1054: LGTM!

Appropriate use of the suppression annotation for a complex method that maintains consistency across multiple nested data structures. The comment explains it well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants