private void maybeDeleteEmptyConsumerGroup(String groupId, List<CoordinatorRecord> records) {
        Group group = groups.get(groupId, Long.MAX_VALUE);
        if (isEmptyConsumerGroup(group)) {
            // Add tombstones for the previous consumer group. The tombstones won't actually be
            // replayed because its coordinator result has a non-null appendFuture.
            createGroupTombstoneRecords(group, records);
            removeGroup(groupId);
        }
    }
Delete and write tombstones for the group if it's empty and is a consumer group.

@param groupId The group id to be deleted.
@param records The list of records to delete the group.
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java