Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

maxConcurrentExecutionsReached() has a race-condition where multiple instances can start before it returns a result #219

@ccanning

Description

@ccanning

In the launch method of LocalTaskLauncher, the

if (this.maxConcurrentExecutionsReached()) {
			throw new IllegalStateException(
				String.format("Cannot launch task %s. The maximum concurrent task executions is at its limit [%d].",
					request.getDefinition().getName(), this.getMaximumConcurrentTasks())
			);
		}

check isn't synchronized, and multiple instances can start before this code returns

public int getRunningTaskExecutionCount() {
		int runningExecutionCount = 0;

		for (TaskInstance taskInstance: running.values()) {
			if (taskInstance.getProcess().isAlive()) {
				runningExecutionCount++;
			}
		}
		return runningExecutionCount;
	}

an easy test is to set the max instances to 1 and kick off multiple concurrent requests and have it start docker tasks.

From investigation, the other launchers handle this differently and don't seem to have this issue.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions