On ApsaraMQ for Kafka instances with a server version of 2.2.0, consumer offsets on an active consumer group are never deleted, regardless of the Consumer Offset Retention Period setting. This behavior follows the open source Apache Kafka design.
How consumer offset retention works
The Consumer Offset Retention Period controls how long a consumer offset is kept after it was last committed. When the period expires, the system deletes the offset record entirely -- it does not reset the offset to 0. Each new commit to a topic partition resets the retention timer for that partition.
The following table summarizes when offsets expire and when they do not:
| Condition | Consumer type | Offset deleted after retention period? |
|---|---|---|
| Group has no consumers (inactive) | subscribe | Yes |
| Group unsubscribes from a topic but remains active on other topics | subscribe (server < 2.6.0) | No |
| Group unsubscribes from a topic but remains active on other topics | subscribe (server >= 2.6.0) | Yes |
A consumer group is active when it has at least one consumer thread that uses the subscribe method. The assign method does not make a group active.
Why offsets persist on active groups (server < 2.6.0)
In server versions earlier than 2.6.0 (including 2.2.0), the system retains consumer offsets for all topics as long as the group stays active -- even for topics the group no longer subscribes to.
Example: A group subscribes to both Topic A and Topic B, then unsubscribes from Topic A. The group remains active because of Topic B. Offsets for both topics are not deleted.
If the group unsubscribes from all topics, it becomes inactive and offsets are deleted after the retention period expires.
Solutions
Upgrade to server version 2.6.0 or later (recommended)
Starting with version 2.6.0, Kafka deletes expired offsets for unsubscribed topics even when the group is still active. No consumer disconnection is required.
After upgrading, if a group unsubscribes from Topic A but continues to subscribe to Topic B, the offsets for Topic A are automatically cleared after the retention period expires.
Make the group inactive
If upgrading is not possible, make the group inactive so that the retention timer takes effect. Use one of the following approaches:
| Approach | Steps | When to use |
|---|---|---|
| Wait for automatic deletion | Disconnect all consumers from the group. Offsets are deleted after the retention period expires. | You can tolerate waiting for the retention period. |
| Reset offsets manually | Disconnect all consumers from the group, then reset the expired consumer offsets to 0 for each partition on the Topic Details page in the ApsaraMQ for Kafka console. Go to the Subscriptions tab and click Consumer Details. | You need offsets cleared immediately. |
| Migrate to a new group | Move all consumers to a new group. The original group becomes inactive and its offsets are deleted after the retention period expires. | You are already planning to reorganize consumer groups. |
Verify consumer offset status
To check whether a group still holds consumer offsets for a topic:
Open the ApsaraMQ for Kafka console.
Go to the Topic Details page for the target topic.
Click the Subscriptions tab.
Click Consumer Details to view offset records.