Question
United Health Group
US
Last activity: 10 Dec 2015 9:56 EST
Performing a Save (Write Now) in a system queue activity
I am performing a save of a data instance with write Now enabled with a System Queue in the activity that is called by the Standard Agent.. I am setting Step Status to Fail however because I need the system queue to be re-queued and retry to occur. The Save I am speaking about is to log the failure as a data instance. Can I not do this because the agent will perform a rollback?
I am getting Save, Delete or Commit has failed because lock "UHG-FW-TCMM-DATA-SERVICELOG SYSTEM-QUEUE-BOUNCEDUNOPENED 14495840126460001999FC74FAA73F5352523C7649EBC29D" is not held error. I believe it is called by CheckRequiredLocks. Using PRPC 6.2 SP2
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems
US
I don't know enough about your context to know whether what you are doing is advisable, but I do know that you definitely need to have a lock in order to do your save. One way is to do an obj-open or obj-open-by-handle with the "lock" checkmark. Make sure you use something like "StepStatusFail" on your post condition to detect if you can't lock it because someone else already has the lock. Once you get the lock, after your save with "write now", do an unlock. One way of doing the unlock is by stepping outside the guard rail into a java step that performs something like 'tools.getDatabase().getLockManager().unlock(tools.findPage("theWork")' . /Eric
United Health Group
US
Hi Eric,
THanks for your response. I finally figure out a solution. I had to use a named page to get to work so now I'm fine.
Pegasystems
US
Please note that normally you should only use obj-save (with your without "write-now"!) for an object OTHER than the primary work object.
For the primary work object (the one being acted on in normal flow processing), you should normally merely update your properties. The work will get saved for you by the system when the submit happens.
The reason it is important NOT to use obj-save for the primary work object is that it will cause trouble if there is ever a rollback situation, in which case it can cause errors such as "flow removed" or "flow not at task". /Eric
United Health Group
US
What is the primary work object? The work object that performed the Queue-For-Agent thus creating the queue item?
Pegasystems
US
If a flow is in progress, it's associated with a work object that is currently open and locked by the current requestor. This is the primary work object. That current requestor is often an interactive user or an SLA agent. Often, the name of the page containing the current property values for that work object is pyWorkPage.
That primary work object will be properly saved and committed by the Pega core rules, which is why in general your private rules need only update properties on the page and not doing any obj-save. /Eric
United Health Group
US
Sorry eric. Still a little confused. The queue manager handles the transaction processing. For what object is it handling the transactions for?
United Health Group
US
Or is it just saying it will perform the rollback or commit for everything?
Pegasystems
US
Hi,
Here's two articles that may help:
https://docs-previous.pega.com/system-administration/overview-agent-processing
https://docs-previous.pega.com/system-administration/how-write-agent-activity
In particular, this bit, from the second one:
The agent activity contains the agent task; it may be named with whatever descriptive name you want. This activity should only contain business logic. It should not attempt to obtain locks on any objects, nor should it perform any database commit or rollback operations; it should not perform any immediate (“Write Now”) database operations. These should all be part of transaction processing, which is handled automatically. In the agent activity, all operations should be deferred, using Obj-Save or Obj-Delete with WriteNow unchecked. However, Release On Commit should be checked.