Skip to content

Commit

Permalink
Fix task execution cleanup
Browse files Browse the repository at this point in the history
 - Fix the result set matching on the query. This is needed especially on Postgres
 - Fix the task cleanup to allow the task executions that don't have external execution IDs

Resolves spring-cloud#4532
Resolves spring-cloud#4533
  • Loading branch information
ilayaperumalg authored and Glenn Renfro committed May 27, 2021
1 parent d98efa6 commit 393622e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ public class JdbcDataflowTaskExecutionDao implements DataflowTaskExecutionDao {
private static final String FIND_TASK_EXECUTION_IDS_BY_TASK_NAME = "SELECT TASK_EXECUTION_ID "
+ "from %PREFIX%EXECUTION where TASK_NAME = :taskName";

private static final String GET_COMPLETED_TASK_EXECUTIONS_COUNT = "SELECT COUNT(TASK_EXECUTION_ID) "
private static final String GET_COMPLETED_TASK_EXECUTIONS_COUNT = "SELECT COUNT(TASK_EXECUTION_ID) AS count "
+ "from %PREFIX%EXECUTION where END_TIME IS NOT NULL";

private static final String GET_ALL_TASK_EXECUTIONS_COUNT = "SELECT COUNT(TASK_EXECUTION_ID) "
private static final String GET_ALL_TASK_EXECUTIONS_COUNT = "SELECT COUNT(TASK_EXECUTION_ID) AS count "
+ "from %PREFIX%EXECUTION";

private static final String GET_COMPLETED_TASK_EXECUTIONS_COUNT_BY_TASK_NAME = "SELECT COUNT(TASK_EXECUTION_ID) "
private static final String GET_COMPLETED_TASK_EXECUTIONS_COUNT_BY_TASK_NAME = "SELECT COUNT(TASK_EXECUTION_ID) AS count "
+ "from %PREFIX%EXECUTION where END_TIME IS NOT NULL AND TASK_NAME = :taskName";

private static final String GET_ALL_TASK_EXECUTIONS_COUNT_BY_TASK_NAME = "SELECT COUNT(TASK_EXECUTION_ID) "
private static final String GET_ALL_TASK_EXECUTIONS_COUNT_BY_TASK_NAME = "SELECT COUNT(TASK_EXECUTION_ID) AS count "
+ "from %PREFIX%EXECUTION where TASK_NAME = :taskName";

private static final String FIND_ALL_COMPLETED_TASK_EXECUTION_IDS = "SELECT TASK_EXECUTION_ID "
Expand Down Expand Up @@ -210,7 +210,7 @@ public Integer getAllTaskExecutionsCount(boolean onlyCompleted, String taskName)
public Integer extractData(ResultSet resultSet)
throws SQLException, DataAccessException {
if (resultSet.next()) {
return resultSet.getInt("COUNT(TASK_EXECUTION_ID)");
return resultSet.getInt("count");
}
return Integer.valueOf(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ public void cleanupExecution(long id) {
TaskExecution taskExecution = taskExplorer.getTaskExecution(id);
Assert.notNull(taskExecution, "There was no task execution with id " + id);
String launchId = taskExecution.getExternalExecutionId();
Assert.hasLength(launchId, "The TaskExecution for id " + id + " did not have an externalExecutionId");
if (!StringUtils.hasText(launchId)) {
logger.warn(String.format("Did not find External execution ID for taskName = [%s], taskId = [%s]. Nothing to clean up.",
taskExecution.getTaskName(), id));
return;
}
TaskDeployment taskDeployment = this.taskDeploymentRepository.findByTaskDeploymentId(launchId);
if (taskDeployment == null) {
logger.warn(String.format("Did not find TaskDeployment for taskName = [%s], taskId = [%s]. Nothing to clean up.",
Expand Down

0 comments on commit 393622e

Please sign in to comment.