Solved

AcquireLock activity on Workflow


Userlevel 3
Badge +12

Hi guys,

 

Hope everyone is doing well.

I have a workflow that I scheduled to run once per day, the workflow may take time to complete (Over a day sometimes depending on the data to process).

I need to have only one workflow job to be running at the same time, and I wonder how can I prevent the next scheduled job of the workflow to be canceled if the today’s one will keep running until the next day.

 

Found the “AcquireLock” activity, which I tried to use at the start of the workflow, which works fine to prevent the next scheduled workflow to execute, however it remains in the waiting state, while I want it to end directly if the previous one is still running.

Is there any way to force the AcquireLock to process to the next activity even if it didn’t acquire the lock ? That why, if it didn’t acquire the lock, I can end the workflow directly.

 

Regards.

 

icon

Best answer by Chris Sunderland 21 June 2022, 21:43

View original

6 replies

Userlevel 7
Badge +23

@Commvault Engineer have you looked at workflowend?

84549.pngWorkflowEnd

Terminates the Workflow when a specified activity thread fails to complete. This activity is useful to indicate that the Workflow failed and to show the respective reason.

Note: When the WorkflowEnd activity is used inside a ProcessBlock activity, the workflow will not transition away from the process block.

This activity requires the following inputs:

  • completionStatus

    A string value which determines if the activity thread completed or failed.

    Note: For Workflows with multiple activity threads, if you are using this activity on a specific activity thread and you selected the COMPLETED status, WorkflowEnd will terminate the activity thread, but the Workflow will continue to execute the other threads. However, if the FAILED status is set, the Workflow terminates.

  • failureMessage

    (Optional) A string value which describes the reason of the failure. This input is not needed if you set the completionStatus input as completed.

 

Adding in the great @Chris Sunderland to add in.

Userlevel 3
Badge +12

@Commvault Engineer have you looked at workflowend?

84549.pngWorkflowEnd

Terminates the Workflow when a specified activity thread fails to complete. This activity is useful to indicate that the Workflow failed and to show the respective reason.

Note: When the WorkflowEnd activity is used inside a ProcessBlock activity, the workflow will not transition away from the process block.

This activity requires the following inputs:

  • completionStatus

    A string value which determines if the activity thread completed or failed.

    Note: For Workflows with multiple activity threads, if you are using this activity on a specific activity thread and you selected the COMPLETED status, WorkflowEnd will terminate the activity thread, but the Workflow will continue to execute the other threads. However, if the FAILED status is set, the Workflow terminates.

  • failureMessage

    (Optional) A string value which describes the reason of the failure. This input is not needed if you set the completionStatus input as completed.

 

Adding in the great @Chris Sunderland to add in.

Thanks a lot, Mike, for your suggestion.

 

That’s what I want to achieve, if my workflow cannot Acquire the lock, since one instance of the workflow is already running, it processes to the next activity, which is a “WorkflowEnd”.

I don’t know how to force the AcquireLock to process to the WorkflowEnd when it can not acquire the lock.

 

Thanks again for your help.

 

Userlevel 7
Badge +23

Let me reach out to @Chris Sunderland who is a master at Workflows 😁

Userlevel 3
Badge +6

You could put a timeout of 0, 1 or something small and then set the activity to continue after max restarts and set max restarts to 0.  Then afterwards you can check if the activity failed and navigate to a WorkflowEnd activity.

 

Userlevel 3
Badge +12

You could put a timeout of 0, 1 or something small and then set the activity to continue after max restarts and set max restarts to 0.  Then afterwards you can check if the activity failed and navigate to a WorkflowEnd activity.

 

Thanks a lot @Mike Struening and @Chris Sunderland For your help, will try it out.

Userlevel 3
Badge +12

Thanks, @Chris Sunderland For the suggestion, set up a timeout as you advised, when the timeout ends for the AcquireLock, the activity ends with the output variable “lockAcquired” set to “false”, which attached to a Decision helped me to directly set a WorkflowEnd.

 

Thanks again :-)

Reply