IT Process Automation

  • 1.  Archive and Purge the Workflow Instances through Database

    Posted Jul 06, 2017 09:27 AM

    Hello Community,

     

    how to archive and purge the failed and blocked process instances from the backend(sql database), we have archive and purge rules in place in the application. however their are very old failed and blocked instances were left over. so we would like to archive and purge all the old process in oneshot.

     how to accomplish this , please suggest us .

     

    Thank you,

    Venkat



  • 2.  Re: Archive and Purge the Workflow Instances through Database

    Broadcom Employee
    Posted Jul 06, 2017 09:32 AM

    Does the Delete Archived Instances button clear them?   That would be the best option:

     



  • 3.  Re: Archive and Purge the Workflow Instances through Database

    Posted Jul 06, 2017 09:44 AM

    Thank you, the above operation cleared the instances in archived section but how to clear the old(year old) failed and blocked instances from current block in the operations tab.

     

    we have enabled archive and purge in 60 days back, the new instances were getting archived as per the configuration but the old instances were left over.

    we would like to clear all the old instances in current section.

     

    Thank you

    Venkat



  • 4.  Re: Archive and Purge the Workflow Instances through Database

    Broadcom Employee
    Posted Jul 06, 2017 11:57 AM

    The Archive and Purge configurations are set within an instance at the time of its launch so instances launched prior to a change to the configuration would still hold the older archive configuration.

    Additionally it is possible to start instances with a flag 'autoarchive=false' which excludes the instance from the automatic archiving process.  For example, CA Service Catalog starts all instances with this flag set

     

    All older instances from prior to your Archive configuration change, as well as instances with the Autoarchive=false flag will need to be manually Aborted (if not completed), then Manually Archived from the Operations tab:

     

     

     

    Furthermore, 60 days is quite a long time depending on your overall load, and I would recommend you review the following knowledge article, TEC1434589 Discussion of Archive and Purge configuration,  which discusses archive and purge and recommends being aggressive with your archiving and purge settings to maintain an overall healthy orchestrator engine.



  • 5.  Re: Archive and Purge the Workflow Instances through Database

    Posted Jul 06, 2017 01:07 PM

    This might be useful.  I had to use this a couple years ago, to clean up.

    CREATE PROCEDURE dbo.mark_auto_archive_procedure_runtime
    AS
    BEGIN
    DECLARE @loopcount INT,@rowcount INT, @increment INT
    SET @loopcount = 0
    SET @rowcount = 0
    SET @increment = 100

    print 'Going to mark the autoArchive flag in the C2ORuntimeObjectsArch table';

    SELECT @rowcount = COUNT(rtArch.OID) FROM C2ORuntimeObjectsArch rtArch with (NOLOCK) WHERE rtArch.autoArchive = 0 AND Ended <= DATEADD(d, -25, getdate())

    print 'Total number of rows eligible of marking ' + Convert(varchar(50), @rowcount);

    WHILE @loopcount <= @rowcount
    BEGIN
    BEGIN TRY
    BEGIN TRANSACTION
    UPDATE TOP (CAST(@increment AS INT)) C2ORuntimeObjectsArch set autoArchive=1 WHERE ( autoArchive = 0 AND Ended <= DATEADD(d, -25, getdate()));
    COMMIT TRANSACTION

    SET @loopcount = @loopcount + @increment;
    END TRY
    BEGIN CATCH
    ROLLBACK
    END CATCH

    -- Optional delay between the batches can set here. Here it is a delay of 5 secs. The downside is that
    -- no loggers would appear whole stored procedure is executed.
    print 'Sleep for 5 secs';
    WAITFOR DELAY '00:00:05';
    END
    END

    exec dbo.mark_auto_archive_procedure_runtime
    drop procedure dbo.mark_auto_archive_procedure_runtime



  • 6.  Re: Archive and Purge the Workflow Instances through Database
    Best Answer

    Broadcom Employee
    Posted Jul 06, 2017 01:45 PM

    Great stuff Andrew, thank you!

     

    This will change the autoarchive flag from false to true (set autoArchive=1) for instances that are older than 25 days (DATEADD(d, -25, getdate()) )

    if you modify the -25 you can alter that time frame.

     

    This script can help if the majority of the remaining instances are launched with this flag set, for instance if they are from Service Catalog, but otherwise will not impact older instances and they will likely still need to be manually cleaned up



  • 7.  Re: Archive and Purge the Workflow Instances through Database

    Broadcom Employee
    Posted Mar 06, 2018 04:34 PM

    Here is another option using the web service methods:

     

    Below is the 4.2.2 procedure for clearing up the autoArchive flag using the controlInstance Method.  This is not documented properly currently, so I am including it here:



    - Make a SOAP call to the controlInstance method with <tns:processName>”Absolute Path With Name of Process”</tns:processName>

    What it will do is that it will clear up the autoArchive flag for all the instances of the Process Automation Object and it will be picked up by the archiver next time.

    Below are the key points to be noted
    (1) The autoArchive is cleared in batches of 500 instances. The batch size is controlled by a property “pam.autoarchive.batch.size”. Any change in the default value which is 500 should not be done without any PAM SE/Dev consultation.
    (2) The timeinterval between two successive calls of (1) is atleast 2 mins.
    (3) Once the above SOAP call is made in about 2 mins you will messages like

    "Total number of rows udpated"+noOfRows + ". AutoArchive flag updated with value true" in c2o.log if the log level is set to INFO.


    You can get details and example code on this method here: controlInstance Method