Symptoms
We noticed there were constant errors in the K2 Host Server error logs:
"Error","General","1","GeneralErrorMessage","K2Worker.OpenProcessInstance","1 26023 Process instance 112 not found for K2:DOMAINK2ServiceAccount
Diagnoses
You can search through K2 database for process instance ID mentioned in error message using the following query (example assumes process ID is 112):
SELECT * FROM MK2].]Server].]ProcInst] WHERE ID ='112'
SELECT * FROM MK2].]ServerLog].]ProcInst] WHERE ID = '112'
If you cannot find anthing then it could be the case that something else is checking if this process exists / tries to execute it and as it fails to do so error messages appear in K2 host server log.
Resolution
Issue can be caused by "Process Error Notification Service" (PENS) installed and running (custom third party add-on from K2 marketplace).
To verify if this is the case you can stop and disable this service and check if error message no longer occurs. To prevent this error from happening some changes need to be made to the source code of this tool, see details below.
Two things you can do:
1) For a service that is running on a timer or thread, you should not open a connection to the server in “real-time” (less than 1sec) but rather let the Thread Sleep for a minute or so, to take some load off the server
2) Verify the logic - if the process instance is completed you should not try to open it.
Here is an example of how it should look like in code (pay attention to parts highlighted in yellow):
If the code shown above attempt to open a Process Instance and it fails with a “26023” error code ("Process Not Found") it will skip it.