Are you using any custom workflow?
Generally to lock or unlock a page through code-
// To Lock a page
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
Page page = pageManager.getPage("/content/myPage");
pageManager.lock(page);
// To Unlock a page
pageManager.unlock(page);
If you are using a custom workflow - you have to add workflow step:
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap args) throws WorkflowException {
try {
ResourceResolver resourceResolver = workflowSession.adaptTo(ResourceResolver.class);
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
String path = workItem.getWorkflowData().getPayload().toString();
Page page = pageManager.getPage(path);
if (page != null && pageManager.isLocked(page)) {
pageManager.unlock(page);
}
} catch (Exception e) {
throw new WorkflowException("Failed to unlock page", e);
}
}