Are environment locks released when process ends?

mbailey

Member
Hi,

If a Blue Prism process ends while holding the token for an environment lock, is that token released? I wrote a Cleanup page for my process to ensure that open applications are closed, temporary files are deleted, and any held environment tokens are released. Cleanup is called before ending the process both normally and as part of my error handling routine, but I'm not sure what happens if the process is ended unexpectedly and Cleanup is never executed. Would the environment locks held by that process still be in force and prevent other processes from accessing the shared resource or would they be released automatically?

Thanks,
Michael Bailey
 

VJR

Well-Known Member
Hi mbailey,

Check what you see in the System tab -> Workflow -> Environment lock.
When a process is locked it returns a token as an output and when the work is over the token has to be released which you might have to do normally and in the error handler.
 

mbailey

Member
Hi VJ,

As I said, I already do that in my code. My question relates to what happens to such a token if the process terminates without being able to run the code that releases the token (e.g., Blue Prism crashes or the server on which the bot is running goes down, etc)? If it is not automatically released and the process that held the token no longer exists, how can the token ever be released?

Thanks,
Michael Bailey
 

VJR

Well-Known Member
Hi VJ,

As I said, I already do that in my code. My question relates to what happens to such a token if the process terminates without being able to run the code that releases the token (e.g., Blue Prism crashes or the server on which the bot is running goes down, etc)? If it is not automatically released and the process that held the token no longer exists, how can the token ever be released?

Thanks,
Michael Bailey
Hi mbailey,

Wouldn't you be checking at the beginning of the process if a Lock exists Release it and continue and if it doesn't then too continue. Just like CleanUp, an Initialise activity would do all of these. Does that relate to what you are enquiring about?
 

Kamal

New Member
Hi mbailey,

Wouldn't you be checking at the beginning of the process if a Lock exists Release it and continue and if it doesn't then too continue. Just like CleanUp, an Initialise activity would do all of these. Does that relate to what you are enquiring about?
VJ, Its a simple question. If the the system shuts down abnormally when there is lock acquired then what will happen to that lock ? Will it automatically get released and next time when the system is ON then any other process can acquire the same lock or not ?

What you have replied is something that we need to check in our code. But we are not asking what we need to do. We are asking about the bot bahavior.
 

mbailey

Member
VJ,

To expand on Kamal's point, we are running this process with multiple bots and the environment lock is not being acquired with a preferred token. The only process aware of the token value is the process that acquired the lock. Additional bots running the same process cannot release the lock because they do not know the token value. This is by design to ensure that a bot that fails to acquire the lock performs other work until that lock becomes available.

If the process holding the lock terminates abnormally and cannot execute the code to release the lock, I want to know if Blue Prism releases the lock automatically (similar to Blue Prism closing an open work queue item as an exception when a process terminates abnormally). If it does, my code will function correctly. However, if the lock is not released when the process holding it terminates abnormally, I need to redesign my code to use a preferred token and add a datetime comment when the lock is acquired. This will allow bots that fail to acquire the lock to check the lock comment to determine how long that lock has been held since its acquisition and, when a predetermined maximum timespan is exceeded, to use the preferred token to release the lock before attempting to acquire it. The latter process has a basic issue in deciding how long to wait before allowing one bot to override a lock held by another bot that may or may not have terminated.

The lock appears to be released when I simulate an abnormal termination by running in debug mode and placing a breakpoint that allows me to manually terminate the process. However, one Quality Control test running a single bot in headless mode encountered a lock that was held and had to be released in the Control Room. The reason for the lock being held was not known and developers are not allowed access to the QC environment so I am attempting to investigate this indirectly. Knowing how Blue Prism is supposed to handle this will allow me to decide whether to modify the code and add the environment variable to specify the wait period to override the lock held by another process.

Thanks,
Michael Bailey
 
Top