Resolution
First, check the Tasks page with the space filter set to All Spaces. Look for the task named in the wait message by hovering over each task in the UI and inspecting the URL preview. If it exists, let it finish or cancel it. If it doesn't exist, the script lock is stale: restart the Tentacle on the target or worker the step is waiting on, or restart the Octopus Server if the step is waiting on the built-in worker. If restarting the Tentacle service on the impacted target does not resolve the issue, the Octopus Server service should be restarted to see if this clears the lock.
Symptom
A deployment or runbook run stops on a step and stays there. The task log shows a message like one of these:
Waiting for the script in task ServerTasks-1234 to finish as that script requires that no other Octopus scripts are executing on this target at the same time.
Waiting for the script in task (error - task not found) to finish
When you open the task ID from the message, Octopus can't find it:
The resource 'ServerTasks-1234' was not found.
Scope: when this is the right article
This article applies when all of these are true:
- The waiting step runs a script on a Tentacle deployment target, a Tentacle worker, or the built-in worker.
- The task log shows a
Waiting for the script in task … to finishmessage. - The task named in that message can't be found, or no task ID is shown.
This article doesn't cover:
- Tasks that stay in the Queued state and never start. That's usually the task cap or another deployment of the same project to the same environment.
- Steps that started running and then stopped responding. See Troubleshooting failed or hanging tasks.
Cause
By default, a Tentacle runs one Octopus script at a time. Before a step runs a script on a target or worker, it takes a lock on that machine. Any other task that needs the same machine waits for the lock, and its task log names the task that holds it.
When the named task can't be found, one of three things is happening:
- The task exists, but you can't see it. It's in another space, or your filters on the Tasks page hide it. The wait is working as designed.
- The message can't name the task. The lock is held by a real, running task, but Octopus lost track of which one.
- The lock is stale. The task that held the lock finished, was canceled, or was deleted, but the lock on the Tentacle wasn't released. Nothing releases it until the Tentacle restarts, or the Octopus Server restarts for the built-in worker.
Diagnosis and fix
Restarting a Tentacle or the Octopus Server stops any script that's genuinely running on it, so rule out a hidden task before you restart anything.
Find the task that holds the lock
You need permission to view tasks in every space that deploys to the affected target or worker.
- In the waiting task's log, copy the task ID from the
Waiting for the script in taskmessage. - In the waiting task's log, note the name of the deployment target or worker the step is waiting on.
- In the Octopus Web Portal, select Tasks in the top navigation.
- On the Tasks page, ensure All Spaces is selected in the Space filter.
- In the list of running tasks, look for the task ID you copied in step 1 by hovering over the individual tasks and inspecting the URL preview.
- If the task appears and is still running, wait for it to finish, or cancel it if it's no longer needed. The waiting task continues when the lock is released, and you can stop here.
- If the task doesn't appear in any space, the lock is stale. Release it with the restart for the machine type you noted in step 2: Windows Tentacle, Linux Tentacle, or built-in worker.
- If step 7 does not resolve the issue, the Octopus Server service should be restarted to see if this clears the lock.
Release a stale lock on a Windows Tentacle
Restarting the Tentacle stops every script currently running on that machine, so any other task with a step running there fails that step. On the Tasks page, check for other running tasks that use this target or worker before you restart. You need remote access to the Windows machine, with permission to restart services.
- On the Windows machine that hosts the Tentacle, open Tentacle Manager.
- In Tentacle Manager, select Restart.
Release a stale lock on a Linux Tentacle
Restarting the Tentacle stops every script currently running on that machine, so any other task with a step running there fails that step. On the Tasks page, check for other running tasks that use this target or worker before you restart. You need shell access to the Linux machine, and the Tentacle instance name.
- On the Linux machine that hosts the Tentacle, stop the Tentacle service:
/opt/octopus/tentacle/Tentacle service --instance <instance name> --stop
- On the same machine, start the Tentacle service:
/opt/octopus/tentacle/Tentacle service --instance <instance name> --start
Release a stale lock on the built-in worker
This applies to self-hosted Octopus Server only. On Octopus Cloud, contact Octopus Support instead.
Restarting the Octopus Server interrupts every task running on that node, not only tasks that use the built-in worker. Schedule the restart for a quiet period, or put the server into maintenance mode first and let running tasks finish. You need remote access to the Octopus Server machine, with permission to restart services. If you run Octopus High Availability, you also need the name of the node that ran the waiting task.
- On the Octopus Server machine, open Octopus Manager.
- In Octopus Manager, select Restart.
- After the Octopus Server is back online, rerun the deployment or runbook that was waiting.
If the lock keeps coming back
If the restart operations don't release the lock, or stale locks keep returning on the same target or worker, collect trace logs for Octopus Support. Removing and re-adding the target or worker may work in the meantime, but it doesn't show why the lock went stale.
- Rerun the deployment or runbook until a task stalls on the script lock again.
- In the Octopus Web Portal, select Configuration > Diagnostics.
- On the Diagnostics page, download the System Diagnostics Report.
- On each affected Tentacle, collect the Tentacle log files.
- Send the diagnostics report, the Tentacle log files, and the raw task log of the waiting task to Octopus Support.
- After the investigation, change the Tentacle log level back to its previous value, as trace logging produces large log files.
Verify
To confirm the lock is fully cleared, start a new deployment or runbook run that uses the same target or worker. Its step should start without a Waiting for the script in task message.
Related
- Troubleshooting failed or hanging tasks covers steps that start and then stop responding, including antivirus interference.
-
Run multiple processes on a target simultaneously explains
OctopusBypassDeploymentMutex, which lets tasks share a target instead of waiting on one lock. - Troubleshooting Tentacles covers checking and restarting Tentacle services and diagnosing connection problems.
- Superseded tasks describes how Octopus cancels queued or paused tasks that a newer task has replaced.
- Increase the Octopus Server task cap explains the limit on how many tasks run at once.