Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

In development server, due to the fact that process design will always get updated and developed, there will be more and more XPDLs cached in the memory. In the long run, this may cause "java.lang.OutOfMemoryError" exception during runtime or server startup. To solve this issue, we will need to clean up the unused XPDLs with following steps. The following example queries are written in MySQL and MSSQL syntax.

Note
titleNote

1. Please shutdown your application server.

2. Please do a full database backup before proceeding to the following steps.


1. Check existing count of XPDLs

On a common production server, normally there are only few app versions and each version only tied to 1 process version. This is because we won't do any development in production server, so the process version is only increased during the app imported. But in the development server, it will be a different case. The process version will be going up to few hundred process version which also means there are few hundred of XPDL data are cached in memory. To check how many XPDLs are cached, please run the following query in your database server.

Code Block
languagesql
titleMySQL, MSSQL, Oracle
 select count(*) from SHKXPDLS

2. Check the count of unused XPDLs

In all the cached process version XPDLs, there is a case that some process version is not used by any process instances. These unused XPDLs can be safely deleted. The check the number of unused XPDLs, we can use the following query. Then, we can know how many are unused in the total number of XPDLs.

...

Code Block
languagesql
titleOracle
select * from SHKXPDLS x
where concat(x.XPDLId, x.XPDLVersion) not in (
    select concat(packageId,packageVersion) as id from (
        select def.PackageId as packageId, TO_CHAR(def.ProcessDefinitionVersion) as packageVersion 
        from SHKActivities act 
        join SHKProcesses pro on act.Process = pro.oid 
        left join SHKProcessDefinitions def on pro.ProcessDefinition = def.oid 
        group by def.PackageId, def.ProcessDefinitionVersion 
        union 
        select packageId, TO_CHAR(packageVersion) from app_package
    ) group by packageId, packageVersion
);

3. Delete completed process instances data to clean up more XPDLs from cache

If the process instances data are not important to you or you have your process instance data captured a copy by the Process Data Collector plugin, you can delete your process instances data to increase the number of unused XPDLs. In this case, only the process version for running process instances and the latest process version for each app version will be kept.

...

Code Block
languagesql
titleMSSQL
EXEC sp_MSforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"

delete sa from SHKAssignmentsTable as sa
left join SHKProcesses as sp on sa.ActivityProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 

delete sadsaj from SHKAndJoinTable as saj
left join SHKActivities as sac on saj.Activity = sac.oid
left join SHKProcesses as sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 
 
delete sadsd from SHKDeadlines as sd
left join SHKActivities as sac on sd.Activity = sac.oid
left join SHKProcesses as sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 
 
delete sad from SHKActivityData as sad
left join SHKActivities as sac on sad.Activity = sac.oid
left join SHKProcesses as sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 
 
delete sac from SHKActivities as sac
left join SHKProcesses as sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 

delete spd from SHKProcessData as spd
left join SHKProcesses as sp on spd.Process = sp.oid
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 

delete spr from SHKProcessRequesters as spr
left join SHKProcesses as sp on spr.Id = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 

delete from SHKProcesses where (State = 1000006 or State = 1000008 or State = 1000010); 
 
EXEC sp_MSforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
Code Block
languagesql
titleOracle
delete (select sa.* from SHKAssignmentsTable sa
left join SHKProcesses sp on sa.ActivityProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010));

delete sadsaj from SHKAndJoinTable as saj
left join SHKActivities as sac on saj.Activity = sac.oid
left join SHKProcesses as sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 
 
delete sadsd from SHKDeadlines as sd
left join SHKActivities as sac on sd.Activity = sac.oid
left join SHKProcesses as sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 
 
delete (select sad.* from SHKActivityData sad
left join SHKActivities sac on sad.Activity = sac.oid
left join SHKProcesses sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010)); 
 
delete (select sac.* from SHKActivities sac
left join SHKProcesses sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010)); 

delete (select spd.* from SHKProcessData spd
left join SHKProcesses sp on spd.Process = sp.oid
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010)); 

delete (select spr.* from SHKProcessRequesters spr
left join SHKProcesses sp on spr.Id = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010)); 

delete from SHKProcesses where (State = 1000006 or State = 1000008 or State = 1000010); 

...

Code Block
languagesql
titleOracle
delete from SHKAssignmentsTable;
delete from SHKAndJoinTable;
delete from SHKDeadlines;
delete from SHKActivityData;
delete from SHKActivities;
delete from SHKProcessData;
delete from SHKProcessRequesters;
delete from SHKProcesses;

4. Delete the unused XDPLs

Now, you can delete the unused XPDLs and it will be free from your memory cache when next server startup.

...