Unstoppable Workflows :)

Harun Kara 156 Reputation points
2020-12-11T11:20:12.47+00:00

Hi,

I have some weird occurrences in my SharePoint farm. I have a couple of workflows that run on SharePoint items. Now the workflows do what they are supposed to do and work fine. But, some instances on random items do not finish. However, the workflows complete their job as defined in the designer. And slowly this builds up workflow instances running at any given time which I believe will turn into a problem in the future.

So to fix it, I tried GUI "stop this workflow" with no success. And I have also tried force stopping them through PowerShell to no avail.

Any idea why this might be happening? Not recently but a couple of weeks ago I tried to look for logs, tried to check differences between instances that run normally and ones that get "stuck" but I couldn't make much sense of what I found then. I also did google my problem but couldn't find similar posts on the interwebs.

Any help towards identifying the problem and, hopefully to a solution is much appreciated

SharePoint Workflow
SharePoint Workflow
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Workflow: An orchestrated and repeatable pattern of business activity, enabling data transformation, service provision, and information retrieval.
599 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,959 questions
{count} votes

Accepted answer
  1. Echo Du_MSFT 17,181 Reputation points
    2020-12-14T10:22:45.65+00:00

    Hi @Harun Kara ,

    This may be because the workflow is working on an item, and the priority of the running state is higher than the priority of stopping the workflow. Therefore, you cannot enforce stop the workflow.

    To fix this issue, please remove the scope which holds that workflow.

    • Remove the scope from the dbo.Scopes table of the WFResourceManagementDB Database
      47954-1.png
    • Restart ServiceBus Gateway and Broker services
    • Create scope programmatically.
    • Publish workflow again

    Note: This will cause all running instances of the workflow to fail!

    Thanks,
    Echo Du

    ---------------------------------
    Updated Answer -------------------------------------

    Hi @Harun Kara ,

    Before removing the workflow scopes, you should back it up.

    Here is the PowerShell script to backup Database from SQL Server:

    #Import SQL PowerShell module  
    Import-Module SQLPS –DisableNameChecking  
    #Configuration parameters  
    $SQLInstance="Cre-SQL-001"  
    $BackupPath="D:\Backup\"  
    #Array of Database names, Comma separated  
    $DBName="WFResourceManagementDB"  
    #Backup Database  
    Write-host "Backing up the database: $($DBName)"  
    Backup-SqlDatabase -ServerInstance $SQLInstance -Database $DBName -BackupFile "$($BackupPath)\$($DBName).bak"  
    

    Use the "Restore-WFScope" cmdlet to restore a previously backed-up Workflows scope.

    Syntax:

    Parameter Set: Default  
    Restore-WFScope -BackupInstanceDBConnectionString <String> -BackupResourceDBConnectionString <String> -BackupSBGatewayDBConnectionString <String> -BackupSBMessageContainerConnectionString <String[]> -InstanceStateSyncTime <DateTime> -LiveInstanceDBConnectionString <String> -LiveResourceDBConnectionString <String> -ScopePath <String> [-AbortOnError] [-LiveSiteEncryptedEncryptionToken <String> ] [-LiveSiteEncryptionCertificate <X509Certificate2> ] [-LiveSiteEncryptionToken <String> ] [ <CommonParameters>]  
    

    Run Restore-WFScope to restore a previously backed-up Workflows scope. It provides the ability to help customers recover from unexpected deletions of scopes that need recovery using a backup.

    Thanks,
    Echo Du

    ===========

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Harun Kara 156 Reputation points
    2020-12-14T10:50:13.033+00:00

    Hi @Echo Du_MSFT ,
    How can I create the scope programmatically? I believe I do it through PowerShell? Can you steer me towards the command pages? Thank you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.