Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ccanning opened this issue Dec 9, 2022 · 0 comments · Fixed by #230
Assignees
Milestone

Comments

@ccanning
Copy link

ccanning commented Dec 9, 2022

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.

@github-actions github-actions bot added the status/need-triage Team needs to triage and take a first look label Dec 9, 2022
@onobc onobc removed the status/need-triage Team needs to triage and take a first look label Jan 31, 2023
@onobc onobc self-assigned this Jan 31, 2023
@onobc onobc added this to the 2.8.1 milestone Jan 31, 2023
onobc added a commit to onobc/spring-cloud-deployer-local that referenced this issue Feb 8, 2023
@onobc onobc closed this as completed in #230 Feb 8, 2023
onobc added a commit that referenced this issue Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants