Wednesday 4 January 2017

IBM BPM - Tinkering with Process Instance Cleanup - aka BPMProcessInstancesPurge

Following my previous post: -


I've had a play with the BPMProcessInstancesPurge command.

It's WAY more powerful, and definitely a case of Caveat Emptor, Your Mileage May Vary and Here Be Dragons.

This command allows one to remove *ALL* instances from a Process Server, regardless of status.

But it does require one to Use The Force.

Now read on ….

Validate status of instances - active, completed, terminated, suspended

db2 "select inst.EXECUTION_STATUS, count(*) as total from LSW_BPD_INSTANCE inst, LSW_TASK task where task.BPD_INSTANCE_ID = inst.BPD_INSTANCE_ID group by inst.EXECUTION_STATUS"

EXECUTION_STATUS TOTAL      

              1.           1
              2.           1
              4.           1
              6.           1

Clear ALL Terminated instances

print AdminTask.BPMProcessInstancesPurge('[-instanceStatus TERMINATED]')

The BPMProcessInstancesPurge command passed.

Check results in AppCluster logs

tail -f /opt/ibm/WebSphereProfiles/AppSrv01/logs/AppClusterMember1/SystemOut.log

[04/01/17 17:04:25:612 GMT] 000001eb CommandServic I PALAdminCommands otherProcessInstancesPurge Entering
[04/01/17 17:04:25:616 GMT] 000001eb Log           I   PAL: About to delete the process instances matching the filter criteria: 
Statuses: [4]
Maximum duration: 0
Transaction slice: 10

[04/01/17 17:04:25:616 GMT] 000001eb Log           I   PAL: Number of qualifying instances before deletion: 1
[04/01/17 17:04:25:687 GMT] 000001eb Log           I   PAL: A deletion job is running. Progress: Deleted 1 instance(s).
[04/01/17 17:04:25:687 GMT] 000001eb Log           I   PAL: Every instance has been deleted. The deletion job finished.
[04/01/17 17:04:25:691 GMT] 000001eb Log           I   PAL: Successfully deleted the process instances matching the filter criteria: 
Statuses: [4]
Maximum duration: 0
Transaction slice: 10

[04/01/17 17:04:25:692 GMT] 000001eb Log           I   PAL: Number of qualifying instances before deletion: 1
[04/01/17 17:04:25:695 GMT] 000001eb Log           I   PAL: Number of qualifying instances after deletion: 0
[04/01/17 17:04:25:698 GMT] 000001eb CommandServic I PALAdminCommands otherProcessInstancesPurge Exiting
[04/01/17 17:04:34:110 GMT] 00000124 ProcessIndexB I   CWLLG0757I: The purge process was completed successfully. 1 tasks and 1 instances were successfully removed from the search index.

Validate that there are no longer any Terminated instances ( status code 4 )

db2 "select inst.EXECUTION_STATUS, count(*) as total from LSW_BPD_INSTANCE inst, LSW_TASK task where task.BPD_INSTANCE_ID = inst.BPD_INSTANCE_ID group by inst.EXECUTION_STATUS"

EXECUTION_STATUS TOTAL      

              1.           1
              2.           1
              6.           1

Attempt to clear ALL instances

print AdminTask.BPMProcessInstancesPurge('[-instanceStatus ALL]')

The BPMProcessInstancesPurge command passed.
wsadmin>print AdminTask.BPMProcessInstancesPurge('[-instanceStatus ALL]')
WASX7015E: Exception running command: "AdminTask.BPMProcessInstancesPurge('[-instanceStatus ALL]')"; exception information:
java.lang.Exception: java.lang.Exception: The instance status 'ALL' is a non end state. The '-force' flag is mandatory to delete instances in this state.

Attempt to clear ALL instances - use the force

print AdminTask.BPMProcessInstancesPurge('[-instanceStatus ALL -force]')

The BPMProcessInstancesPurge command passed.

Check results in AppCluster logs

tail -f /opt/ibm/WebSphereProfiles/AppSrv01/logs/AppClusterMember1/SystemOut.log

[04/01/17 17:08:42:748 GMT] 000001ec CommandServic I PALAdminCommands otherProcessInstancesPurge Entering
[04/01/17 17:08:42:753 GMT] 000001ec Log           I   PAL: About to delete the process instances matching the filter criteria: 
Statuses: [2, 4, 3, 1, 5, 6]
Maximum duration: 0
Transaction slice: 10

[04/01/17 17:08:42:754 GMT] 000001ec Log           I   PAL: Number of qualifying instances before deletion: 3
[04/01/17 17:08:42:963 GMT] 000001ec Log           I   PAL: A deletion job is running. Progress: Deleted 3 instance(s).
[04/01/17 17:08:42:963 GMT] 000001ec Log           I   PAL: Every instance has been deleted. The deletion job finished.
[04/01/17 17:08:42:970 GMT] 000001ec Log           I   PAL: Successfully deleted the process instances matching the filter criteria: 
Statuses: [2, 4, 3, 1, 5, 6]
Maximum duration: 0
Transaction slice: 10

[04/01/17 17:08:42:970 GMT] 000001ec Log           I   PAL: Number of qualifying instances before deletion: 3
[04/01/17 17:08:42:975 GMT] 000001ec Log           I   PAL: Number of qualifying instances after deletion: 0
[04/01/17 17:08:42:978 GMT] 000001ec CommandServic I PALAdminCommands otherProcessInstancesPurge Exiting
[04/01/17 17:08:49:143 GMT] 00000124 ProcessIndexB I   CWLLG0757I: The purge process was completed successfully. 3 tasks and 3 instances were successfully removed from the search index.

Validate the database

db2 "select inst.EXECUTION_STATUS, count(*) as total from LSW_BPD_INSTANCE inst, LSW_TASK task where task.BPD_INSTANCE_ID = inst.BPD_INSTANCE_ID group by inst.EXECUTION_STATUS"

EXECUTION_STATUS TOTAL      

  0 record(s) selected.

It goes without saying that the force should be used with caution - with great power, comes great responsibility ( just because you can, doesn't mean you should )

No comments:

Visual Studio Code - Wow 🙀

Why did I not know that I can merely hit [cmd] [p]  to bring up a search box allowing me to search my project e.g. a repo cloned from GitHub...