status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
unknown
language
stringclasses
5 values
commit_datetime
unknown
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } if (file != null) { if (!upload(loginUser, fullName, file, type)) { logger.error("upload resource: {} file: {} failed.", name, RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.HDFS_OPERATION_ERROR); throw new ServiceException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename())); } if (!fullName.equals(originFullName)) { try { HadoopUtils.getInstance().delete(originHdfsFileName,false); } catch (IOException e) { logger.error(e.getMessage(),e); throw new ServiceException(String.format("delete resource: %s failed.", originFullName)); } } return result; } String destHdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(),tenantCode,fullName); try { logger.info("start hdfs copy {} -> {}", originHdfsFileName, destHdfsFileName); HadoopUtils.getInstance().copy(originHdfsFileName, destHdfsFileName, true, true); } catch (Exception e) { logger.error(MessageFormat.format("hdfs copy {0} -> {1} fail", originHdfsFileName, destHdfsFileName), e); putMsg(result,Status.HDFS_COPY_FAIL); throw new ServiceException(Status.HDFS_COPY_FAIL); } return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} private Result<Object> verifyFile(String name, ResourceType type, MultipartFile file) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (file != null) { if (file.isEmpty()) { logger.error("file is empty: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_FILE_IS_EMPTY); return result; } String fileSuffix = FileUtils.suffix(file.getOriginalFilename()); String nameSuffix = FileUtils.suffix(name); if (!(StringUtils.isNotEmpty(fileSuffix) && fileSuffix.equalsIgnoreCase(nameSuffix))) { logger.error("rename file suffix and original suffix must be consistent: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_SUFFIX_FORBID_CHANGE); return result; } if (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(fileSuffix)) { logger.error(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg()); putMsg(result, Status.UDF_RESOURCE_SUFFIX_NOT_JAR); return result; } if (file.getSize() > Constants.MAX_FILE_SIZE) { logger.error("file size is too large: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_SIZE_EXCEED_LIMIT);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } } return result; } /** * query resources list paging * * @param loginUser login user * @param type resource type * @param searchVal search value * @param pageNo page number * @param pageSize page size * @return resource list page */ @Override public Result queryResourceListPaging(User loginUser, int directoryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) { Result result = new Result(); Page<Resource> page = new Page<>(pageNo, pageSize); int userId = loginUser.getId(); if (isAdmin(loginUser)) { userId = 0; } if (directoryId != -1) { Resource directory = resourcesMapper.selectById(directoryId); if (directory == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
List<Integer> resourcesIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, 0); IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page, userId, directoryId, type.ordinal(), searchVal,resourcesIds); PageInfo<Resource> pageInfo = new PageInfo<>(pageNo, pageSize); pageInfo.setTotal((int)resourceIPage.getTotal()); pageInfo.setTotalList(resourceIPage.getRecords()); result.setData(pageInfo); putMsg(result,Status.SUCCESS); return result; } /** * create directory * @param loginUser login user * @param fullName full name * @param type resource type * @param result Result */ private void createDirectory(User loginUser,String fullName,ResourceType type,Result<Object> result) { String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); String directoryName = HadoopUtils.getHdfsFileName(type,tenantCode,fullName); String resourceRootPath = HadoopUtils.getHdfsDir(type,tenantCode); try { if (!HadoopUtils.getInstance().exists(resourceRootPath)) { createTenantDirIfNotExists(tenantCode); } if (!HadoopUtils.getInstance().mkdir(directoryName)) { logger.error("create resource directory {} of hdfs failed",directoryName); putMsg(result,Status.HDFS_OPERATION_ERROR); throw new ServiceException(String.format("create resource directory: %s failed.", directoryName)); } } catch (Exception e) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
logger.error("create resource directory {} of hdfs failed",directoryName); putMsg(result,Status.HDFS_OPERATION_ERROR); throw new ServiceException(String.format("create resource directory: %s failed.", directoryName)); } } /** * upload file to hdfs * * @param loginUser login user * @param fullName full name * @param file file */ private boolean upload(User loginUser, String fullName, MultipartFile file, ResourceType type) { String fileSuffix = FileUtils.suffix(file.getOriginalFilename()); String nameSuffix = FileUtils.suffix(fullName); if (!(StringUtils.isNotEmpty(fileSuffix) && fileSuffix.equalsIgnoreCase(nameSuffix))) { return false; } String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); String localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString()); String hdfsFilename = HadoopUtils.getHdfsFileName(type,tenantCode,fullName); String resourcePath = HadoopUtils.getHdfsDir(type,tenantCode); try { if (!HadoopUtils.getInstance().exists(resourcePath)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
createTenantDirIfNotExists(tenantCode); } org.apache.dolphinscheduler.api.utils.FileUtils.copyFile(file, localFilename); HadoopUtils.getInstance().copyLocalToHdfs(localFilename, hdfsFilename, true, true); } catch (Exception e) { try { FileUtils.deleteFile(localFilename); } catch (IOException ex) { logger.error("delete local tmp file:{} error", localFilename, ex); } logger.error(e.getMessage(), e); return false; } return true; } /** * query resource list * * @param loginUser login user * @param type resource type * @return resource list */ @Override public Map<String, Object> queryResourceList(User loginUser, ResourceType type) { Map<String, Object> result = new HashMap<>(); List<Resource> allResourceList = queryAuthoredResourceList(loginUser, type); Visitor resourceTreeVisitor = new ResourceTreeVisitor(allResourceList); result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} /** * query resource list by program type * * @param loginUser login user * @param type resource type * @return resource list */ @Override public Map<String, Object> queryResourceByProgramType(User loginUser, ResourceType type, ProgramType programType) { Map<String, Object> result = new HashMap<>(); List<Resource> allResourceList = queryAuthoredResourceList(loginUser, type); String suffix = ".jar"; if (programType != null) { switch (programType) { case JAVA: case SCALA: break; case PYTHON: suffix = ".py"; break; default: } } List<Resource> resources = new ResourceFilter(suffix, new ArrayList<>(allResourceList)).filter(); Visitor resourceTreeVisitor = new ResourceTreeVisitor(resources); result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
/** * delete resource * * @param loginUser login user * @param resourceId resource id * @return delete result code * @throws IOException exception */ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> delete(User loginUser, int resourceId) throws IOException { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!hasPerm(loginUser, resource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } String tenantCode = getTenantCode(resource.getUserId(),result); if (StringUtils.isEmpty(tenantCode)) { return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
List<Map<String, Object>> list = processDefinitionMapper.listResources(); Map<Integer, Set<Long>> resourceProcessMap = ResourceProcessDefinitionUtils.getResourceProcessDefinitionMap(list); Set<Integer> resourceIdSet = resourceProcessMap.keySet(); List<Integer> allChildren = listAllChildren(resource,true); Integer[] needDeleteResourceIdArray = allChildren.toArray(new Integer[allChildren.size()]); if (resource.getType() == (ResourceType.UDF)) { List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(needDeleteResourceIdArray); if (CollectionUtils.isNotEmpty(udfFuncs)) { logger.error("can't be deleted,because it is bound by UDF functions:{}", udfFuncs); putMsg(result,Status.UDF_RESOURCE_IS_BOUND,udfFuncs.get(0).getFuncName()); return result; } } if (resourceIdSet.contains(resource.getPid())) { logger.error("can't be deleted,because it is used of process definition"); putMsg(result, Status.RESOURCE_IS_USED); return result; } resourceIdSet.retainAll(allChildren); if (CollectionUtils.isNotEmpty(resourceIdSet)) { logger.error("can't be deleted,because it is used of process definition"); for (Integer resId : resourceIdSet) { logger.error("resource id:{} is used of process definition {}",resId,resourceProcessMap.get(resId)); } putMsg(result, Status.RESOURCE_IS_USED); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String hdfsFilename = HadoopUtils.getHdfsFileName(resource.getType(), tenantCode, resource.getFullName()); resourcesMapper.deleteIds(needDeleteResourceIdArray); resourceUserMapper.deleteResourceUserArray(0, needDeleteResourceIdArray); HadoopUtils.getInstance().delete(hdfsFilename, true); putMsg(result, Status.SUCCESS); return result; } /** * verify resource by name and type * @param loginUser login user * @param fullName resource full name * @param type resource type * @return true if the resource name not exists, otherwise return false */ @Override public Result<Object> verifyResourceName(String fullName, ResourceType type, User loginUser) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (checkResourceExists(fullName, 0, type.ordinal())) { logger.error("resource type:{} name:{} has exist, can't create again.", type, RegexUtils.escapeNRT(fullName)); putMsg(result, Status.RESOURCE_EXIST); } else { Tenant tenant = tenantMapper.queryById(loginUser.getTenantId()); if (tenant != null) { String tenantCode = tenant.getTenantCode(); try { String hdfsFilename = HadoopUtils.getHdfsFileName(type,tenantCode,fullName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (HadoopUtils.getInstance().exists(hdfsFilename)) { logger.error("resource type:{} name:{} has exist in hdfs {}, can't create again.", type, RegexUtils.escapeNRT(fullName), hdfsFilename); putMsg(result, Status.RESOURCE_FILE_EXIST,hdfsFilename); } } catch (Exception e) { logger.error(e.getMessage(),e); putMsg(result,Status.HDFS_OPERATION_ERROR); } } else { putMsg(result,Status.TENANT_NOT_EXIST); } } return result; } /** * verify resource by full name or pid and type * @param fullName resource full name * @param id resource id * @param type resource type * @return true if the resource full name or pid not exists, otherwise return false */ @Override public Result<Object> queryResource(String fullName, Integer id, ResourceType type) { Result<Object> result = new Result<>(); if (StringUtils.isBlank(fullName) && id == null) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR); return result; } if (StringUtils.isNotBlank(fullName)) { List<Resource> resourceList = resourcesMapper.queryResource(fullName,type.ordinal());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (CollectionUtils.isEmpty(resourceList)) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } putMsg(result, Status.SUCCESS); result.setData(resourceList.get(0)); } else { Resource resource = resourcesMapper.selectById(id); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } Resource parentResource = resourcesMapper.selectById(resource.getPid()); if (parentResource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } putMsg(result, Status.SUCCESS); result.setData(parentResource); } return result; } /** * view resource file online * * @param resourceId resource id * @param skipLineNum skip line number * @param limit limit * @return resource content */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
@Override public Result<Object> readResource(int resourceId, int skipLineNum, int limit) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } String nameSuffix = FileUtils.suffix(resource.getAlias()); String resourceViewSuffixs = FileUtils.getResourceViewSuffixs(); if (StringUtils.isNotEmpty(resourceViewSuffixs)) { List<String> strList = Arrays.asList(resourceViewSuffixs.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support view, resource id {}", nameSuffix, resourceId); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String tenantCode = getTenantCode(resource.getUserId(),result); if (StringUtils.isEmpty(tenantCode)) { return result; } String hdfsFileName = HadoopUtils.getHdfsResourceFileName(tenantCode, resource.getFullName()); logger.info("resource hdfs path is {}", hdfsFileName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
try { if (HadoopUtils.getInstance().exists(hdfsFileName)) { List<String> content = HadoopUtils.getInstance().catFile(hdfsFileName, skipLineNum, limit); putMsg(result, Status.SUCCESS); Map<String, Object> map = new HashMap<>(); map.put(ALIAS, resource.getAlias()); map.put(CONTENT, String.join("\n", content)); result.setData(map); } else { logger.error("read file {} not exist in hdfs", hdfsFileName); putMsg(result, Status.RESOURCE_FILE_NOT_EXIST,hdfsFileName); } } catch (Exception e) { logger.error("Resource {} read failed", hdfsFileName, e); putMsg(result, Status.HDFS_OPERATION_ERROR); } return result; } /** * create resource file online * * @param loginUser login user * @param type resource type * @param fileName file name * @param fileSuffix file suffix * @param desc description * @param content content * @param pid pid * @param currentDir current directory * @return create result code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
*/ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix, String desc, String content,int pid,String currentDir) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } String nameSuffix = fileSuffix.trim(); String resourceViewSuffixs = FileUtils.getResourceViewSuffixs(); if (StringUtils.isNotEmpty(resourceViewSuffixs)) { List<String> strList = Arrays.asList(resourceViewSuffixs.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support create", nameSuffix); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String name = fileName.trim() + "." + nameSuffix; String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name) : String.format("%s/%s",currentDir,name); result = verifyResource(loginUser, type, fullName, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Date now = new Date(); Resource resource = new Resource(pid,name,fullName,false,desc,name,loginUser.getId(),type,content.getBytes().length,now,now); resourcesMapper.insert(resource); putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
Map<Object, Object> dataMap = new BeanMap(resource); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry: dataMap.entrySet()) { if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap); String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); result = uploadContentToHdfs(fullName, tenantCode, content); if (!result.getCode().equals(Status.SUCCESS.getCode())) { throw new ServiceException(result.getMsg()); } return result; } private Result<Object> checkResourceUploadStartupState() { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (!PropertyUtils.getResUploadStartupState()) { logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState()); putMsg(result, Status.HDFS_NOT_STARTUP); return result; } return result; } private Result<Object> verifyResource(User loginUser, ResourceType type, String fullName, int pid) { Result<Object> result = verifyResourceName(fullName, type, loginUser); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} return verifyPid(loginUser, pid); } private Result<Object> verifyPid(User loginUser, int pid) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (pid != -1) { Resource parentResource = resourcesMapper.selectById(pid); if (parentResource == null) { putMsg(result, Status.PARENT_RESOURCE_NOT_EXIST); return result; } if (!hasPerm(loginUser, parentResource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } } return result; } /** * updateProcessInstance resource * * @param resourceId resource id * @param content content * @return update result cod */ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> updateResourceContent(int resourceId, String content) { Result<Object> result = checkResourceUploadStartupState();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { logger.error("read file not exist, resource id {}", resourceId); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } String nameSuffix = FileUtils.suffix(resource.getAlias()); String resourceViewSuffixs = FileUtils.getResourceViewSuffixs(); if (StringUtils.isNotEmpty(resourceViewSuffixs)) { List<String> strList = Arrays.asList(resourceViewSuffixs.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support updateProcessInstance, resource id {}", nameSuffix, resourceId); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String tenantCode = getTenantCode(resource.getUserId(),result); if (StringUtils.isEmpty(tenantCode)) { return result; } resource.setSize(content.getBytes().length); resource.setUpdateTime(new Date()); resourcesMapper.updateById(resource); result = uploadContentToHdfs(resource.getFullName(), tenantCode, content); if (!result.getCode().equals(Status.SUCCESS.getCode())) { throw new ServiceException(result.getMsg());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} return result; } /** * @param resourceName resource name * @param tenantCode tenant code * @param content content * @return result */ private Result<Object> uploadContentToHdfs(String resourceName, String tenantCode, String content) { Result<Object> result = new Result<>(); String localFilename = ""; String hdfsFileName = ""; try { localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString()); if (!FileUtils.writeContent2File(content, localFilename)) { logger.error("file {} fail, content is {}", localFilename, RegexUtils.escapeNRT(content)); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } hdfsFileName = HadoopUtils.getHdfsResourceFileName(tenantCode, resourceName); String resourcePath = HadoopUtils.getHdfsResDir(tenantCode); logger.info("resource hdfs path is {}, resource dir is {}", hdfsFileName, resourcePath); HadoopUtils hadoopUtils = HadoopUtils.getInstance(); if (!hadoopUtils.exists(resourcePath)) { createTenantDirIfNotExists(tenantCode); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (hadoopUtils.exists(hdfsFileName)) { hadoopUtils.delete(hdfsFileName, false); } hadoopUtils.copyLocalToHdfs(localFilename, hdfsFileName, true, true); } catch (Exception e) { logger.error(e.getMessage(), e); result.setCode(Status.HDFS_OPERATION_ERROR.getCode()); result.setMsg(String.format("copy %s to hdfs %s fail", localFilename, hdfsFileName)); return result; } putMsg(result, Status.SUCCESS); return result; } /** * download file * * @param resourceId resource id * @return resource content * @throws IOException exception */ @Override public org.springframework.core.io.Resource downloadResource(int resourceId) throws IOException { if (!PropertyUtils.getResUploadStartupState()) { logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState()); throw new ServiceException("hdfs not startup"); } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { logger.error("download file not exist, resource id {}", resourceId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return null; } if (resource.isDirectory()) { logger.error("resource id {} is directory,can't download it", resourceId); throw new ServiceException("can't download directory"); } int userId = resource.getUserId(); User user = userMapper.selectById(userId); if (user == null) { logger.error("user id {} not exists", userId); throw new ServiceException(String.format("resource owner id %d not exist",userId)); } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant id {} not exists", user.getTenantId()); throw new ServiceException(String.format("The tenant id %d of resource owner not exist",user.getTenantId())); } String tenantCode = tenant.getTenantCode(); String hdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(), tenantCode, resource.getFullName()); String localFileName = FileUtils.getDownloadFilename(resource.getAlias()); logger.info("resource hdfs path is {}, download local filename is {}", hdfsFileName, localFileName); HadoopUtils.getInstance().copyHdfsToLocal(hdfsFileName, localFileName, false, true); return org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(localFileName); } /** * list all file * * @param loginUser login user * @param userId user id * @return unauthorized result code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
*/ @Override public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { return result; } List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId); List<ResourceComponent> list; if (CollectionUtils.isNotEmpty(resourceList)) { Visitor visitor = new ResourceTreeVisitor(resourceList); list = visitor.visit().getChildren(); } else { list = new ArrayList<>(0); } result.put(Constants.DATA_LIST, list); putMsg(result, Status.SUCCESS); return result; } /** * unauthorized file * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId); List<Resource> list; if (resourceList != null && !resourceList.isEmpty()) { Set<Resource> resourceSet = new HashSet<>(resourceList); List<Resource> authedResourceList = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM); getAuthorizedResourceList(resourceSet, authedResourceList); list = new ArrayList<>(resourceSet); } else { list = new ArrayList<>(0); } Visitor visitor = new ResourceTreeVisitor(list); result.put(Constants.DATA_LIST, visitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; } /** * unauthorized udf function * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} List<UdfFunc> udfFuncList = udfFunctionMapper.queryUdfFuncExceptUserId(userId); List<UdfFunc> resultList = new ArrayList<>(); Set<UdfFunc> udfFuncSet; if (CollectionUtils.isNotEmpty(udfFuncList)) { udfFuncSet = new HashSet<>(udfFuncList); List<UdfFunc> authedUDFFuncList = udfFunctionMapper.queryAuthedUdfFunc(userId); getAuthorizedResourceList(udfFuncSet, authedUDFFuncList); resultList = new ArrayList<>(udfFuncSet); } result.put(Constants.DATA_LIST, resultList); putMsg(result, Status.SUCCESS); return result; } /** * authorized udf function * * @param loginUser login user * @param userId user id * @return authorized result code */ @Override public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { return result; } List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId); result.put(Constants.DATA_LIST, udfFuncs); putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } /** * authorized file * * @param loginUser login user * @param userId user id * @return authorized result */ @Override public Map<String, Object> authorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { return result; } List<Resource> authedResources = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM); Visitor visitor = new ResourceTreeVisitor(authedResources); String visit = JSONUtils.toJsonString(visitor.visit(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(visit); String jsonTreeStr = JSONUtils.toJsonString(visitor.visit().getChildren(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(jsonTreeStr); result.put(Constants.DATA_LIST, visitor.visit().getChildren()); putMsg(result,Status.SUCCESS); return result; } /** * get authorized resource list * * @param resourceSet resource set * @param authedResourceList authorized resource list
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
*/ private void getAuthorizedResourceList(Set<?> resourceSet, List<?> authedResourceList) { Set<?> authedResourceSet; if (CollectionUtils.isNotEmpty(authedResourceList)) { authedResourceSet = new HashSet<>(authedResourceList); resourceSet.removeAll(authedResourceSet); } } /** * get tenantCode by UserId * * @param userId user id * @param result return result * @return tenant code */ private String getTenantCode(int userId,Result<Object> result) { User user = userMapper.selectById(userId); if (user == null) { logger.error("user {} not exists", userId); putMsg(result, Status.USER_NOT_EXIST,userId); return null; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.TENANT_NOT_EXIST); return null; } return tenant.getTenantCode(); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
/** * list all children id * @param resource resource * @param containSelf whether add self to children list * @return all children id */ List<Integer> listAllChildren(Resource resource,boolean containSelf) { List<Integer> childList = new ArrayList<>(); if (resource.getId() != -1 && containSelf) { childList.add(resource.getId()); } if (resource.isDirectory()) { listAllChildren(resource.getId(),childList); } return childList; } /** * list all children id * @param resourceId resource id * @param childList child list */ void listAllChildren(int resourceId,List<Integer> childList) { List<Integer> children = resourcesMapper.listChildren(resourceId); for (int childId : children) { childList.add(childId); listAllChildren(childId, childList); } } /** * query authored resource list (own and authorized)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,366
[Bug] [API][service] checkResourceExists function use the magic number userId '0'
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened when the resource exactly exists,but the userId is not '0', the function will not take effect. ### What you expected to happen the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### How to reproduce the resources should be operate by the loginUser, sow the userId should be the loginUser's id ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6366
https://github.com/apache/dolphinscheduler/pull/6368
545173faa31e477f9487e98611f1951cf43efa2b
7413b578410a53c4839920edfdf98ac89344b959
"2021-09-27T02:48:04Z"
java
"2021-09-27T08:58:26Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param loginUser login user * @param type ResourceType * @return all authored resource list */ private List<Resource> queryAuthoredResourceList(User loginUser, ResourceType type) { List<Resource> relationResources; int userId = loginUser.getId(); if (isAdmin(loginUser)) { userId = 0; relationResources = new ArrayList<>(); } else { relationResources = queryResourceList(userId, 0); } List<Resource> ownResourceList = resourcesMapper.queryResourceListAuthored(userId, type.ordinal()); ownResourceList.addAll(relationResources); return ownResourceList; } /** * query resource list by userId and perm * @param userId userId * @param perm perm * @return resource list */ private List<Resource> queryResourceList(Integer userId, int perm) { List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, perm); return CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourcesMapper.queryResourceListById(resIds); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
/* * Lcensed to the Apache Software Foundaton (ASF) under one or more * contrbutor lcense agreements. See the NOTICE fle dstrbuted wth * ths work for addtonal nformaton regardng copyrght ownershp. * The ASF lcenses ths fle to You under the Apache Lcense, Verson 2.0 * (the "Lcense"); you may not use ths fle except n complance wth * the Lcense. You may obtan a copy of the Lcense at * * http://www.apache.org/lcenses/LICENSE-2.0 * * Unless requred by applcable law or agreed to n wrtng, software * dstrbuted under the Lcense s dstrbuted on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, ether express or mpled. * See the Lcense for the specfc language governng permssons and * lmtatons under the Lcense. */ package org.apache.dolphnscheduler.server.master.runner; mport statc org.apache.dolphnscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE; mport statc org.apache.dolphnscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE; mport statc org.apache.dolphnscheduler.common.Constants.CMD_PARAM_RECOVERY_START_NODE_STRING; mport statc org.apache.dolphnscheduler.common.Constants.CMD_PARAM_START_NODE_NAMES; mport statc org.apache.dolphnscheduler.common.Constants.DEFAULT_WORKER_GROUP; mport statc org.apache.dolphnscheduler.common.Constants.SEC_2_MINUTES_TIME_UNIT; mport org.apache.dolphnscheduler.common.Constants; mport org.apache.dolphnscheduler.common.enums.CommandType; mport org.apache.dolphnscheduler.common.enums.DependResult; mport org.apache.dolphnscheduler.common.enums.Drect; mport org.apache.dolphnscheduler.common.enums.ExecutonStatus;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
mport org.apache.dolphnscheduler.common.enums.FalureStrategy; mport org.apache.dolphnscheduler.common.enums.Flag; mport org.apache.dolphnscheduler.common.enums.Prorty; mport org.apache.dolphnscheduler.common.enums.StateEvent; mport org.apache.dolphnscheduler.common.enums.StateEventType; mport org.apache.dolphnscheduler.common.enums.TaskDependType; mport org.apache.dolphnscheduler.common.enums.TaskTmeoutStrategy; mport org.apache.dolphnscheduler.common.enums.TmeoutFlag; mport org.apache.dolphnscheduler.common.graph.DAG; mport org.apache.dolphnscheduler.common.model.TaskNode; mport org.apache.dolphnscheduler.common.model.TaskNodeRelaton; mport org.apache.dolphnscheduler.common.process.ProcessDag; mport org.apache.dolphnscheduler.common.process.Property; mport org.apache.dolphnscheduler.common.thread.ThreadUtls; mport org.apache.dolphnscheduler.common.utls.CollectonUtls; mport org.apache.dolphnscheduler.common.utls.DateUtls; mport org.apache.dolphnscheduler.common.utls.JSONUtls; mport org.apache.dolphnscheduler.common.utls.NetUtls; mport org.apache.dolphnscheduler.common.utls.ParameterUtls; mport org.apache.dolphnscheduler.dao.entty.Envronment; mport org.apache.dolphnscheduler.dao.entty.ProcessDefnton; mport org.apache.dolphnscheduler.dao.entty.ProcessInstance; mport org.apache.dolphnscheduler.dao.entty.ProjectUser; mport org.apache.dolphnscheduler.dao.entty.Schedule; mport org.apache.dolphnscheduler.dao.entty.TaskDefnton; mport org.apache.dolphnscheduler.dao.entty.TaskInstance; mport org.apache.dolphnscheduler.dao.utls.DagHelper; mport org.apache.dolphnscheduler.remote.command.HostUpdateCommand; mport org.apache.dolphnscheduler.remote.utls.Host; mport org.apache.dolphnscheduler.server.master.confg.MasterConfg;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
mport org.apache.dolphnscheduler.server.master.dspatch.executor.NettyExecutorManager; mport org.apache.dolphnscheduler.server.master.runner.task.ITaskProcessor; mport org.apache.dolphnscheduler.server.master.runner.task.TaskActon; mport org.apache.dolphnscheduler.server.master.runner.task.TaskProcessorFactory; mport org.apache.dolphnscheduler.servce.alert.ProcessAlertManager; mport org.apache.dolphnscheduler.servce.process.ProcessServce; mport org.apache.dolphnscheduler.servce.quartz.cron.CronUtls; mport org.apache.dolphnscheduler.servce.queue.PeerTaskInstancePrortyQueue; mport org.apache.commons.lang.StrngUtls; mport java.utl.ArrayLst; mport java.utl.Arrays; mport java.utl.Collecton; mport java.utl.Date; mport java.utl.HashMap; mport java.utl.Iterator; mport java.utl.Lst; mport java.utl.Map; mport java.utl.Objects; mport java.utl.Set; mport java.utl.concurrent.ConcurrentHashMap; mport java.utl.concurrent.ConcurrentLnkedQueue; mport java.utl.concurrent.ExecutorServce; mport org.slf4j.Logger; mport org.slf4j.LoggerFactory; mport com.google.common.collect.HashBasedTable; mport com.google.common.collect.Lsts; mport com.google.common.collect.Table; /** * master exec thread,splt dag */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
publc class WorkflowExecuteThread mplements Runnable { /** * logger of WorkflowExecuteThread */ prvate statc fnal Logger logger = LoggerFactory.getLogger(WorkflowExecuteThread.class); /** * runng TaskNode */ prvate fnal Map<Integer, ITaskProcessor> actveTaskProcessorMaps = new ConcurrentHashMap<>(); /** * task exec servce */ prvate fnal ExecutorServce taskExecServce; /** * process nstance */ prvate ProcessInstance processInstance; /** * submt falure nodes */ prvate boolean taskFaledSubmt = false; /** * recover node d lst */ prvate Lst<TaskInstance> recoverNodeIdLst = new ArrayLst<>(); /** * error task lst */ prvate Map<Strng, TaskInstance> errorTaskLst = new ConcurrentHashMap<>(); /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
* complete task lst */ prvate Map<Strng, TaskInstance> completeTaskLst = new ConcurrentHashMap<>(); /** * ready to submt task queue */ prvate PeerTaskInstancePrortyQueue readyToSubmtTaskQueue = new PeerTaskInstancePrortyQueue(); /** * depend faled task map */ prvate Map<Strng, TaskInstance> dependFaledTask = new ConcurrentHashMap<>(); /** * forbdden task map */ prvate Map<Strng, TaskNode> forbddenTaskLst = new ConcurrentHashMap<>(); /** * skp task map */ prvate Map<Strng, TaskNode> skpTaskNodeLst = new ConcurrentHashMap<>(); /** * recover tolerance fault task lst */ prvate Lst<TaskInstance> recoverToleranceFaultTaskLst = new ArrayLst<>(); /** * alert manager */ prvate ProcessAlertManager processAlertManager; /** * the object of DAG */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
prvate DAG<Strng, TaskNode, TaskNodeRelaton> dag; /** * process servce */ prvate ProcessServce processServce; /** * master confg */ prvate MasterConfg masterConfg; /** * */ prvate NettyExecutorManager nettyExecutorManager; prvate ConcurrentLnkedQueue<StateEvent> stateEvents = new ConcurrentLnkedQueue<>(); prvate Lst<Date> complementLstDate = Lsts.newLnkedLst(); prvate Table<Integer, Long, TaskInstance> taskInstanceHashMap = HashBasedTable.create(); prvate ProcessDefnton processDefnton; prvate Strng key; prvate ConcurrentHashMap<Integer, TaskInstance> taskTmeoutCheckLst; /** * start flag, true: start nodes submt completely * */ prvate boolean sStart = false; /** * constructor of WorkflowExecuteThread * * @param processInstance processInstance * @param processServce processServce * @param nettyExecutorManager nettyExecutorManager
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
* @param taskTmeoutCheckLst */ publc WorkflowExecuteThread(ProcessInstance processInstance , ProcessServce processServce , NettyExecutorManager nettyExecutorManager , ProcessAlertManager processAlertManager , MasterConfg masterConfg , ConcurrentHashMap<Integer, TaskInstance> taskTmeoutCheckLst) { ths.processServce = processServce; ths.processInstance = processInstance; ths.masterConfg = masterConfg; nt masterTaskExecNum = masterConfg.getMasterExecTaskNum(); ths.taskExecServce = ThreadUtls.newDaemonFxedThreadExecutor("Master-Task-Exec-Thread", masterTaskExecNum); ths.nettyExecutorManager = nettyExecutorManager; ths.processAlertManager = processAlertManager; ths.taskTmeoutCheckLst = taskTmeoutCheckLst; } @Overrde publc vod run() { try { startProcess(); handleEvents(); } catch (Excepton e) { logger.error("handler error:", e); } } /** * the process start nodes are submtted completely. * @return
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
*/ publc boolean sStart() { return ths.sStart; } prvate vod handleEvents() { whle (ths.stateEvents.sze() > 0) { try { StateEvent stateEvent = ths.stateEvents.peek(); f (stateEventHandler(stateEvent)) { ths.stateEvents.remove(stateEvent); } } catch (Excepton e) { logger.error("state handle error:", e); } } } publc Strng getKey() { f (StrngUtls.sNotEmpty(key) || ths.processDefnton == null) { return key; } key = Strng.format("{}_{}_{}", ths.processDefnton.getCode(), ths.processDefnton.getVerson(), ths.processInstance.getId()); return key; } publc boolean addStateEvent(StateEvent stateEvent) { f (processInstance.getId() != stateEvent.getProcessInstanceId()) { logger.nfo("state event would be abounded :{}", stateEvent.toStrng());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
return false; } ths.stateEvents.add(stateEvent); return true; } publc nt eventSze() { return ths.stateEvents.sze(); } publc ProcessInstance getProcessInstance() { return ths.processInstance; } prvate boolean stateEventHandler(StateEvent stateEvent) { logger.nfo("process event: {}", stateEvent.toStrng()); f (!checkStateEvent(stateEvent)) { return false; } boolean result = false; swtch (stateEvent.getType()) { case PROCESS_STATE_CHANGE: result = processStateChangeHandler(stateEvent); break; case TASK_STATE_CHANGE: result = taskStateChangeHandler(stateEvent); break; case PROCESS_TIMEOUT: result = processTmeout(); break; case TASK_TIMEOUT: result = taskTmeout(stateEvent); break;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
default: break; } f (result) { ths.stateEvents.remove(stateEvent); } return result; } prvate boolean taskTmeout(StateEvent stateEvent) { f (taskInstanceHashMap.contansRow(stateEvent.getTaskInstanceId())) { return true; } TaskInstance taskInstance = taskInstanceHashMap .row(stateEvent.getTaskInstanceId()) .values() .terator().next(); f (TmeoutFlag.CLOSE == taskInstance.getTaskDefne().getTmeoutFlag()) { return true; } TaskTmeoutStrategy taskTmeoutStrategy = taskInstance.getTaskDefne().getTmeoutNotfyStrategy(); f (TaskTmeoutStrategy.FAILED == taskTmeoutStrategy) { ITaskProcessor taskProcessor = actveTaskProcessorMaps.get(stateEvent.getTaskInstanceId()); taskProcessor.acton(TaskActon.TIMEOUT); return false; } else { processAlertManager.sendTaskTmeoutAlert(processInstance, taskInstance, taskInstance.getTaskDefne()); return true; } } prvate boolean processTmeout() {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
ths.processAlertManager.sendProcessTmeoutAlert(ths.processInstance, ths.processDefnton); return true; } prvate boolean taskStateChangeHandler(StateEvent stateEvent) { TaskInstance task = processServce.fndTaskInstanceById(stateEvent.getTaskInstanceId()); f (stateEvent.getExecutonStatus().typeIsFnshed()) { taskFnshed(task); } else f (actveTaskProcessorMaps.contansKey(stateEvent.getTaskInstanceId())) { ITaskProcessor TaskProcessor = actveTaskProcessorMaps.get(stateEvent.getTaskInstanceId()); TaskProcessor.run(); f (TaskProcessor.taskState().typeIsFnshed()) { task = processServce.fndTaskInstanceById(stateEvent.getTaskInstanceId()); taskFnshed(task); } } else { logger.error("state handler error: {}", stateEvent.toStrng()); } return true; } prvate vod taskFnshed(TaskInstance task) { logger.nfo("work flow {} task {} state:{} ", processInstance.getId(), task.getId(), task.getState()); f (task.taskCanRetry()) { addTaskToStandByLst(task); return; } ProcessInstance processInstance = processServce.fndProcessInstanceById(ths.processInstance.getId()); completeTaskLst.put(task.getName(), task);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
actveTaskProcessorMaps.remove(task.getId()); taskTmeoutCheckLst.remove(task.getId()); f (task.getState().typeIsSuccess()) { processInstance.setVarPool(task.getVarPool()); processServce.saveProcessInstance(processInstance); submtPostNode(task.getName()); } else f (task.getState().typeIsFalure()) { f (task.sCondtonsTask() || DagHelper.haveCondtonsAfterNode(task.getName(), dag)) { submtPostNode(task.getName()); } else { errorTaskLst.put(task.getName(), task); f (processInstance.getFalureStrategy() == FalureStrategy.END) { kllAllTasks(); } } } ths.updateProcessInstanceState(); } prvate boolean checkStateEvent(StateEvent stateEvent) { f (ths.processInstance.getId() != stateEvent.getProcessInstanceId()) { logger.error("msmatch process nstance d: {}, state event:{}", ths.processInstance.getId(), stateEvent.toStrng()); return false; } return true; } prvate boolean processStateChangeHandler(StateEvent stateEvent) { try {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
logger.nfo("process:{} state {} change to {}", processInstance.getId(), processInstance.getState(), stateEvent.getExecutonStatus()); processInstance = processServce.fndProcessInstanceById(ths.processInstance.getId()); f (processComplementData()) { return true; } f (stateEvent.getExecutonStatus().typeIsFnshed()) { endProcess(); } f (stateEvent.getExecutonStatus() == ExecutonStatus.READY_STOP) { kllAllTasks(); } return true; } catch (Excepton e) { logger.error("process state change error:", e); } return true; } prvate boolean processComplementData() throws Excepton { f (!needComplementProcess()) { return false; } Date scheduleDate = processInstance.getScheduleTme(); f (scheduleDate == null) { scheduleDate = complementLstDate.get(0); } else f (processInstance.getState().typeIsFnshed()) { endProcess(); nt ndex = complementLstDate.ndexOf(scheduleDate); f (ndex >= complementLstDate.sze() - 1 || !processInstance.getState().typeIsSuccess()) { logger.nfo("process complement end. process d:{}", processInstance.getId());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
return false; } logger.nfo("process complement contnue. process d:{}, schedule tme:{} complementLstDate:{}", processInstance.getId(), processInstance.getScheduleTme(), complementLstDate.toStrng()); scheduleDate = complementLstDate.get(ndex + 1); processInstance.setId(0); } processInstance.setScheduleTme(scheduleDate); Map<Strng, Strng> cmdParam = JSONUtls.toMap(processInstance.getCommandParam()); f (cmdParam.contansKey(Constants.CMD_PARAM_RECOVERY_START_NODE_STRING)) { cmdParam.remove(Constants.CMD_PARAM_RECOVERY_START_NODE_STRING); processInstance.setCommandParam(JSONUtls.toJsonStrng(cmdParam)); } processInstance.setState(ExecutonStatus.RUNNING_EXECUTION); processInstance.setGlobalParams(ParameterUtls.curngGlobalParams( processDefnton.getGlobalParamMap(), processDefnton.getGlobalParamLst(), CommandType.COMPLEMENT_DATA, processInstance.getScheduleTme())); processInstance.setStartTme(new Date()); processInstance.setEndTme(null); processServce.saveProcessInstance(processInstance); ths.taskInstanceHashMap.clear(); startProcess(); return true; } prvate boolean needComplementProcess() { f (processInstance.sComplementData()
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
&& Flag.NO == processInstance.getIsSubProcess()) { return true; } return false; } prvate vod startProcess() throws Excepton { f (ths.taskInstanceHashMap.sze() == 0) { sStart = false; buldFlowDag(); ntTaskQueue(); submtPostNode(null); sStart = true; } } /** * process end handle */ prvate vod endProcess() { ths.stateEvents.clear(); processInstance.setEndTme(new Date()); processServce.updateProcessInstance(processInstance); f (processInstance.getState().typeIsWatngThread()) { processServce.createRecoveryWatngThreadCommand(null, processInstance); } Lst<TaskInstance> taskInstances = processServce.fndValdTaskLstByProcessId(processInstance.getId()); ProjectUser projectUser = processServce.queryProjectWthUserByProcessInstanceId(processInstance.getId()); processAlertManager.sendAlertProcessInstance(processInstance, taskInstances, projectUser); } /** * generate process dag
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
* * @throws Excepton excepton */ prvate vod buldFlowDag() throws Excepton { f (ths.dag != null) { return; } processDefnton = processServce.fndProcessDefnton(processInstance.getProcessDefntonCode(), processInstance.getProcessDefntonVerson()); recoverNodeIdLst = getStartTaskInstanceLst(processInstance.getCommandParam()); Lst<TaskNode> taskNodeLst = processServce.transformTask(processServce.fndRelatonByCode(processDefnton.getProjectCode(), processDefnton.getCode()), Lsts.newArrayLst()); forbddenTaskLst.clear(); taskNodeLst.forEach(taskNode -> { f (taskNode.sForbdden()) { forbddenTaskLst.put(taskNode.getName(), taskNode); } }); Lst<Strng> recoveryNameLst = getRecoveryNodeNameLst(); Lst<Strng> startNodeNameLst = parseStartNodeName(processInstance.getCommandParam()); ProcessDag processDag = generateFlowDag(taskNodeLst, startNodeNameLst, recoveryNameLst, processInstance.getTaskDependType()); f (processDag == null) { logger.error("processDag s null"); return; } dag = DagHelper.buldDagGraph(processDag); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
/** * nt task queue */ prvate vod ntTaskQueue() { taskFaledSubmt = false; actveTaskProcessorMaps.clear(); dependFaledTask.clear(); completeTaskLst.clear(); errorTaskLst.clear(); Lst<TaskInstance> taskInstanceLst = processServce.fndValdTaskLstByProcessId(processInstance.getId()); for (TaskInstance task : taskInstanceLst) { f (task.sTaskComplete()) { completeTaskLst.put(task.getName(), task); } f (task.sCondtonsTask() || DagHelper.haveCondtonsAfterNode(task.getName(), dag)) { contnue; } f (task.getState().typeIsFalure() && !task.taskCanRetry()) { errorTaskLst.put(task.getName(), task); } } f (complementLstDate.sze() == 0 && needComplementProcess()) { complementLstDate = processServce.getComplementDateLst( JSONUtls.toMap(processInstance.getCommandParam()), processInstance.getProcessDefntonCode()); logger.nfo(" process defnton code:{} complement data: {}", processInstance.getProcessDefntonCode(), complementLstDate.toStrng()); } } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
* submt task to execute * * @param taskInstance task nstance * @return TaskInstance */ prvate TaskInstance submtTaskExec(TaskInstance taskInstance) { try { ITaskProcessor taskProcessor = TaskProcessorFactory.getTaskProcessor(taskInstance.getTaskType()); f (taskInstance.getState() == ExecutonStatus.RUNNING_EXECUTION && taskProcessor.getType().equalsIgnoreCase(Constants.COMMON_TASK_TYPE)) { notfyProcessHostUpdate(taskInstance); } boolean submt = taskProcessor.submt(taskInstance, processInstance, masterConfg.getMasterTaskCommtRetryTmes(), masterConfg.getMasterTaskCommtInterval()); f (submt) { ths.taskInstanceHashMap.put(taskInstance.getId(), taskInstance.getTaskCode(), taskInstance); actveTaskProcessorMaps.put(taskInstance.getId(), taskProcessor); taskProcessor.run(); addTmeoutCheck(taskInstance); TaskDefnton taskDefnton = processServce.fndTaskDefnton( taskInstance.getTaskCode(), taskInstance.getTaskDefntonVerson()); taskInstance.setTaskDefne(taskDefnton); f (taskProcessor.taskState().typeIsFnshed()) { StateEvent stateEvent = new StateEvent(); stateEvent.setProcessInstanceId(ths.processInstance.getId()); stateEvent.setTaskInstanceId(taskInstance.getId()); stateEvent.setExecutonStatus(taskProcessor.taskState()); stateEvent.setType(StateEventType.TASK_STATE_CHANGE); ths.stateEvents.add(stateEvent); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
return taskInstance; } else { logger.error("process d:{} name:{} submt standby task d:{} name:{} faled!", processInstance.getId(), processInstance.getName(), taskInstance.getId(), taskInstance.getName()); return null; } } catch (Excepton e) { logger.error("submt standby task error", e); return null; } } prvate vod notfyProcessHostUpdate(TaskInstance taskInstance) { f (StrngUtls.sEmpty(taskInstance.getHost())) { return; } try { HostUpdateCommand hostUpdateCommand = new HostUpdateCommand(); hostUpdateCommand.setProcessHost(NetUtls.getAddr(masterConfg.getLstenPort())); hostUpdateCommand.setTaskInstanceId(taskInstance.getId()); Host host = new Host(taskInstance.getHost()); nettyExecutorManager.doExecute(host, hostUpdateCommand.convert2Command()); } catch (Excepton e) { logger.error("notfy process host update", e); } } prvate vod addTmeoutCheck(TaskInstance taskInstance) { TaskDefnton taskDefnton = processServce.fndTaskDefnton( taskInstance.getTaskCode(), taskInstance.getTaskDefntonVerson()
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
); taskInstance.setTaskDefne(taskDefnton); f (TmeoutFlag.OPEN == taskDefnton.getTmeoutFlag()) { ths.taskTmeoutCheckLst.put(taskInstance.getId(), taskInstance); return; } f (taskInstance.sDependTask() || taskInstance.sSubProcess()) { ths.taskTmeoutCheckLst.put(taskInstance.getId(), taskInstance); } } /** * fnd task nstance n db. * n case submt more than one same name task n the same tme. * * @param taskCode task code * @param taskVerson task verson * @return TaskInstance */ prvate TaskInstance fndTaskIfExsts(Long taskCode, nt taskVerson) { Lst<TaskInstance> taskInstanceLst = processServce.fndValdTaskLstByProcessId(ths.processInstance.getId()); for (TaskInstance taskInstance : taskInstanceLst) { f (taskInstance.getTaskCode() == taskCode && taskInstance.getTaskDefntonVerson() == taskVerson) { return taskInstance; } } return null; } /** * encapsulaton task *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
* @param processInstance process nstance * @param taskNode taskNode * @return TaskInstance */ prvate TaskInstance createTaskInstance(ProcessInstance processInstance, TaskNode taskNode) { TaskInstance taskInstance = fndTaskIfExsts(taskNode.getCode(), taskNode.getVerson()); f (taskInstance == null) { taskInstance = new TaskInstance(); taskInstance.setTaskCode(taskNode.getCode()); taskInstance.setTaskDefntonVerson(taskNode.getVerson()); taskInstance.setName(taskNode.getName()); taskInstance.setState(ExecutonStatus.SUBMITTED_SUCCESS); taskInstance.setProcessInstanceId(processInstance.getId()); taskInstance.setTaskType(taskNode.getType().toUpperCase()); taskInstance.setAlertFlag(Flag.NO); taskInstance.setStartTme(null); taskInstance.setFlag(Flag.YES); taskInstance.setRetryTmes(0); taskInstance.setMaxRetryTmes(taskNode.getMaxRetryTmes()); taskInstance.setRetryInterval(taskNode.getRetryInterval());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
taskInstance.setTaskParams(taskNode.getTaskParams()); f (taskNode.getTaskInstanceProrty() == null) { taskInstance.setTaskInstanceProrty(Prorty.MEDIUM); } else { taskInstance.setTaskInstanceProrty(taskNode.getTaskInstanceProrty()); } Strng processWorkerGroup = processInstance.getWorkerGroup(); processWorkerGroup = StrngUtls.sBlank(processWorkerGroup) ? DEFAULT_WORKER_GROUP : processWorkerGroup; Strng taskWorkerGroup = StrngUtls.sBlank(taskNode.getWorkerGroup()) ? processWorkerGroup : taskNode.getWorkerGroup(); Long processEnvronmentCode = Objects.sNull(processInstance.getEnvronmentCode()) ? -1 : processInstance.getEnvronmentCode(); Long taskEnvronmentCode = Objects.sNull(taskNode.getEnvronmentCode()) ? processEnvronmentCode : taskNode.getEnvronmentCode(); f (!processWorkerGroup.equals(DEFAULT_WORKER_GROUP) && taskWorkerGroup.equals(DEFAULT_WORKER_GROUP)) { taskInstance.setWorkerGroup(processWorkerGroup); taskInstance.setEnvronmentCode(processEnvronmentCode); } else { taskInstance.setWorkerGroup(taskWorkerGroup); taskInstance.setEnvronmentCode(taskEnvronmentCode); } f (!taskInstance.getEnvronmentCode().equals(-1L)) { Envronment envronment = processServce.fndEnvronmentByCode(taskInstance.getEnvronmentCode()); f (Objects.nonNull(envronment) && StrngUtls.sNotEmpty(envronment.getConfg())) { taskInstance.setEnvronmentConfg(envronment.getConfg()); } } taskInstance.setDelayTme(taskNode.getDelayTme()); } return taskInstance;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
} publc vod getPreVarPool(TaskInstance taskInstance, Set<Strng> preTask) { Map<Strng, Property> allProperty = new HashMap<>(); Map<Strng, TaskInstance> allTaskInstance = new HashMap<>(); f (CollectonUtls.sNotEmpty(preTask)) { for (Strng preTaskName : preTask) { TaskInstance preTaskInstance = completeTaskLst.get(preTaskName); f (preTaskInstance == null) { contnue; } Strng preVarPool = preTaskInstance.getVarPool(); f (StrngUtls.sNotEmpty(preVarPool)) { Lst<Property> propertes = JSONUtls.toLst(preVarPool, Property.class); for (Property nfo : propertes) { setVarPoolValue(allProperty, allTaskInstance, preTaskInstance, nfo); } } } f (allProperty.sze() > 0) { taskInstance.setVarPool(JSONUtls.toJsonStrng(allProperty.values())); } } } prvate vod setVarPoolValue(Map<Strng, Property> allProperty, Map<Strng, TaskInstance> allTaskInstance, TaskInstance preTaskInstance, Property thsProperty) { thsProperty.setDrect(Drect.IN); Strng proName = thsProperty.getProp(); f (allProperty.contansKey(proName)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
Property otherPro = allProperty.get(proName); f (StrngUtls.sEmpty(thsProperty.getValue())) { allProperty.put(proName, otherPro); } else f (StrngUtls.sNotEmpty(otherPro.getValue())) { TaskInstance otherTask = allTaskInstance.get(proName); f (otherTask.getEndTme().getTme() > preTaskInstance.getEndTme().getTme()) { allProperty.put(proName, thsProperty); allTaskInstance.put(proName, preTaskInstance); } else { allProperty.put(proName, otherPro); } } else { allProperty.put(proName, thsProperty); allTaskInstance.put(proName, preTaskInstance); } } else { allProperty.put(proName, thsProperty); allTaskInstance.put(proName, preTaskInstance); } } prvate vod submtPostNode(Strng parentNodeName) { Set<Strng> submtTaskNodeLst = DagHelper.parsePostNodes(parentNodeName, skpTaskNodeLst, dag, completeTaskLst); Lst<TaskInstance> taskInstances = new ArrayLst<>(); for (Strng taskNode : submtTaskNodeLst) { TaskNode taskNodeObject = dag.getNode(taskNode); f (taskInstanceHashMap.contansColumn(taskNodeObject.getCode())) { contnue;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
} TaskInstance task = createTaskInstance(processInstance, taskNodeObject); taskInstances.add(task); } for (TaskInstance task : taskInstances) { f (readyToSubmtTaskQueue.contans(task)) { contnue; } f (completeTaskLst.contansKey(task.getName())) { logger.nfo("task {} has already run success", task.getName()); contnue; } f (task.getState().typeIsPause() || task.getState().typeIsCancel()) { logger.nfo("task {} stopped, the state s {}", task.getName(), task.getState()); } else { addTaskToStandByLst(task); } } submtStandByTask(); updateProcessInstanceState(); } /** * determne whether the dependences of the task node are complete * * @return DependResult */ prvate DependResult sTaskDepsComplete(Strng taskName) { Collecton<Strng> startNodes = dag.getBegnNode();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
f (startNodes.contans(taskName)) { return DependResult.SUCCESS; } TaskNode taskNode = dag.getNode(taskName); Lst<Strng> depNameLst = taskNode.getDepLst(); for (Strng depsNode : depNameLst) { f (!dag.contansNode(depsNode) || forbddenTaskLst.contansKey(depsNode) || skpTaskNodeLst.contansKey(depsNode)) { contnue; } f (!completeTaskLst.contansKey(depsNode)) { return DependResult.WAITING; } ExecutonStatus depTaskState = completeTaskLst.get(depsNode).getState(); f (depTaskState.typeIsPause() || depTaskState.typeIsCancel()) { return DependResult.NON_EXEC; } f (taskNode.sCondtonsTask()) { contnue; } f (!dependTaskSuccess(depsNode, taskName)) { return DependResult.FAILED; } } logger.nfo("taskName: {} completeDependTaskLst: {}", taskName, Arrays.toStrng(completeTaskLst.keySet().toArray())); return DependResult.SUCCESS; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
/** * depend node s completed, but here need check the condton task branch s the next node */ prvate boolean dependTaskSuccess(Strng dependNodeName, Strng nextNodeName) { f (dag.getNode(dependNodeName).sCondtonsTask()) { Lst<Strng> nextTaskLst = DagHelper.parseCondtonTask(dependNodeName, skpTaskNodeLst, dag, completeTaskLst); f (!nextTaskLst.contans(nextNodeName)) { return false; } } else { ExecutonStatus depTaskState = completeTaskLst.get(dependNodeName).getState(); f (depTaskState.typeIsFalure()) { return false; } } return true; } /** * query task nstance by complete state * * @param state state * @return task nstance lst */ prvate Lst<TaskInstance> getCompleteTaskByState(ExecutonStatus state) { Lst<TaskInstance> resultLst = new ArrayLst<>(); for (Map.Entry<Strng, TaskInstance> entry : completeTaskLst.entrySet()) { f (entry.getValue().getState() == state) { resultLst.add(entry.getValue()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
} return resultLst; } /** * where there are ongong tasks * * @param state state * @return ExecutonStatus */ prvate ExecutonStatus runnngState(ExecutonStatus state) { f (state == ExecutonStatus.READY_STOP || state == ExecutonStatus.READY_PAUSE || state == ExecutonStatus.WAITING_THREAD || state == ExecutonStatus.DELAY_EXECUTION) { return state; } else { return ExecutonStatus.RUNNING_EXECUTION; } } /** * exsts falure task,contans submt falure、dependency falure,execute falure(retry after) * * @return Boolean whether has faled task */ prvate boolean hasFaledTask() { f (ths.taskFaledSubmt) { return true; } f (ths.errorTaskLst.sze() > 0) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
return true; } return ths.dependFaledTask.sze() > 0; } /** * process nstance falure * * @return Boolean whether process nstance faled */ prvate boolean processFaled() { f (hasFaledTask()) { f (processInstance.getFalureStrategy() == FalureStrategy.END) { return true; } f (processInstance.getFalureStrategy() == FalureStrategy.CONTINUE) { return readyToSubmtTaskQueue.sze() == 0 || actveTaskProcessorMaps.sze() == 0; } } return false; } /** * whether task for watng thread * * @return Boolean whether has watng thread task */ prvate boolean hasWatngThreadTask() { Lst<TaskInstance> watngLst = getCompleteTaskByState(ExecutonStatus.WAITING_THREAD); return CollectonUtls.sNotEmpty(watngLst); } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
* prepare for pause * 1,faled retry task n the preparaton queue , returns to falure drectly * 2,exsts pause task,complement not completed, pendng submsson of tasks, return to suspenson * 3,success * * @return ExecutonStatus */ prvate ExecutonStatus processReadyPause() { f (hasRetryTaskInStandBy()) { return ExecutonStatus.FAILURE; } Lst<TaskInstance> pauseLst = getCompleteTaskByState(ExecutonStatus.PAUSE); f (CollectonUtls.sNotEmpty(pauseLst) || !sComplementEnd() || readyToSubmtTaskQueue.sze() > 0) { return ExecutonStatus.PAUSE; } else { return ExecutonStatus.SUCCESS; } } /** * generate the latest process nstance status by the tasks state * * @param nstance * @return process nstance executon status */ prvate ExecutonStatus getProcessInstanceState(ProcessInstance nstance) { ExecutonStatus state = nstance.getState(); f (actveTaskProcessorMaps.sze() > 0 || hasRetryTaskInStandBy()) { // actve
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
return runnngState(state); } // process falure f (processFaled()) { return ExecutonStatus.FAILURE; } // watng thread f (hasWatngThreadTask()) { return ExecutonStatus.WAITING_THREAD; } // pause f (state == ExecutonStatus.READY_PAUSE) { return processReadyPause(); } // stop f (state == ExecutonStatus.READY_STOP) { Lst<TaskInstance> stopLst = getCompleteTaskByState(ExecutonStatus.STOP); Lst<TaskInstance> kllLst = getCompleteTaskByState(ExecutonStatus.KILL); f (CollectonUtls.sNotEmpty(stopLst) || CollectonUtls.sNotEmpty(kllLst) || !sComplementEnd()) { return ExecutonStatus.STOP; } else { return ExecutonStatus.SUCCESS; } } // success f (state == ExecutonStatus.RUNNING_EXECUTION) { Lst<TaskInstance> kllTasks = getCompleteTaskByState(ExecutonStatus.KILL); f (readyToSubmtTaskQueue.sze() > 0) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
//tasks cu return ExecutonStatus.RUNNING_EXECUTION; } else f (CollectonUtls.sNotEmpty(kllTasks)) { // tasks m return ExecutonStatus.FAILURE; } else { // f the return ExecutonStatus.SUCCESS; } } return state; } /** * whether complement end * * @return Boolean whether s complement end */ prvate boolean sComplementEnd() { f (!processInstance.sComplementData()) { return true; } try { Map<Strng, Strng> cmdParam = JSONUtls.toMap(processInstance.getCommandParam()); Date endTme = DateUtls.getScheduleDate(cmdParam.get(CMDPARAM_COMPLEMENT_DATA_END_DATE)); return processInstance.getScheduleTme().equals(endTme); } catch (Excepton e) { logger.error("complement end faled ", e); return false; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
/** * updateProcessInstance process nstance state * after each batch of tasks s executed, the status of the process nstance s updated */ prvate vod updateProcessInstanceState() { ProcessInstance nstance = processServce.fndProcessInstanceById(processInstance.getId()); ExecutonStatus state = getProcessInstanceState(nstance); f (processInstance.getState() != state) { logger.nfo( "work flow process nstance [d: {}, name:{}], state change from {} to {}, cmd type: {}", processInstance.getId(), processInstance.getName(), processInstance.getState(), state, processInstance.getCommandType()); nstance.setState(state); processServce.updateProcessInstance(nstance); processInstance = nstance; StateEvent stateEvent = new StateEvent(); stateEvent.setExecutonStatus(processInstance.getState()); stateEvent.setProcessInstanceId(ths.processInstance.getId()); stateEvent.setType(StateEventType.PROCESS_STATE_CHANGE); ths.processStateChangeHandler(stateEvent); } } /** * get task dependency result * * @param taskInstance task nstance * @return DependResult */ prvate DependResult getDependResultForTask(TaskInstance taskInstance) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
return sTaskDepsComplete(taskInstance.getName()); } /** * add task to standby lst * * @param taskInstance task nstance */ prvate vod addTaskToStandByLst(TaskInstance taskInstance) { logger.nfo("add task to stand by lst: {}", taskInstance.getName()); try { readyToSubmtTaskQueue.put(taskInstance); } catch (Excepton e) { logger.error("add task nstance to readyToSubmtTaskQueue error, taskName: {}", taskInstance.getName(), e); } } /** * remove task from stand by lst * * @param taskInstance task nstance */ prvate vod removeTaskFromStandbyLst(TaskInstance taskInstance) { logger.nfo("remove task from stand by lst, d: {} name:{}", taskInstance.getId(), taskInstance.getName()); try { readyToSubmtTaskQueue.remove(taskInstance); } catch (Excepton e) { logger.error("remove task nstance from readyToSubmtTaskQueue error, task d:{}, Name: {}", taskInstance.getId(), taskInstance.getName(), e);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
} } /** * has retry task n standby * * @return Boolean whether has retry task n standby */ prvate boolean hasRetryTaskInStandBy() { for (Iterator<TaskInstance> ter = readyToSubmtTaskQueue.terator(); ter.hasNext(); ) { f (ter.next().getState().typeIsFalure()) { return true; } } return false; } /** * close the on gong tasks */ prvate vod kllAllTasks() { logger.nfo("kll called on process nstance d: {}, num: {}", processInstance.getId(), actveTaskProcessorMaps.sze()); for (nt taskId : actveTaskProcessorMaps.keySet()) { TaskInstance taskInstance = processServce.fndTaskInstanceById(taskId); f (taskInstance == null || taskInstance.getState().typeIsFnshed()) { contnue; } ITaskProcessor taskProcessor = actveTaskProcessorMaps.get(taskId); taskProcessor.acton(TaskActon.STOP); f (taskProcessor.taskState().typeIsFnshed()) { StateEvent stateEvent = new StateEvent();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
stateEvent.setType(StateEventType.TASK_STATE_CHANGE); stateEvent.setProcessInstanceId(ths.processInstance.getId()); stateEvent.setTaskInstanceId(taskInstance.getId()); stateEvent.setExecutonStatus(taskProcessor.taskState()); ths.addStateEvent(stateEvent); } } } publc boolean workFlowFnsh() { return ths.processInstance.getState().typeIsFnshed(); } /** * whether the retry nterval s tmed out * * @param taskInstance task nstance * @return Boolean */ prvate boolean retryTaskIntervalOverTme(TaskInstance taskInstance) { f (taskInstance.getState() != ExecutonStatus.FAILURE) { return true; } f (taskInstance.getId() == 0 || taskInstance.getMaxRetryTmes() == 0 || taskInstance.getRetryInterval() == 0) { return true; } Date now = new Date(); long faledTmeInterval = DateUtls.dfferSec(now, taskInstance.getEndTme());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
// task retry does not over tme, return false return taskInstance.getRetryInterval() * SEC_2_MINUTES_TIME_UNIT < faledTmeInterval; } /** * handlng the lst of tasks to be submtted */ prvate vod submtStandByTask() { try { nt length = readyToSubmtTaskQueue.sze(); for (nt = 0; < length; ++) { TaskInstance task = readyToSubmtTaskQueue.peek(); f (task == null) { contnue; } // stop ta f (task.taskCanRetry()) { TaskInstance retryTask = processServce.fndTaskInstanceById(task.getId()); f (retryTask != null && retryTask.getState().equals(ExecutonStatus.FORCED_SUCCESS)) { task.setState(retryTask.getState()); logger.nfo("task: {} has been forced success, put t nto complete task lst and stop retryng", task.getName()); removeTaskFromStandbyLst(task); completeTaskLst.put(task.getName(), task); submtPostNode(task.getName()); contnue; } } //nt var f (task.sFrstRun()) { //get pre Set<Strng> preTask = dag.getPrevousNodes(task.getName());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
getPreVarPool(task, preTask); } DependResult dependResult = getDependResultForTask(task); f (DependResult.SUCCESS == dependResult) { f (retryTaskIntervalOverTme(task)) { TaskInstance taskInstance = submtTaskExec(task); f (taskInstance == null) { ths.taskFaledSubmt = true; } else { removeTaskFromStandbyLst(task); } } } else f (DependResult.FAILED == dependResult) { // f the dependFaledTask.put(task.getName(), task); removeTaskFromStandbyLst(task); logger.nfo("task {},d:{} depend result : {}", task.getName(), task.getId(), dependResult); } else f (DependResult.NON_EXEC == dependResult) { // for som removeTaskFromStandbyLst(task); logger.nfo("remove task {},d:{} , because depend result : {}", task.getName(), task.getId(), dependResult); } } } catch (Excepton e) { logger.error("submt standby task error", e); } } /** * get recovery task nstance *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
* @param taskId task d * @return recovery task nstance */ prvate TaskInstance getRecoveryTaskInstance(Strng taskId) { f (!StrngUtls.sNotEmpty(taskId)) { return null; } try { Integer ntId = Integer.valueOf(taskId); TaskInstance task = processServce.fndTaskInstanceById(ntId); f (task == null) { logger.error("start node d cannot be found: {}", taskId); } else { return task; } } catch (Excepton e) { logger.error("get recovery task nstance faled ", e); } return null; } /** * get start task nstance lst * * @param cmdParam command param * @return task nstance lst */ prvate Lst<TaskInstance> getStartTaskInstanceLst(Strng cmdParam) { Lst<TaskInstance> nstanceLst = new ArrayLst<>(); Map<Strng, Strng> paramMap = JSONUtls.toMap(cmdParam); f (paramMap != null && paramMap.contansKey(CMD_PARAM_RECOVERY_START_NODE_STRING)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
Strng[] dLst = paramMap.get(CMD_PARAM_RECOVERY_START_NODE_STRING).splt(Constants.COMMA); for (Strng nodeId : dLst) { TaskInstance task = getRecoveryTaskInstance(nodeId); f (task != null) { nstanceLst.add(task); } } } return nstanceLst; } /** * parse "StartNodeNameLst" from cmd param * * @param cmdParam command param * @return start node name lst */ prvate Lst<Strng> parseStartNodeName(Strng cmdParam) { Lst<Strng> startNodeNameLst = new ArrayLst<>(); Map<Strng, Strng> paramMap = JSONUtls.toMap(cmdParam); f (paramMap == null) { return startNodeNameLst; } f (paramMap.contansKey(CMD_PARAM_START_NODE_NAMES)) { startNodeNameLst = Arrays.asLst(paramMap.get(CMD_PARAM_START_NODE_NAMES).splt(Constants.COMMA)); } return startNodeNameLst; } /** * generate start node name lst from parsng command param; * f "StartNodeIdLst" exsts n command param, return StartNodeIdLst
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,353
[Bug] [Master] dispatch task to worker very slowly
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev i find master dispatch tasks to worker slowly . mysql> select count(*),state from t_ds_task_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 15347 | 7 | | 12 | 1 | +----------+-------+ 2 rows in set (0.01 sec) mysql> select count(*),state from t_ds_process_instance group by state; +----------+-------+ | count(*) | state | +----------+-------+ | 892 | 7 | | 12109 | 1 | +----------+-------+ ### What you expected to happen Optimize the speed of dispatch task ### How to reproduce create a dag ![image](https://user-images.githubusercontent.com/29528966/134792830-967b6674-52c8-4241-a02e-c4c23b593904.png) schedule the dag '0 * * * * ? *' run the dag with 'complement data' you will find the process_instance count: 12109 but the task (state=1) number is 12 This phenomenon is not normal ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6353
https://github.com/apache/dolphinscheduler/pull/6375
b2a2fbda1d25c4eb18cf58ceb6d062b74855cedd
67094d0f7f1803e263e73a0164ecbbd829c57129
"2021-09-26T03:49:00Z"
java
"2021-09-27T11:31:22Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
* * @return recovery node name lst */ prvate Lst<Strng> getRecoveryNodeNameLst() { Lst<Strng> recoveryNodeNameLst = new ArrayLst<>(); f (CollectonUtls.sNotEmpty(recoverNodeIdLst)) { for (TaskInstance task : recoverNodeIdLst) { recoveryNodeNameLst.add(task.getName()); } } return recoveryNodeNameLst; } /** * generate flow dag * * @param totalTaskNodeLst total task node lst * @param startNodeNameLst start node name lst * @param recoveryNodeNameLst recovery node name lst * @param depNodeType depend node type * @return ProcessDag process dag * @throws Excepton excepton */ publc ProcessDag generateFlowDag(Lst<TaskNode> totalTaskNodeLst, Lst<Strng> startNodeNameLst, Lst<Strng> recoveryNodeNameLst, TaskDependType depNodeType) throws Excepton { return DagHelper.generateFlowDag(totalTaskNodeLst, startNodeNameLst, recoveryNodeNameLst, depNodeType); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.plugin.task.sql; import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor; import org.apache.dolphinscheduler.plugin.task.api.TaskException; import org.apache.dolphinscheduler.plugin.task.datasource.BaseConnectionParam; import org.apache.dolphinscheduler.plugin.task.datasource.DatasourceUtil; import org.apache.dolphinscheduler.plugin.task.util.MapUtils; import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.dolphinscheduler.spi.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.spi.task.AbstractParameters; import org.apache.dolphinscheduler.spi.task.Direct;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
import org.apache.dolphinscheduler.spi.task.Property; import org.apache.dolphinscheduler.spi.task.TaskAlertInfo; import org.apache.dolphinscheduler.spi.task.TaskConstants; import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils; import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; import org.apache.dolphinscheduler.spi.task.request.SQLTaskExecutionContext; import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import org.apache.dolphinscheduler.spi.task.request.UdfFuncRequest; import org.apache.dolphinscheduler.spi.utils.CollectionUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import org.slf4j.Logger; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; public class SqlTask extends AbstractTaskExecutor {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
/** * taskExecutionContext */ private TaskRequest taskExecutionContext; /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
* sql parameters */ private SqlParameters sqlParameters; /** * base datasource */ private BaseConnectionParam baseConnectionParam; /** * create function format */ private static final String CREATE_FUNCTION_FORMAT = "create temporary function {0} as ''{1}''"; /** * Abstract Yarn Task * * @param taskRequest taskRequest */ public SqlTask(TaskRequest taskRequest) { super(taskRequest); this.taskExecutionContext = taskRequest; this.sqlParameters = JSONUtils.parseObject(taskExecutionContext.getTaskParams(), SqlParameters.class); assert sqlParameters != null; if (!sqlParameters.checkParameters()) { throw new RuntimeException("sql task params is not valid"); } } @Override public AbstractParameters getParameters() { return sqlParameters; } @Override
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
public void handle() throws Exception { String threadLoggerInfoName = String.format(TaskConstants.TASK_LOG_INFO_FORMAT, taskExecutionContext.getTaskAppId()); Thread.currentThread().setName(threadLoggerInfoName); logger.info("Full sql parameters: {}", sqlParameters); logger.info("sql type : {}, datasource : {}, sql : {} , localParams : {},udfs : {},showType : {},connParams : {},varPool : {} ,query max result limit {}", sqlParameters.getType(), sqlParameters.getDatasource(), sqlParameters.getSql(), sqlParameters.getLocalParams(), sqlParameters.getUdfs(), sqlParameters.getShowType(), sqlParameters.getConnParams(), sqlParameters.getVarPool(), sqlParameters.getLimit()); try { SQLTaskExecutionContext sqlTaskExecutionContext = taskExecutionContext.getSqlTaskExecutionContext(); baseConnectionParam = (BaseConnectionParam) DatasourceUtil.buildConnectionParams( DbType.valueOf(sqlParameters.getType()), sqlTaskExecutionContext.getConnectionParams()); SqlBinds mainSqlBinds = getSqlAndSqlParamsMap(sqlParameters.getSql()); List<SqlBinds> preStatementSqlBinds = Optional.ofNullable(sqlParameters.getPreStatements()) .orElse(new ArrayList<>()) .stream() .map(this::getSqlAndSqlParamsMap) .collect(Collectors.toList()); List<SqlBinds> postStatementSqlBinds = Optional.ofNullable(sqlParameters.getPostStatements()) .orElse(new ArrayList<>())
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
.stream() .map(this::getSqlAndSqlParamsMap) .collect(Collectors.toList()); List<String> createFuncs = createFuncs(sqlTaskExecutionContext.getUdfFuncTenantCodeMap(), logger); executeFuncAndSql(mainSqlBinds, preStatementSqlBinds, postStatementSqlBinds, createFuncs); setExitStatusCode(TaskConstants.EXIT_CODE_SUCCESS); } catch (Exception e) { setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE); logger.error("sql task error: {}", e.toString()); throw e; } } /** * execute function and sql * * @param mainSqlBinds main sql binds * @param preStatementsBinds pre statements binds * @param postStatementsBinds post statements binds * @param createFuncs create functions */ public void executeFuncAndSql(SqlBinds mainSqlBinds, List<SqlBinds> preStatementsBinds, List<SqlBinds> postStatementsBinds, List<String> createFuncs) throws Exception { Connection connection = null; PreparedStatement stmt = null; ResultSet resultSet = null; try {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
connection = DatasourceUtil.getConnection(DbType.valueOf(sqlParameters.getType()), baseConnectionParam); if (CollectionUtils.isNotEmpty(createFuncs)) { createTempFunction(connection, createFuncs); } preSql(connection, preStatementsBinds); stmt = prepareStatementAndBind(connection, mainSqlBinds); String result = null; if (sqlParameters.getSqlType() == SqlType.QUERY.ordinal()) { resultSet = stmt.executeQuery(); result = resultProcess(resultSet); } else if (sqlParameters.getSqlType() == SqlType.NON_QUERY.ordinal()) { String updateResult = String.valueOf(stmt.executeUpdate()); result = setNonQuerySqlReturn(updateResult, sqlParameters.getLocalParams()); } sqlParameters.dealOutParam(result); postSql(connection, postStatementsBinds); } catch (Exception e) { logger.error("execute sql error: {}", e.getMessage()); throw e; } finally { close(resultSet, stmt, connection); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
private String setNonQuerySqlReturn(String updateResult, List<Property> properties) { String result = null; for (Property info : properties) { if (Direct.OUT == info.getDirect()) { List<Map<String, String>> updateRL = new ArrayList<>(); Map<String, String> updateRM = new HashMap<>(); updateRM.put(info.getProp(), updateResult); updateRL.add(updateRM); result = JSONUtils.toJsonString(updateRL); break; } } return result; } /** * result process * * @param resultSet resultSet * @throws Exception Exception */ private String resultProcess(ResultSet resultSet) throws Exception { ArrayNode resultJSONArray = JSONUtils.createArrayNode(); if (resultSet != null) { ResultSetMetaData md = resultSet.getMetaData(); int num = md.getColumnCount(); int rowCount = 0; while (rowCount < sqlParameters.getLimit() && resultSet.next()) { ObjectNode mapOfColValues = JSONUtils.createObjectNode(); for (int i = 1; i <= num; i++) { mapOfColValues.set(md.getColumnLabel(i), JSONUtils.toJsonNode(resultSet.getObject(i)));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
} resultJSONArray.add(mapOfColValues); rowCount++; } int displayRows = sqlParameters.getDisplayRows() > 0 ? sqlParameters.getDisplayRows() : TaskConstants.DEFAULT_DISPLAY_ROWS; displayRows = Math.min(displayRows, resultJSONArray.size()); logger.info("display sql result {} rows as follows:", displayRows); for (int i = 0; i < displayRows; i++) { String row = JSONUtils.toJsonString(resultJSONArray.get(i)); logger.info("row {} : {}", i + 1, row); } } String result = JSONUtils.toJsonString(resultJSONArray); if (sqlParameters.getSendEmail() == null || sqlParameters.getSendEmail()) { sendAttachment(sqlParameters.getGroupId(), StringUtils.isNotEmpty(sqlParameters.getTitle()) ? sqlParameters.getTitle() : taskExecutionContext.getTaskName() + " query result sets", result); } logger.debug("execute sql result : {}", result); return result; } /** * send alert as an attachment * * @param title title * @param content content */ private void sendAttachment(int groupId, String title, String content) { setNeedAlert(Boolean.TRUE); TaskAlertInfo taskAlertInfo = new TaskAlertInfo();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
taskAlertInfo.setAlertGroupId(groupId); taskAlertInfo.setContent(content); taskAlertInfo.setTitle(title); } /** * pre sql * * @param connection connection * @param preStatementsBinds preStatementsBinds */ private void preSql(Connection connection, List<SqlBinds> preStatementsBinds) throws Exception { for (SqlBinds sqlBind : preStatementsBinds) { try (PreparedStatement pstmt = prepareStatementAndBind(connection, sqlBind)) { int result = pstmt.executeUpdate(); logger.info("pre statement execute result: {}, for sql: {}", result, sqlBind.getSql()); } } } /** * post sql * * @param connection connection * @param postStatementsBinds postStatementsBinds */ private void postSql(Connection connection, List<SqlBinds> postStatementsBinds) throws Exception { for (SqlBinds sqlBind : postStatementsBinds) { try (PreparedStatement pstmt = prepareStatementAndBind(connection, sqlBind)) { int result = pstmt.executeUpdate();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
logger.info("post statement execute result: {},for sql: {}", result, sqlBind.getSql()); } } } /** * create temp function * * @param connection connection * @param createFuncs createFuncs */ private void createTempFunction(Connection connection, List<String> createFuncs) throws Exception { try (Statement funcStmt = connection.createStatement()) { for (String createFunc : createFuncs) { logger.info("hive create function sql: {}", createFunc); funcStmt.execute(createFunc); } } } /** * close jdbc resource * * @param resultSet resultSet * @param pstmt pstmt * @param connection connection */ private void close(ResultSet resultSet, PreparedStatement pstmt, Connection connection) { if (resultSet != null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
try { resultSet.close(); } catch (SQLException e) { logger.error("close result set error : {}", e.getMessage(), e); } } if (pstmt != null) { try { pstmt.close(); } catch (SQLException e) { logger.error("close prepared statement error : {}", e.getMessage(), e); } } if (connection != null) { try { connection.close(); } catch (SQLException e) { logger.error("close connection error : {}", e.getMessage(), e); } } } /** * preparedStatement bind * * @param connection connection * @param sqlBinds sqlBinds * @return PreparedStatement * @throws Exception Exception */ private PreparedStatement prepareStatementAndBind(Connection connection, SqlBinds sqlBinds) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
boolean timeoutFlag = taskExecutionContext.getTaskTimeoutStrategy() == TaskTimeoutStrategy.FAILED || taskExecutionContext.getTaskTimeoutStrategy() == TaskTimeoutStrategy.WARNFAILED; try { PreparedStatement stmt = connection.prepareStatement(sqlBinds.getSql()); if (timeoutFlag) { stmt.setQueryTimeout(taskExecutionContext.getTaskTimeout()); } Map<Integer, Property> params = sqlBinds.getParamsMap(); if (params != null) { for (Map.Entry<Integer, Property> entry : params.entrySet()) { Property prop = entry.getValue(); ParameterUtils.setInParameter(entry.getKey(), stmt, prop.getType(), prop.getValue()); } } logger.info("prepare statement replace sql : {} ", stmt); return stmt; } catch (Exception exception) { throw new TaskException("SQL task prepareStatementAndBind error", exception); } } /** * regular expressions match the contents between two specified strings * * @param content content * @param rgex rgex * @param sqlParamsMap sql params map * @param paramsPropsMap params props map */ public void setSqlParamsMap(String content, String rgex, Map<Integer, Property> sqlParamsMap, Map<String, Property> paramsPropsMap) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
Pattern pattern = Pattern.compile(rgex); Matcher m = pattern.matcher(content); int index = 1; while (m.find()) { String paramName = m.group(1); Property prop = paramsPropsMap.get(paramName); if (prop == null) { logger.error("setSqlParamsMap: No Property with paramName: {} is found in paramsPropsMap of task instance" + " with id: {}. So couldn't put Property in sqlParamsMap.", paramName, taskExecutionContext.getTaskInstanceId()); } else { sqlParamsMap.put(index, prop); index++; logger.info("setSqlParamsMap: Property with paramName: {} put in sqlParamsMap of content {} successfully.", paramName, content); } } } /** * print replace sql * * @param content content * @param formatSql format sql * @param rgex rgex * @param sqlParamsMap sql params map */ private void printReplacedSql(String content, String formatSql, String rgex, Map<Integer, Property> sqlParamsMap) { logger.info("after replace sql , preparing : {}", formatSql); StringBuilder logPrint = new StringBuilder("replaced sql , parameters:"); if (sqlParamsMap == null) { logger.info("printReplacedSql: sqlParamsMap is null.");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
} else { for (int i = 1; i <= sqlParamsMap.size(); i++) { logPrint.append(sqlParamsMap.get(i).getValue()).append("(").append(sqlParamsMap.get(i).getType()).append(")"); } } logger.info("Sql Params are {}", logPrint); } /** * ready to execute SQL and parameter entity Map * * @return SqlBinds */ private SqlBinds getSqlAndSqlParamsMap(String sql) { Map<Integer, Property> sqlParamsMap = new HashMap<>(); StringBuilder sqlBuilder = new StringBuilder(); Map<String, Property> paramsMap = ParamUtils.convert(taskExecutionContext, getParameters()); if (paramsMap == null) { sqlBuilder.append(sql); return new SqlBinds(sqlBuilder.toString(), sqlParamsMap); } if (StringUtils.isNotEmpty(sqlParameters.getTitle())) { String title = ParameterUtils.convertParameterPlaceholders(sqlParameters.getTitle(), ParamUtils.convert(paramsMap)); logger.info("SQL title : {}", title); sqlParameters.setTitle(title); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
sql = ParameterUtils.replaceScheduleTime(sql, taskExecutionContext.getScheduleTime()); String rgex = "['\"]*\\$\\{(.*?)\\}['\"]*"; setSqlParamsMap(sql, rgex, sqlParamsMap, paramsMap); String rgexo = "['\"]*\\!\\{(.*?)\\}['\"]*"; sql = replaceOriginalValue(sql, rgexo, paramsMap); // r String formatSql = sql.replaceAll(rgex, "?"); sqlBuilder.append(formatSql); // p printReplacedSql(sql, formatSql, rgex, sqlParamsMap); return new SqlBinds(sqlBuilder.toString(), sqlParamsMap); } private String replaceOriginalValue(String content, String rgex, Map<String, Property> sqlParamsMap) { Pattern pattern = Pattern.compile(rgex); while (true) { Matcher m = pattern.matcher(content); if (!m.find()) { break; } String paramName = m.group(1); String paramValue = sqlParamsMap.get(paramName).getValue(); content = m.replaceFirst(paramValue); } return content; } /** * create function list *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,367
[Bug] [Plugin TIS] Misuseing PowerMockito.spy lead to UT faild
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In Plugin TIS TestCase , by misuseing PowerMockito.spy lead to UT faild [https://github.com/apache/dolphinscheduler/pull/6363/checks](https://github.com/apache/dolphinscheduler/pull/6363/checks) ``` Error: Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.786 s <<< FAILURE! - in org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest Error: testInit(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.531 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testGetTISConfigParams(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) Error: testHandle(org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest) Time elapsed: 0.001 s <<< ERROR! java.lang.IllegalArgumentException: name argument cannot be null at org.apache.dolphinscheduler.plugin.task.tis.TISTaskTest.before(TISTaskTest.java:71) ``` ### What you expected to happen make the UT pass ### How to reproduce for fix this bug ,shoud remote PowerMockito.spy() invoking ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6367
https://github.com/apache/dolphinscheduler/pull/6387
cdcbe84c8a1bb1e5286568f42d2eb2ff530dbe6a
a62a7a7216fe2021d1516b6d7370598123cced37
"2021-09-27T03:24:56Z"
java
"2021-09-28T03:38:22Z"
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
* @param udfFuncTenantCodeMap key is udf function,value is tenant code * @param logger logger * @return create function list */ public static List<String> createFuncs(Map<UdfFuncRequest, String> udfFuncTenantCodeMap, Logger logger) { if (MapUtils.isEmpty(udfFuncTenantCodeMap)) { logger.info("can't find udf function resource"); return null; } List<String> funcList = new ArrayList<>(); // b buildTempFuncSql(funcList, new ArrayList<>(udfFuncTenantCodeMap.keySet())); return funcList; } /** * b * * @param sqls sql list * @param udfFuncRequests udf function list */ private static void buildTempFuncSql(List<String> sqls, List<UdfFuncRequest> udfFuncRequests) { if (CollectionUtils.isNotEmpty(udfFuncRequests)) { for (UdfFuncRequest udfFuncRequest : udfFuncRequests) { sqls.add(MessageFormat .format(CREATE_FUNCTION_FORMAT, udfFuncRequest.getFuncName(), udfFuncRequest.getClassName())); } } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/builder/TaskExecutionContextBuilder.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.server.builder; import static org.apache.dolphinscheduler.common.Constants.SEC_2_MINUTES_TIME_UNIT; import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; import org.apache.dolphinscheduler.spi.task.request.DataxTaskExecutionContext; import org.apache.dolphinscheduler.spi.task.request.ProcedureTaskExecutionContext; import org.apache.dolphinscheduler.spi.task.request.SQLTaskExecutionContext;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/builder/TaskExecutionContextBuilder.java
import org.apache.dolphinscheduler.spi.task.request.SqoopTaskExecutionContext; /** * TaskExecutionContext builder */ public class TaskExecutionContextBuilder { public static TaskExecutionContextBuilder get() { return new TaskExecutionContextBuilder(); } private TaskExecutionContext taskExecutionContext = new TaskExecutionContext(); /** * build taskInstance related info * * @param taskInstance taskInstance * @return TaskExecutionContextBuilder */ public TaskExecutionContextBuilder buildTaskInstanceRelatedInfo(TaskInstance taskInstance) { taskExecutionContext.setTaskInstanceId(taskInstance.getId()); taskExecutionContext.setTaskName(taskInstance.getName()); taskExecutionContext.setFirstSubmitTime(taskInstance.getFirstSubmitTime()); taskExecutionContext.setStartTime(taskInstance.getStartTime()); taskExecutionContext.setTaskType(taskInstance.getTaskType()); taskExecutionContext.setLogPath(taskInstance.getLogPath()); taskExecutionContext.setWorkerGroup(taskInstance.getWorkerGroup()); taskExecutionContext.setEnvironmentConfig(taskInstance.getEnvironmentConfig()); taskExecutionContext.setHost(taskInstance.getHost()); taskExecutionContext.setResources(taskInstance.getResources()); taskExecutionContext.setDelayTime(taskInstance.getDelayTime()); taskExecutionContext.setVarPool(taskInstance.getVarPool()); return this; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/builder/TaskExecutionContextBuilder.java
public TaskExecutionContextBuilder buildTaskDefinitionRelatedInfo(TaskDefinition taskDefinition) { taskExecutionContext.setTaskTimeout(Integer.MAX_VALUE); if (taskDefinition.getTimeoutFlag() == TimeoutFlag.OPEN) { taskExecutionContext.setTaskTimeoutStrategy(taskDefinition.getTimeoutNotifyStrategy()); if (taskDefinition.getTimeoutNotifyStrategy() == TaskTimeoutStrategy.FAILED || taskDefinition.getTimeoutNotifyStrategy() == TaskTimeoutStrategy.WARNFAILED) { taskExecutionContext.setTaskTimeout(Math.min(taskDefinition.getTimeout() * SEC_2_MINUTES_TIME_UNIT, Integer.MAX_VALUE)); } } taskExecutionContext.setTaskParams(taskDefinition.getTaskParams()); return this; } /** * build processInstance related info * * @param processInstance processInstance * @return TaskExecutionContextBuilder */ public TaskExecutionContextBuilder buildProcessInstanceRelatedInfo(ProcessInstance processInstance) { taskExecutionContext.setProcessInstanceId(processInstance.getId()); taskExecutionContext.setScheduleTime(processInstance.getScheduleTime()); taskExecutionContext.setGlobalParams(processInstance.getGlobalParams()); taskExecutionContext.setExecutorId(processInstance.getExecutorId()); taskExecutionContext.setCmdTypeIfComplement(processInstance.getCmdTypeIfComplement().getCode()); taskExecutionContext.setTenantCode(processInstance.getTenantCode()); taskExecutionContext.setQueue(processInstance.getQueue()); return this; } /** * build processDefinition related info
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/builder/TaskExecutionContextBuilder.java
* * @param processDefinition processDefinition * @return TaskExecutionContextBuilder */ public TaskExecutionContextBuilder buildProcessDefinitionRelatedInfo(ProcessDefinition processDefinition) { taskExecutionContext.setProcessDefineCode(processDefinition.getCode()); taskExecutionContext.setProcessDefineVersion(processDefinition.getVersion()); taskExecutionContext.setProjectCode(processDefinition.getProjectCode()); return this; } /** * build SQLTask related info * * @param sqlTaskExecutionContext sqlTaskExecutionContext * @return TaskExecutionContextBuilder */ public TaskExecutionContextBuilder buildSQLTaskRelatedInfo(SQLTaskExecutionContext sqlTaskExecutionContext) { taskExecutionContext.setSqlTaskExecutionContext(sqlTaskExecutionContext); return this; } /** * build DataxTask related info * * @param dataxTaskExecutionContext dataxTaskExecutionContext * @return TaskExecutionContextBuilder */ public TaskExecutionContextBuilder buildDataxTaskRelatedInfo(DataxTaskExecutionContext dataxTaskExecutionContext) { taskExecutionContext.setDataxTaskExecutionContext(dataxTaskExecutionContext); return this; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/builder/TaskExecutionContextBuilder.java
/** * build procedureTask related info * * @param procedureTaskExecutionContext procedureTaskExecutionContext * @return TaskExecutionContextBuilder */ public TaskExecutionContextBuilder buildProcedureTaskRelatedInfo(ProcedureTaskExecutionContext procedureTaskExecutionContext) { taskExecutionContext.setProcedureTaskExecutionContext(procedureTaskExecutionContext); return this; } /** * build sqoopTask related info * * @param sqoopTaskExecutionContext sqoopTaskExecutionContext * @return TaskExecutionContextBuilder */ public TaskExecutionContextBuilder buildSqoopTaskRelatedInfo(SqoopTaskExecutionContext sqoopTaskExecutionContext) { taskExecutionContext.setSqoopTaskExecutionContext(sqoopTaskExecutionContext); return this; } /** * create * * @return taskExecutionContext */ public TaskExecutionContext create() { return taskExecutionContext; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java
* * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.server.worker.runner; import static java.util.Calendar.DAY_OF_MONTH; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.Event; import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.process.Property; import org.apache.dolphinscheduler.common.utils.CommonUtils; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.HadoopUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.LoggerUtils; import org.apache.dolphinscheduler.common.utils.OSUtils; import org.apache.dolphinscheduler.common.utils.RetryerUtils; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.TaskExecuteAckCommand; import org.apache.dolphinscheduler.remote.command.TaskExecuteResponseCommand; import org.apache.dolphinscheduler.server.utils.ProcessUtils; import org.apache.dolphinscheduler.server.worker.cache.ResponceCache; import org.apache.dolphinscheduler.server.worker.plugin.TaskPluginManager; import org.apache.dolphinscheduler.server.worker.processor.TaskCallbackService;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java
import org.apache.dolphinscheduler.service.alert.AlertClientService; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; import org.apache.dolphinscheduler.spi.exception.PluginNotFoundException; import org.apache.dolphinscheduler.spi.task.AbstractTask; import org.apache.dolphinscheduler.spi.task.TaskAlertInfo; import org.apache.dolphinscheduler.spi.task.TaskChannel; import org.apache.dolphinscheduler.spi.task.TaskExecutionContextCacheManager; import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; import java.io.File; import java.io.IOException; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.Delayed; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.github.rholder.retry.RetryException; /** * task scheduler thread */ public class TaskExecuteThread implements Runnable, Delayed {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java
/** * logger */ private final Logger logger = LoggerFactory.getLogger(TaskExecuteThread.class); /** * task instance */ private TaskExecutionContext taskExecutionContext; /** * abstract task */ private AbstractTask task; /** * task callback service */ private TaskCallbackService taskCallbackService; /** * taskExecutionContextCacheManager */ private TaskExecutionContextCacheManager taskExecutionContextCacheManager; /** * task logger */ private Logger taskLogger; /** * alert client server */ private AlertClientService alertClientService; private TaskPluginManager taskPluginManager;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java
/** * process database access */ protected ProcessService processService; /** * constructor * * @param taskExecutionContext taskExecutionContext * @param taskCallbackService taskCallbackService */ public TaskExecuteThread(TaskExecutionContext taskExecutionContext, TaskCallbackService taskCallbackService, AlertClientService alertClientService) { this.taskExecutionContext = taskExecutionContext; this.taskCallbackService = taskCallbackService; this.alertClientService = alertClientService; this.processService = SpringApplicationContext.getBean(ProcessService.class); } public TaskExecuteThread(TaskExecutionContext taskExecutionContext, TaskCallbackService taskCallbackService, AlertClientService alertClientService, TaskPluginManager taskPluginManager) { this.taskExecutionContext = taskExecutionContext; this.taskCallbackService = taskCallbackService; this.alertClientService = alertClientService; this.taskPluginManager = taskPluginManager; this.processService = SpringApplicationContext.getBean(ProcessService.class); } @Override public void run() {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java
TaskExecuteResponseCommand responseCommand = new TaskExecuteResponseCommand(taskExecutionContext.getTaskInstanceId(), taskExecutionContext.getProcessInstanceId()); try { logger.info("script path : {}", taskExecutionContext.getExecutePath()); if (!OSUtils.getUserList().contains(taskExecutionContext.getTenantCode())) { String errorLog = String.format("tenantCode: %s does not exist", taskExecutionContext.getTenantCode()); taskLogger.error(errorLog); responseCommand.setStatus(ExecutionStatus.FAILURE.getCode()); responseCommand.setEndTime(new Date()); return; } if (taskExecutionContext.getStartTime() == null) { taskExecutionContext.setStartTime(new Date()); } if (taskExecutionContext.getCurrentExecutionStatus() != ExecutionStatus.RUNNING_EXECUTION) { changeTaskExecutionStatusToRunning(); } logger.info("the task begins to execute. task instance id: {}", taskExecutionContext.getTaskInstanceId()); TaskInstance taskInstance = processService.findTaskInstanceById(taskExecutionContext.getTaskInstanceId()); int dryRun = taskInstance.getDryRun(); if (dryRun == Constants.DRY_RUN_FLAG_NO) { downloadResource(taskExecutionContext.getExecutePath(), taskExecutionContext.getResources(), logger); } taskExecutionContext.setEnvFile(CommonUtils.getSystemEnvPath()); taskExecutionContext.setDefinedParams(getGlobalParamsMap()); taskExecutionContext.setTaskAppId(String.format("%s_%s", taskExecutionContext.getProcessInstanceId(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java
taskExecutionContext.getTaskInstanceId())); preBuildBusinessParams(); TaskChannel taskChannel = taskPluginManager.getTaskChannelMap().get(taskExecutionContext.getTaskType()); if (null == taskChannel) { throw new PluginNotFoundException(String.format("%s Task Plugin Not Found,Please Check Config File.", taskExecutionContext.getTaskType())); } TaskRequest taskRequest = JSONUtils.parseObject(JSONUtils.toJsonString(taskExecutionContext), TaskRequest.class); String taskLogName = LoggerUtils.buildTaskId(LoggerUtils.TASK_LOGGER_INFO_PREFIX, taskExecutionContext.getProcessDefineCode(), taskExecutionContext.getProcessDefineVersion(), taskExecutionContext.getProcessInstanceId(), taskExecutionContext.getTaskInstanceId()); taskRequest.setTaskLogName(taskLogName); task = taskChannel.createTask(taskRequest); this.task.init(); this.task.getParameters().setVarPool(taskExecutionContext.getVarPool()); if (dryRun == Constants.DRY_RUN_FLAG_NO) { this.task.handle(); if (this.task.getNeedAlert()) { sendAlert(this.task.getTaskAlertInfo()); } responseCommand.setStatus(this.task.getExitStatus().getCode()); } else { responseCommand.setStatus(ExecutionStatus.SUCCESS.getCode()); task.setExitStatusCode(Constants.EXIT_CODE_SUCCESS); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java
responseCommand.setEndTime(new Date()); responseCommand.setProcessId(this.task.getProcessId()); responseCommand.setAppIds(this.task.getAppIds()); responseCommand.setVarPool(JSONUtils.toJsonString(this.task.getParameters().getVarPool())); logger.info("task instance id : {},task final status : {}", taskExecutionContext.getTaskInstanceId(), this.task.getExitStatus()); } catch (Throwable e) { logger.error("task scheduler failure", e); kill(); responseCommand.setStatus(ExecutionStatus.FAILURE.getCode()); responseCommand.setEndTime(new Date()); responseCommand.setProcessId(task.getProcessId()); responseCommand.setAppIds(task.getAppIds()); } finally { TaskExecutionContextCacheManager.removeByTaskInstanceId(taskExecutionContext.getTaskInstanceId()); ResponceCache.get().cache(taskExecutionContext.getTaskInstanceId(), responseCommand.convert2Command(), Event.RESULT); taskCallbackService.sendResult(taskExecutionContext.getTaskInstanceId(), responseCommand.convert2Command()); clearTaskExecPath(); } } private void sendAlert(TaskAlertInfo taskAlertInfo) { alertClientService.sendAlert(taskAlertInfo.getAlertGroupId(), taskAlertInfo.getTitle(), taskAlertInfo.getContent()); } /** * when task finish, clear execute path. */ private void clearTaskExecPath() { logger.info("develop mode is: {}", CommonUtils.isDevelopMode()); if (!CommonUtils.isDevelopMode()) { String execLocalPath = taskExecutionContext.getExecutePath();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,438
[Improvement][Worker] remove meaningless DB query
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description remove meaningless DB query org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread In the process of task kill, it will query the DB to obtain the task instance object, but this judgment does not make any sense. In fact, the relevant context is already clear, so there is no need to query from DB. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6438
https://github.com/apache/dolphinscheduler/pull/6440
d284e44d52f75bd6c5f5756d9b7ae4a5af24fadc
ea2a8d26a0d42683309b8bda9ef24f4daaab266b
"2021-10-01T17:01:38Z"
java
"2021-10-02T05:09:00Z"
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java
if (StringUtils.isEmpty(execLocalPath)) { logger.warn("task: {} exec local path is empty.", taskExecutionContext.getTaskName()); return; } if ("/".equals(execLocalPath)) { logger.warn("task: {} exec local path is '/', direct deletion is not allowed", taskExecutionContext.getTaskName()); return; } try { org.apache.commons.io.FileUtils.deleteDirectory(new File(execLocalPath)); logger.info("exec local path: {} cleared.", execLocalPath); } catch (IOException e) { logger.error("delete exec dir failed : {}", e.getMessage(), e); } } } /** * get global paras map * * @return map */ private Map<String, String> getGlobalParamsMap() { Map<String, String> globalParamsMap = new HashMap<>(16); String globalParamsStr = taskExecutionContext.getGlobalParams(); if (globalParamsStr != null) { List<Property> globalParamsList = JSONUtils.toList(globalParamsStr, Property.class); globalParamsMap.putAll(globalParamsList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue))); } return globalParamsMap;