RE: Unable to migrate documents to AdvancedFileSystemStore (Liferay 6.2)

Amos Fong, modified 5 Years ago. New Member Posts: 20 Join Date: 11/11/19 Recent Posts
I'm currently in the process of migrating documents to AdvancedFileSystemStore, using Liferay 6.2, but getting a FATAL error when it comes to a document that is attached to a message board post that no longer exists (at least, that is my understanding from the error message). This suggests when the thread was deleted, the associated files were not.

What is the relationships between file entries and message board posts? How can I fix this so document migration works as expected? I can see the id for the message board thread from the error, but not the document that is referencing it. The exception details are below:
12:38:14,204 FATAL [liferay/convert_process-1][ConvertProcessMessageListener:36] Unable to process message {destinationName=liferay/convert_process, response=null, responseDestinationName=null, responseId=null, payload=com.liferay.portal.convert.ConvertDocumentLibrary, values={defaultLocale=en_GB, companyId=10157, groupId=0, principalPassword=********, principalName=17492, permissionChecker=com.liferay.portal.kernel.util.TransientValue@76cd39af, siteDefaultLocale=en_GB, themeDisplayLocale=en_GB}}com.liferay.portal.convert.ConvertException: com.liferay.portlet.messageboards.NoSuchThreadException: No MBThread exists with the primary key 160221    at com.liferay.portal.convert.ConvertProcess.convert(ConvertProcess.java:51)    at com.liferay.portal.convert.messaging.ConvertProcessMessageListener.doReceive(ConvertProcessMessageListener.java:48)    at com.liferay.portal.convert.messaging.ConvertProcessMessageListener.receive(ConvertProcessMessageListener.java:33)    at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:72)    at com.liferay.portal.kernel.messaging.SerialDestination$1.run(SerialDestination.java:67)    at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:682)    at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:593)    at java.base/java.lang.Thread.run(Unknown Source)Caused by: com.liferay.portlet.messageboards.NoSuchThreadException: No MBThread exists with the primary key 160221    at com.liferay.portlet.messageboards.service.persistence.MBThreadPersistenceImpl.findByPrimaryKey(MBThreadPersistenceImpl.java:13452)    at com.liferay.portlet.messageboards.service.persistence.MBThreadPersistenceImpl.findByPrimaryKey(MBThreadPersistenceImpl.java:13470)    at com.liferay.portlet.messageboards.service.impl.MBThreadLocalServiceImpl.getThread(MBThreadLocalServiceImpl.java:608)    at jdk.internal.reflect.GeneratedMethodAccessor1216.invoke(Unknown Source)    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)    at java.base/java.lang.reflect.Method.invoke(Unknown Source)    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)    at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)    at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)    at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)    at com.sun.proxy.$Proxy171.getThread(Unknown Source)    at com.liferay.portlet.messageboards.service.MBThreadLocalServiceUtil.getThread(MBThreadLocalServiceUtil.java:552)    at com.liferay.portlet.messageboards.model.impl.MBMessageImpl.getThread(MBMessageImpl.java:237)    at com.liferay.portlet.messageboards.model.impl.MBMessageImpl.getThreadAttachmentsFolderId(MBMessageImpl.java:244)    at com.liferay.portlet.messageboards.model.impl.MBMessageImpl.getAttachmentsFolderId(MBMessageImpl.java:150)    at com.liferay.portlet.messageboards.model.impl.MBMessageImpl.getAttachmentsFileEntries(MBMessageImpl.java:102)    at com.liferay.portlet.messageboards.model.impl.MBMessageImpl.getAttachmentsFileEntries(MBMessageImpl.java:93)    at com.liferay.portal.convert.ConvertDocumentLibrary$3.performAction(ConvertDocumentLibrary.java:267)    at com.liferay.portal.kernel.dao.orm.BaseActionableDynamicQuery.performActions(BaseActionableDynamicQuery.java:70)    at com.liferay.portal.kernel.dao.orm.BaseActionableDynamicQuery.performActionsInMultipleIntervals(BaseActionableDynamicQuery.java:297)    at com.liferay.portal.kernel.dao.orm.BaseActionableDynamicQuery.performActions(BaseActionableDynamicQuery.java:43)    at com.liferay.portal.convert.ConvertDocumentLibrary.migrateMB(ConvertDocumentLibrary.java:282)    at com.liferay.portal.convert.ConvertDocumentLibrary.migratePortlets(ConvertDocumentLibrary.java:288)    at com.liferay.portal.convert.ConvertDocumentLibrary.doConvert(ConvertDocumentLibrary.java:116)    at com.liferay.portal.convert.ConvertProcess.convert(ConvertProcess.java:42)    ... 7 more
Sam Collett, modified 5 Years ago. New Member Posts: 20 Join Date: 11/11/19 Recent Posts
I have managed to find a fix to this, by deleting any message board posts without an associated thread. The failure happens when calling the MBMessage.getAttachmentsFileEntries() method, which includes code to get the message thread. 

DELETE FROM MBMessage
WHERE threadId NOT IN (SELECT threadId FROM MBThread)