Skip to content

Commit

Permalink
perf: 对执行对象任务写入 db 进行分批处理 #3312
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 committed Nov 28, 2024
1 parent 66a3252 commit a9ad191
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.tencent.bk.job.common.mysql.dynamic.ds.DbOperationEnum;
import com.tencent.bk.job.common.mysql.dynamic.ds.MySQLOperation;
import com.tencent.bk.job.common.mysql.jooq.JooqDataTypeUtil;
import com.tencent.bk.job.common.util.CollectionUtil;
import com.tencent.bk.job.common.util.BatchUtil;
import com.tencent.bk.job.execute.common.constants.RunStatusEnum;
import com.tencent.bk.job.execute.dao.TaskInstanceDAO;
import com.tencent.bk.job.execute.dao.common.DSLContextProviderFactory;
Expand Down Expand Up @@ -527,11 +527,7 @@ public List<Long> listTaskInstanceId(Long appId, Long fromTime, Long toTime, int
public void saveTaskInstanceHosts(long appId,
long taskInstanceId,
Collection<HostDTO> hosts) {
if (CollectionUtils.isEmpty(hosts)) {
return;
}
List<List<HostDTO>> hostBatches = CollectionUtil.partitionCollection(hosts, 2000);
hostBatches.forEach(batchHosts -> {
BatchUtil.executeBatch(hosts, 2000, batchHosts -> {
BatchBindStep batchInsert = dsl().batch(
dsl().insertInto(
TASK_INSTANCE_HOST,
Expand Down

0 comments on commit a9ad191

Please sign in to comment.