执行器删除逻辑优化,删除时一并清理注册表数据,避免小概率情况下注册数据堆积(ISSUE-3669);

3.3.1-release
xuxueli 2 months ago
parent c4831bc4f4
commit 4f53622b54

@ -2701,7 +2701,8 @@ public void execute() {
- 1、【修复】调度组件事务代码优化修复DB超时等小概率情况下调度终止问题
- 2、【修复】合并PR-3869修复底层通讯超时设置无效问题
- 3、【新增】新增“执行器启用开关”配置项(xxl.job.executor.enabled),默认开启,关闭时不进行执行器初始化;
- 4、【TODO】任务调度触发后分批批量更新提升调度性能
- 4、【优化】执行器删除逻辑优化删除时一并清理注册表数据避免小概率情况下注册数据堆积ISSUE-3669
- 5、【TODO】任务调度触发后分批批量更新提升调度性能
### TODO LIST

@ -183,24 +183,34 @@ public class JobGroupController {
@XxlSso(role = Consts.ADMIN_ROLE)
public Response<String> delete(@RequestParam("ids[]") List<Integer> ids){
// valid
// parse id
if (CollectionTool.isEmpty(ids) || ids.size()!=1) {
return Response.ofFail(I18nUtil.getString("system_please_choose") + I18nUtil.getString("system_one") + I18nUtil.getString("system_data"));
}
int id = ids.get(0);
// valid
// valid repeat operation
XxlJobGroup xxlJobGroup = xxlJobGroupMapper.load(id);
if (xxlJobGroup == null) {
return Response.ofSuccess();
}
// whether exists job
int count = xxlJobInfoMapper.pageListCount(0, 10, id, -1, null, null, null);
if (count > 0) {
return Response.ofFail( I18nUtil.getString("jobgroup_del_limit_0") );
}
// whether only exists one group
List<XxlJobGroup> allList = xxlJobGroupMapper.findAll();
if (allList.size() == 1) {
return Response.ofFail( I18nUtil.getString("jobgroup_del_limit_1") );
}
// remove group
int ret = xxlJobGroupMapper.remove(id);
// remove registry-data
xxlJobRegistryMapper.removeByRegistryGroupAndKey(RegistType.EXECUTOR.name(), xxlJobGroup.getAppname());
return (ret>0)?Response.ofSuccess():Response.ofFail();
}

@ -40,4 +40,7 @@ public interface XxlJobRegistryMapper {
@Param("registryKey") String registryKey,
@Param("registryValue") String registryValue);
public int removeByRegistryGroupAndKey(@Param("registryGroup") String registryGroup,
@Param("registryKey") String registryKey);
}

@ -66,7 +66,7 @@ public class JobRegistryHelper {
// remove dead address (admin/executor)
List<Integer> ids = XxlJobAdminBootstrap.getInstance().getXxlJobRegistryMapper().findDead(Const.DEAD_TIMEOUT, new Date());
if (ids!=null && ids.size()>0) {
if (ids!=null && !ids.isEmpty()) {
XxlJobAdminBootstrap.getInstance().getXxlJobRegistryMapper().removeDead(ids);
}

@ -68,4 +68,10 @@
AND registry_value = #{registryValue}
</delete>
<delete id="removeByRegistryGroupAndKey" >
DELETE FROM xxl_job_registry
WHERE registry_group = #{registryGroup}
AND registry_key = #{registryKey}
</delete>
</mapper>

@ -52,7 +52,7 @@
<div class="box-header pull-left" id="data_operation" >
<button class="btn btn-sm btn-info add" type="button"><i class="fa fa-plus" ></i>${I18n.system_opt_add}</button>
<button class="btn btn-sm btn-warning selectOnlyOne update" type="button"><i class="fa fa-edit"></i>${I18n.system_opt_edit}</button>
<button class="btn btn-sm btn-danger selectAny delete" type="button"><i class="fa fa-remove "></i>${I18n.system_opt_del}</button>
<button class="btn btn-sm btn-danger selectOnlyOne delete" type="button"><i class="fa fa-remove "></i>${I18n.system_opt_del}</button>
</div>
<div class="box-body" >
<table id="data_list" class="table table-bordered table-striped" width="100%" >

@ -1,6 +1,7 @@
package com.xxl.job.admin.mapper;
import com.xxl.job.admin.model.XxlJobRegistry;
import com.xxl.job.core.constant.RegistType;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@ -18,7 +19,7 @@ public class XxlJobRegistryMapperTest {
@Test
public void test(){
int ret = xxlJobRegistryMapper.registrySaveOrUpdate("g1", "k1", "v1", new Date());
int ret = xxlJobRegistryMapper.registrySaveOrUpdate(RegistType.EXECUTOR.name(), "xxl-job-executor-z1", "v1", new Date());
/*int ret = xxlJobRegistryDao.registryUpdate("g1", "k1", "v1", new Date());
if (ret < 1) {
ret = xxlJobRegistryDao.registrySave("g1", "k1", "v1", new Date());

Loading…
Cancel
Save