wang-jiahua commented on code in PR #10448:
URL: https://github.com/apache/rocketmq/pull/10448#discussion_r3472802746
##########
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java:
##########
@@ -1714,6 +1791,58 @@ private RemotingCommand
deleteSubscriptionGroup(ChannelHandlerContext ctx,
return response;
}
+ private RemotingCommand deleteSubscriptionGroupList(ChannelHandlerContext
ctx,
+ RemotingCommand request) {
+ final RemotingCommand response =
RemotingCommand.createResponseCommand(null);
+
+ DeleteSubscriptionGroupListRequestBody requestBody =
DeleteSubscriptionGroupListRequestBody.decode(
+ request.getBody(), DeleteSubscriptionGroupListRequestBody.class);
+ List<String> groupNameList = requestBody == null ? null :
requestBody.getGroupNameList();
+
+ if (CollectionUtils.isEmpty(groupNameList)) {
+ response.setCode(ResponseCode.INVALID_PARAMETER);
+ response.setRemark("The specified group name list is blank.");
+ return response;
+ }
+
+ // dedup while preserving the input order
+ Set<String> groupNames = new LinkedHashSet<>();
+ for (String groupName : groupNameList) {
+ if (UtilAll.isBlank(groupName)) {
+ response.setCode(ResponseCode.INVALID_PARAMETER);
+ response.setRemark("The specified group name is blank.");
+ return response;
+ }
+ groupNames.add(groupName);
+ }
+
+ LOGGER.info("AdminBrokerProcessor#deleteSubscriptionGroupList:
groupNames={}, caller={}",
+ groupNames, RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+
+ try {
+ // batch delete subscription group config in one persist
+ this.brokerController.getSubscriptionGroupManager()
+ .deleteSubscriptionGroupConfigList(new
ArrayList<>(groupNames));
+
+ boolean cleanOffset = requestBody.isCleanOffset();
+ boolean autoDeleteUnusedStats =
this.brokerController.getBrokerConfig().isAutoDeleteUnusedStats();
+ for (String groupName : groupNames) {
+ if (cleanOffset || LiteMetadataUtil.isLiteGroupType(groupName,
this.brokerController)) {
Review Comment:
Good catch — fixed in 930d6e6d8.
Snapshotted lite-group state **before** calling
`deleteSubscriptionGroupConfigList(...)`:
```java
boolean cleanOffset = requestBody.isCleanOffset();
boolean autoDeleteUnusedStats = ...;
// Snapshot lite-group state before deletion, because once the group config
is removed,
// LiteMetadataUtil.isLiteGroupType(...) calls
findSubscriptionGroupConfig(...) which may
// auto-recreate the group when autoCreateSubscriptionGroup=true.
Set<String> liteGroups = new HashSet<>();
if (!cleanOffset) {
for (String groupName : groupNames) {
if (LiteMetadataUtil.isLiteGroupType(groupName,
this.brokerController)) {
liteGroups.add(groupName);
}
}
}
this.brokerController.getSubscriptionGroupManager()
.deleteSubscriptionGroupConfigList(new ArrayList<>(groupNames));
for (String groupName : groupNames) {
if (cleanOffset || liteGroups.contains(groupName)) {
...
}
}
```
This avoids the auto-recreation race. Will add a regression test for the
`cleanOffset=false` path.
--
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]