public ConsumerInfo removeConsumer(String group, String consumerId, boolean isTimeout) {
        if (group == null || consumerId == null) {
            return null;
        }
        boolean rmvGroup;
        boolean isCltBal = false;
        ConsumerInfo consumer = null;
        Integer lid = null;
        try {
            lid = groupRowLock.getLock(null,
                    StringUtils.getBytesUtf8(group), true);
            ConsumeGroupInfo consumeGroupInfo = groupInfoMap.get(group);
            if (consumeGroupInfo != null) {
                consumer = consumeGroupInfo.removeConsumer(consumerId);
                if (consumeGroupInfo.isGroupEmpty()) {
                    rmvGroup = (groupInfoMap.remove(group) != null);
                    if (consumeGroupInfo.isClientBalance()) {
                        isCltBal = true;
                        clientBalanceGroupSet.remove(group);
                    } else {
                        serverBalanceGroupSet.remove(group);
                    }
                    // remove topic-group map information
                    ConcurrentHashSet<String> groupSet;
                    for (String topicName : consumeGroupInfo.getTopicSet()) {
                        groupSet = topicGroupMap.get(topicName);
                        if (groupSet == null) {
                            continue;
                        }
                        groupSet.remove(group);
                    }
                    // statistic data
                    if (rmvGroup) {
                        if (consumer == null) {
                            MasterSrvStatsHolder.decConsumeGroupCnt(isTimeout, isCltBal);
                        } else {
                            MasterSrvStatsHolder.decConsumerCnt(isTimeout, true, isCltBal);
                        }
                    }
                } else {
                    if (consumer != null) {
                        MasterSrvStatsHolder.decConsumerCnt(isTimeout, false, false);
                    }
                }
            }
            consumerIndexMap.remove(consumerId);
        } catch (IOException e) {
            logger.warn("Failed to lock.", e);
        } finally {
            if (lid != null) {
                groupRowLock.releaseRowLock(lid);
            }
        }
        return consumer;
    }
remove the consumer and return consumer object,
if the consumer is the latest one, then removed the group object

@param group group name of consumer
@param consumerId consumer id
@param isTimeout if timeout
@return ConsumerInfo
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/master/nodemanage/nodeconsumer/ConsumerInfoHolder.java