Unable to unlock pages using workflow-process-service eventhough it is the lock owner
Hi,
In one of our workflows, we are using a "Lock Payload Process" to lock the page and the page is being locked by "workflow-process-service" service user. We are now trying to add multiple schedulers in the next Process Step. These schedulers will trigger at different time from the time the Process Step executes. As part of one of these schedulers, we have to unlock the page and then terminate the workflow.
When the scheduler triggers, as it is not possible to use the original workflow session anymore because the session is automatically being closed when the workflow step ends. So as suggested in Processing Events, Replication Preprocessors and Jobs, I tried creating a subservice that points to "workflow-process-service" and then obtain it's resource resolver from resource resolver factory. I am able to adapt resource resolver into workflow session and then terminate the workflow. But, when I try to unlock the page by adapting the payload's resource into Page API's and using it's unlock method, I am receiving "not an owner of the lock" error even though the session created is from the same service user that locked the page (jcr:lockOwner: "workflow-process-service"). even with page.unlock() I am getting a true.
Now, If I move that unlock code out of the scheduler and use it with the original unclosed session during that process step itself, I am able to unlock the page without any issue. What is the issue with the approach? What else can be done to unlock the page?