AnsweredAssumed Answered

[Solved] Deadlocks when adding files

Question asked by dranakan on Aug 10, 2009
Latest reply on Aug 20, 2009 by dranakan
Hello,

An action is able to add some files in Alfresco. All works good with MySql but I have some problems using Ingres DB 9.2. Sometimes Ingres find Deadlocks.

The action try add add some files (it get some local PDF (in the alfresco temp), add some metadata and create in Alfresco). It can add 300 files in Alfresco, but sometimes the DB Ingres give a deadlock messages. It add 190 files and crash (sometimes after 100 files … it's not always different) . It appends 60% tests and only with lot of files (if I add 3 files in the method, all is ok).
The code is in a transaction and a rollback is done if problem appears.

Samples of method used during the process of adding files :


try {
            InputStream contentStream = new FileInputStream(file);
            // Write the content of the NodeRef
            ContentWriter writer = contentService.getWriter(nodeRef,
                  ContentModel.PROP_CONTENT, true);
            writer.setMimetype(mimetypeService.guessMimetype(file
                  .getAbsolutePath()));
            writer.setEncoding(ENCODING);
            writer.putContent(contentStream); // Line 403
            contentStream.close();
            return true;
         } catch (Exception e) {
            logger.error("Error adding file.",   e);
         }

:arrow: The crash is on : writer.putContent(contentStream); Before doing this code above, I created the node with ( ChildAssociationRef association = nodeService.createNode(…) NodeRef nodeRef = association.getChildRef();, add some metadata (… nodeService.addProperties(node, contentProps);

Message gived by the DB

LOCALHOST_LOCALDOM::[53860             , 5841      ,  02050100]: Fri Aug  7 11:08:00 2009 E_DM9042_PAGE_DEADLOCK        Deadlock encountered locking page 4 for table fk_alf_usaged_n in database alfresco with mode 2. Resource held by session [5841 24f8100] Mode 3.
LOCALHOST_LOCALDOM::[53860             , 5841      ,  02050100]: Fri Aug  7 11:08:00 2009 E_DM0042_DEADLOCK     Resource deadlock.
LOCALHOST_LOCALDOM::[53860             , 5841      ,  02050100]: Fri Aug  7 11:08:00 2009 E_QE002A_DEADLOCK     Deadlock detected.

Message gived by Alfresco (generate by the DB)

11:08:01,198  ERROR [manageoffice.workers.NodeManager] Error adding file.
org.alfresco.service.cmr.repository.ContentIOException: Failed to set content property on stream closure:
   node: workspace://SpacesStore/52bac846-156c-481c-abd3-f393183cd8c1
   property: {http://www.alfresco.org/model/content/1.0}content
   writer: ContentAccessor[ contentUrl=store://2009/8/7/11/7/057ba825-6109-4dd0-8cda-e06214457ab6.bin, mimetype=application/pdf, size=31204, encoding=UTF-8, locale=fr_FR]
        at org.alfresco.repo.content.RoutingContentService$WriteStreamListener.contentStreamClosed(RoutingContentService.java:626)
        at org.alfresco.repo.content.AbstractContentAccessor$CallbackFileChannel$1.execute(AbstractContentAccessor.java:357)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:246)
        at org.alfresco.repo.content.AbstractContentAccessor$CallbackFileChannel.fireChannelClosed(AbstractContentAccessor.java:367)
        at org.alfresco.repo.content.AbstractContentAccessor$CallbackFileChannel.implCloseChannel(AbstractContentAccessor.java:336)
        at java.nio.channels.spi.AbstractInterruptibleChannel.close(AbstractInterruptibleChannel.java:97)
        at java.nio.channels.Channels$1.close(Channels.java:138)
        at java.io.FilterOutputStream.close(FilterOutputStream.java:143)
        at org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:132)
        at org.alfresco.repo.content.AbstractContentWriter.putContent(AbstractContentWriter.java:423)
        at ch.custom.manageoffice.workers.NodeManager.addContentToFileFromFile(NodeManager.java:403)
        at ch.custom.manageoffice.workers.NodeManager.createNode(NodeManager.java:215)
        at ch.custom.manageoffice.workers.NodeManager.writeTree(NodeManager.java:693)
        at ch.custom.manageoffice.workers.NodeManager.createDirectoriesIfNotExisted(NodeManager.java:750)
        at ch.custom.manageoffice.workers.NodeManager.writeTree(NodeManager.java:661)
        at ch.custom.manageoffice.workers.NodeManager.createDirectoriesIfNotExisted(NodeManager.java:750)
        at ch.custom.manageoffice.workers.NodeManager.writeTree(NodeManager.java:616)
        at ch.custom.manageoffice.actions.SplittPDFFromERP.moveFilesAndAddMeta(SplittPDFFromERP.java:335)
        at ch.custom.manageoffice.actions.SplittPDFFromERP.access$0(SplittPDFFromERP.java:323)
        at ch.custom.manageoffice.actions.SplittPDFFromERP$1.execute(SplittPDFFromERP.java:243)
        at ch.custom.manageoffice.actions.SplittPDFFromERP$1.execute(SplittPDFFromERP.java:1)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320)
        at ch.custom.manageoffice.actions.SplittPDFFromERP.executeImpl(SplittPDFFromERP.java:232)
        at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:127)
        at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:592)
        at org.alfresco.repo.action.executer.CompositeActionExecuter.executeImpl(CompositeActionExecuter.java:72)
        at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:127)
        at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:592)
        at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:529)
        at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1$1.execute(AsynchronousActionExecutionQueueImpl.java:369)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:227)
        at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1.doWork(AsynchronousActionExecutionQueueImpl.java:378)
        at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:437)
        at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper.run(AsynchronousActionExecutionQueueImpl.java:381)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.springframework.dao.CannotAcquireLockException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.LockAcquisitionException: Could not execute JDBC batch update
        at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:619)
        at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:377)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338)
        at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.getChildAssocs(HibernateNodeDaoServiceImpl.java:2014)
        at sun.reflect.GeneratedMethodAccessor329.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
        at org.alfresco.repo.transaction.TransactionalDaoInterceptor.invoke(TransactionalDaoInterceptor.java:68)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.alfresco.repo.domain.hibernate.DirtySessionMethodInterceptor.invoke(DirtySessionMethodInterceptor.java:381)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy2.getChildAssocs(Unknown Source)
        at org.alfresco.repo.node.db.DbNodeServiceImpl.getChildAssocs(DbNodeServiceImpl.java:1376)
        at sun.reflect.GeneratedMethodAccessor158.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
        at org.alfresco.repo.transaction.SingleEntryTransactionResourceInterceptor.invoke(SingleEntryTransactionResourceInterceptor.java:127)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy7.getChildAssocs(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor158.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
        at org.alfresco.repo.tenant.MultiTNodeServiceInterceptor.invoke(MultiTNodeServiceInterceptor.java:110)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy7.getChildAssocs(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor158.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvocationHandler.invoke(StoreRedirectorProxyFactory.java:221)
        at $Proxy8.getChildAssocs(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor158.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
        at org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterceptor.java:306)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterceptor.java:306)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:274)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:274)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy7.getChildAssocs(Unknown Source)
        at org.alfresco.repo.rule.RuleServiceImpl.getSavedRuleFolderRef(RuleServiceImpl.java:229)
        at org.alfresco.repo.rule.RuleServiceImpl.getRules(RuleServiceImpl.java:380)
        at org.alfresco.repo.rule.RuleServiceImpl.getRules(RuleServiceImpl.java:348)
        at org.alfresco.repo.rule.RuleServiceImpl.getInheritedRules(RuleServiceImpl.java:503)
        at org.alfresco.repo.rule.RuleServiceImpl.getInheritedRules(RuleServiceImpl.java:494)
        at org.alfresco.repo.rule.RuleServiceImpl.getInheritedRules(RuleServiceImpl.java:494)
        at org.alfresco.repo.rule.RuleServiceImpl.getRules(RuleServiceImpl.java:363)
        at org.alfresco.repo.rule.RuleTypeImpl.triggerRuleType(RuleTypeImpl.java:132)
        at org.alfresco.repo.rule.ruletrigger.RuleTriggerAbstractBase.triggerRules(RuleTriggerAbstractBase.java:162)
        at org.alfresco.repo.rule.ruletrigger.OnContentUpdateRuleTrigger.onContentUpdate(OnContentUpdateRuleTrigger.java:120)
        at sun.reflect.GeneratedMethodAccessor446.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.policy.JavaBehaviour$JavaMethodInvocationHandler.invoke(JavaBehaviour.java:179)
        at $Proxy40.onContentUpdate(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor445.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.policy.PolicyFactory$MultiHandler.invoke(PolicyFactory.java:306)
        at org.alfresco.repo.policy.$Proxy185.onContentUpdate(Unknown Source)
        at org.alfresco.repo.content.RoutingContentService.onUpdateProperties(RoutingContentService.java:281)
        at sun.reflect.GeneratedMethodAccessor422.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.policy.JavaBehaviour$JavaMethodInvocationHandler.invoke(JavaBehaviour.java:179)
        at $Proxy13.onUpdateProperties(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor283.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.policy.PolicyFactory$MultiHandler.invoke(PolicyFactory.java:306)
        at org.alfresco.repo.policy.$Proxy164.onUpdateProperties(Unknown Source)
        at org.alfresco.repo.node.AbstractNodeServiceImpl.invokeOnUpdateProperties(AbstractNodeServiceImpl.java:345)
        at org.alfresco.repo.node.db.DbNodeServiceImpl.setProperty(DbNodeServiceImpl.java:1119)
        at sun.reflect.GeneratedMethodAccessor286.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
        at org.alfresco.repo.transaction.SingleEntryTransactionResourceInterceptor.invokeInternal(SingleEntryTransactionResourceInterceptor.java:169)
        at org.alfresco.repo.transaction.SingleEntryTransactionResourceInterceptor.invoke(SingleEntryTransactionResourceInterceptor.java:138)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy7.setProperty(Unknown Source)
at $Proxy7.setProperty(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor286.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
        at org.alfresco.repo.tenant.MultiTNodeServiceInterceptor.invoke(MultiTNodeServiceInterceptor.java:110)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy7.setProperty(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor286.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvocationHandler.invoke(StoreRedirectorProxyFactory.java:221)
        at $Proxy8.setProperty(Unknown Source)
        at org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterceptor.java:252)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:265)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:265)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy7.setProperty(Unknown Source)
        at org.alfresco.repo.content.RoutingContentService$WriteStreamListener.contentStreamClosed(RoutingContentService.java:606)
        … 38 more
Caused by: org.hibernate.exception.LockAcquisitionException: Could not execute JDBC batch update
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:82)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:309)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:182)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at sun.reflect.GeneratedMethodAccessor406.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1202)
        at $Proxy70.flush(Unknown Source)
        at org.alfresco.repo.domain.hibernate.DirtySessionMethodInterceptor.setQueryFlushMode(DirtySessionMethodInterceptor.java:257)
        at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl$17.doInHibernate(HibernateNodeDaoServiceImpl.java:2007)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
        … 162 more
Caused by: java.sql.BatchUpdateException: Deadlock detected, your single or multi-query transaction has been aborted.
        at com.ingres.gcf.jdbc.JdbcPrep.executeBatch(Unknown Source)
        at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
        … 175 more

Has someone an idea ?

Thanks

Outcomes