Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Set scheduledTime and startTime with currentTime for all system tasks #3278

Merged
merged 2 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ public List<TaskModel> createTasks(List<TaskModel> tasks) {
// update the task_lookup table
tasks.forEach(
task -> {
task.setScheduledTime(System.currentTimeMillis());
if (task.getScheduledTime() == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solves the negative queue wait time.

task.setScheduledTime(System.currentTimeMillis());
}
session.execute(
updateTaskLookupStatement.bind(
workflowUUID, toUUID(task.getTaskId(), "Invalid task id")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext) {
decisionTask.setTaskDefName(TaskType.TASK_TYPE_DECISION);
decisionTask.addInput("case", caseValue);
decisionTask.addOutput("caseOutput", Collections.singletonList(caseValue));
decisionTask.setStartTime(System.currentTimeMillis());
final long currentTimeMillis = System.currentTimeMillis();
decisionTask.setScheduledTime(currentTimeMillis);
decisionTask.setStartTime(currentTimeMillis);
decisionTask.setStatus(TaskModel.Status.IN_PROGRESS);
tasksToBeScheduled.add(decisionTask);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext) {
TaskModel doWhileTask = taskMapperContext.createTaskModel();
doWhileTask.setTaskType(TaskType.TASK_TYPE_DO_WHILE);
doWhileTask.setStatus(TaskModel.Status.IN_PROGRESS);
doWhileTask.setStartTime(System.currentTimeMillis());
final long currentTimeMillis = System.currentTimeMillis();
doWhileTask.setScheduledTime(currentTimeMillis);
doWhileTask.setStartTime(currentTimeMillis);
doWhileTask.setRateLimitPerFrequency(taskDefinition.getRateLimitPerFrequency());
doWhileTask.setRateLimitFrequencyInSeconds(taskDefinition.getRateLimitFrequencyInSeconds());
doWhileTask.setRetryCount(taskMapperContext.getRetryCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext) {
TaskModel joinTask = taskMapperContext.createTaskModel();
joinTask.setTaskType(TaskType.TASK_TYPE_EXCLUSIVE_JOIN);
joinTask.setTaskDefName(TaskType.TASK_TYPE_EXCLUSIVE_JOIN);
joinTask.setStartTime(System.currentTimeMillis());
final long currentTimeMillis = System.currentTimeMillis();
joinTask.setScheduledTime(currentTimeMillis);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taskMapperContext.createTaskModel() sets the scheduledTime already. I missed that during our discussion. I don't see a need to scheduledTime in the TaskMapper implementations.

Its possible that queueWaitTime is a non-zero value for synchronous system tasks, but as long as its not below zero, we are good.

joinTask.setStartTime(currentTimeMillis);
joinTask.setInputData(joinInput);
joinTask.setStatus(TaskModel.Status.IN_PROGRESS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,10 @@ TaskModel createDynamicForkTask(
TaskModel forkDynamicTask = taskMapperContext.createTaskModel();
forkDynamicTask.setTaskType(TaskType.TASK_TYPE_FORK);
forkDynamicTask.setTaskDefName(TaskType.TASK_TYPE_FORK);
forkDynamicTask.setStartTime(System.currentTimeMillis());
forkDynamicTask.setEndTime(System.currentTimeMillis());
final long currentTimeMillis = System.currentTimeMillis();
forkDynamicTask.setScheduledTime(currentTimeMillis);
forkDynamicTask.setStartTime(currentTimeMillis);
forkDynamicTask.setEndTime(currentTimeMillis);
List<String> forkedTaskNames =
dynForkTasks.stream()
.map(WorkflowTask::getTaskReferenceName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext)
forkTask.setTaskType(TaskType.TASK_TYPE_FORK);
forkTask.setTaskDefName(TaskType.TASK_TYPE_FORK);
long epochMillis = System.currentTimeMillis();
forkTask.setScheduledTime(epochMillis);
forkTask.setStartTime(epochMillis);
forkTask.setEndTime(epochMillis);
forkTask.setInputData(taskInput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext) {
TaskModel humanTask = taskMapperContext.createTaskModel();
humanTask.setTaskType(TASK_TYPE_HUMAN);
humanTask.setInputData(humanTaskInput);
humanTask.setStartTime(System.currentTimeMillis());
final long currentTimeMillis = System.currentTimeMillis();
humanTask.setScheduledTime(currentTimeMillis);
humanTask.setStartTime(currentTimeMillis);
humanTask.setStatus(TaskModel.Status.IN_PROGRESS);
return List.of(humanTask);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext) {

TaskModel inlineTask = taskMapperContext.createTaskModel();
inlineTask.setTaskType(TaskType.TASK_TYPE_INLINE);
inlineTask.setStartTime(System.currentTimeMillis());
final long currentTimeMillis = System.currentTimeMillis();
inlineTask.setScheduledTime(currentTimeMillis);
inlineTask.setStartTime(currentTimeMillis);
inlineTask.setInputData(taskInput);
inlineTask.setStatus(TaskModel.Status.IN_PROGRESS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext) {
TaskModel joinTask = taskMapperContext.createTaskModel();
joinTask.setTaskType(TaskType.TASK_TYPE_JOIN);
joinTask.setTaskDefName(TaskType.TASK_TYPE_JOIN);
joinTask.setStartTime(System.currentTimeMillis());
final long currentTimeMillis = System.currentTimeMillis();
joinTask.setScheduledTime(currentTimeMillis);
joinTask.setStartTime(currentTimeMillis);
joinTask.setInputData(joinInput);
joinTask.setStatus(TaskModel.Status.IN_PROGRESS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext) {
workflowTask.getInputParameters(), workflowModel, taskId, taskDefinition);

TaskModel jsonJQTransformTask = taskMapperContext.createTaskModel();
jsonJQTransformTask.setStartTime(System.currentTimeMillis());
final long currentTimeMillis = System.currentTimeMillis();
jsonJQTransformTask.setScheduledTime(currentTimeMillis);
jsonJQTransformTask.setStartTime(currentTimeMillis);
jsonJQTransformTask.setInputData(taskInput);
jsonJQTransformTask.setStatus(TaskModel.Status.IN_PROGRESS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext) {

TaskModel lambdaTask = taskMapperContext.createTaskModel();
lambdaTask.setTaskType(TaskType.TASK_TYPE_LAMBDA);
lambdaTask.setStartTime(System.currentTimeMillis());
final long currentTimeMillis = System.currentTimeMillis();
lambdaTask.setScheduledTime(currentTimeMillis);
lambdaTask.setStartTime(currentTimeMillis);
lambdaTask.setInputData(taskInput);
lambdaTask.setStatus(TaskModel.Status.IN_PROGRESS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext)
LOGGER.debug("TaskMapperContext {} in SetVariableMapper", taskMapperContext);

TaskModel varTask = taskMapperContext.createTaskModel();
varTask.setStartTime(System.currentTimeMillis());
final long currentTimeMillis = System.currentTimeMillis();
varTask.setScheduledTime(currentTimeMillis);
varTask.setStartTime(currentTimeMillis);
varTask.setInputData(taskMapperContext.getTaskInput());
varTask.setStatus(TaskModel.Status.IN_PROGRESS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext) {
switchTask.setTaskDefName(TaskType.TASK_TYPE_SWITCH);
switchTask.getInputData().put("case", evalResult);
switchTask.addOutput("evaluationResult", List.of(evalResult));
switchTask.setStartTime(System.currentTimeMillis());
final long currentTimeMillis = System.currentTimeMillis();
switchTask.setScheduledTime(currentTimeMillis);
switchTask.setStartTime(currentTimeMillis);
switchTask.setStatus(TaskModel.Status.IN_PROGRESS);
tasksToBeScheduled.add(switchTask);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext) {

TaskModel task = taskMapperContext.createTaskModel();
task.setTaskType(TASK_TYPE_TERMINATE);
task.setStartTime(System.currentTimeMillis());
final long currentTimeMillis = System.currentTimeMillis();
task.setScheduledTime(currentTimeMillis);
task.setStartTime(currentTimeMillis);
task.setInputData(taskInput);
task.setStatus(TaskModel.Status.IN_PROGRESS);
return List.of(task);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public List<TaskModel> getMappedTasks(TaskMapperContext taskMapperContext) {
TaskModel waitTask = taskMapperContext.createTaskModel();
waitTask.setTaskType(TASK_TYPE_WAIT);
waitTask.setInputData(waitTaskInput);
waitTask.setStartTime(System.currentTimeMillis());
final long currentTimeMillis = System.currentTimeMillis();
waitTask.setScheduledTime(currentTimeMillis);
waitTask.setStartTime(currentTimeMillis);
waitTask.setStatus(TaskModel.Status.IN_PROGRESS);
return List.of(waitTask);
}
Expand Down