NOTE: This article is an INTERNAL article and is not visible to customers, currently. Please only link this article in internal comments, but not public comments.
Issue
- When you try to publish live some content (web content, page, etc.) and create a new task, the publication task gets stuck and never starts.
- The progress of the task always remains at 0%.
Environment
- DXP 7.3
- DXP 7.2
Resolution
- In some cases this situation could be produced because a com.liferay.exportimport.internal.background.task.LayoutStagingBackgroundTaskExecutor background task has a lock in the database.
- Only one task of each type can be executed at a time, and if there is a lock in the one that should be executed, the rest should wait too.
- A node crashes or an unordered shutdown could produce this situation.
- When this happens, there is a row in the Lock_ table that should be removed. To remove this problematic row easily, the following script could be useful:
import com.liferay.portal.kernel.model.*; import com.liferay.portal.kernel.service.*; import com.liferay.portal.background.task.service.*; import com.liferay.portal.kernel.backgroundtask.*; import com.liferay.portal.lock.service.*; String taskExecutorClassNametaskExecutorClassName = "com.liferay.exportimport.internal.background.task.LayoutStagingBackgroundTaskExecutor"; String groupId = "3172392"; String lockKey = taskExecutorClassName + "#" + groupId; boolean isLocked = LockLocalServiceUtil.isLocked(BackgroundTaskExecutor.class.getName(), lockKey); if(isLocked) { LockLocalServiceUtil.unlock(BackgroundTaskExecutor.class.getName(), lockKey); out.println("Unlocking " + lockKey); } def backgroundTask = BackgroundTaskLocalServiceUtil.fetchFirstBackgroundTask( taskExecutorClassName, BackgroundTaskConstants.STATUS_QUEUED); while (backgroundTask != null) { out.println("Cancelling " + backgroundTask.getBackgroundTaskId()); BackgroundTaskLocalServiceUtil.amendBackgroundTask( backgroundTask.getBackgroundTaskId(), null, BackgroundTaskConstants.STATUS_CANCELLED, "Cancelled", new ServiceContext()); backgroundTask = BackgroundTaskLocalServiceUtil.fetchFirstBackgroundTask( taskExecutorClassName, BackgroundTaskConstants.STATUS_QUEUED); }
-
This script works with local staging. If you are using remote staging, you should change the initiation of the variable
taskExecutorClassName
from"com.liferay.exportimport.internal.background.task.LayoutStagingBackgroundTaskExecutor"
to"com.liferay.exportimport.internal.background.task.LayoutRemoteStagingBackgroundTaskExecutor"
.
Additional Information