cancel
Showing results for 
Search instead for 
Did you mean: 

Timeout trying to lock table 'ACT_HI_ACTINST' [50200-132]

ronnie_and_sand
Champ in-the-making
Champ in-the-making
Apologies again for having to include logs and scripts in-line. All attachment extensions I've tried are not allowed.

We are looking at how Activiti handles process failure.

The contrived script, below, throws an exception on the 2nd task.

Immediate attempts to go to the Manage link in activiti-explorer fail, with the "lock" message showing up in the tomcat console.

This was originally done w/ an instance of Activiti 5.8 that we had on our server for awhile, but it also happens with a brand new install, so it should be easily reproduced. The error sometimes takes on other forms, such as fails to insert into ACT_HI_ACTINST for "good" processes. I've also gotten into the Manage link, only to get the "lock" message when attempting to scroll to the bottom of the ACT_HI_ACTINST contents. I've even seen the server "recover" from the lock error, at least temporarily. As I composed this, it recovered, but has slipped back into a bad lock state when attempting to view ACT_HI_ACTINST

——

bpmn script:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
    <process id="TableLockError" name="TableLockError">
        <documentation>Place documentation for the 'TableLockError' process here.</documentation>
        <startEvent id="startevent1" name="Start"></startEvent>
        <scriptTask id="hello1" name="hello1" scriptFormat="groovy">
            <script>
                System.out.println("hello1");
            </script>
        </scriptTask>
        <scriptTask id="conditionalFail" name="conditionalFail" scriptFormat="groovy">
            <script>
                throw new Throwable("new Throwable");
            </script>
        </scriptTask>
        <scriptTask id="hello2" name="hello2" scriptFormat="groovy">
            <script>
                System.out.println("hello2");
            </script>
        </scriptTask>
        <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="hello1"></sequenceFlow>
        <endEvent id="endevent1" name="End"></endEvent>
        <sequenceFlow id="flow2" name="" sourceRef="hello1" targetRef="conditionalFail"></sequenceFlow>
        <sequenceFlow id="flow3" name="" sourceRef="conditionalFail" targetRef="hello2"></sequenceFlow>
        <sequenceFlow id="flow4" name="" sourceRef="hello2" targetRef="endevent1"></sequenceFlow>
    </process>
</definitions>

——

tomcat log:

Dec 1, 2011 4:36:57 PM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: couldn't get table counts
        at org.activiti.engine.impl.persistence.entity.TableDataManager.getTableCount(TableDataManager.java:50)
        at org.activiti.engine.impl.cmd.GetTableCountCmd.execute(GetTableCountCmd.java:30)
        at org.activiti.engine.impl.cmd.GetTableCountCmd.execute(GetTableCountCmd.java:25)
        at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
        at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
        at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
        at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
        at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
        at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
        at org.activiti.engine.impl.ManagementServiceImpl.getTableCount(ManagementServiceImpl.java:42)
        at org.activiti.explorer.ui.management.db.DatabasePage.populateTableList(DatabasePage.java:93)
        at org.activiti.explorer.ui.management.db.DatabasePage.initUi(DatabasePage.java:57)
        at org.activiti.explorer.ui.AbstractPage.attach(AbstractPage.java:43)
        at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:570)
        at com.vaadin.ui.AbstractComponentContainer.addComponent(AbstractComponentContainer.java:211)
        at com.vaadin.ui.CssLayout.addComponent(CssLayout.java:93)
        at org.activiti.explorer.ui.mainlayout.MainLayout.setMainContent(MainLayout.java:58)
        at org.activiti.explorer.ui.MainWindow.switchView(MainWindow.java:79)
        at org.activiti.explorer.DefaultViewManager.switchView(DefaultViewManager.java:272)
        at org.activiti.explorer.DefaultViewManager.showDatabasePage(DefaultViewManager.java:214)
        at org.activiti.explorer.ui.mainlayout.MainMenuBar$ShowManagementClickListener.buttonClick(MainMenuBar.java:203)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:490)
        at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
        at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1193)
        at com.vaadin.ui.Button.fireClick(Button.java:539)
        at com.vaadin.ui.Button.changeVariables(Button.java:206)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1299)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1219)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:735)
        at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296)
        at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: org.h2.jdbc.JdbcSQLException: Timeout trying to lock table "ACT_HI_ACTINST" [50200-132]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:316)
        at org.h2.message.DbException.get(DbException.java:167)
        at org.h2.message.DbException.get(DbException.java:144)
        at org.h2.table.RegularTable.doLock(RegularTable.java:444)
        at org.h2.table.RegularTable.lock(RegularTable.java:382)
        at org.h2.table.TableFilter.lock(TableFilter.java:117)
        at org.h2.command.dml.Select.queryWithoutCache(Select.java:542)
        at org.h2.command.dml.Query.query(Query.java:233)
        at org.h2.command.CommandContainer.query(CommandContainer.java:80)
        at org.h2.command.Command.executeQuery(Command.java:132)
        at org.h2.server.TcpServerThread.process(TcpServerThread.java:276)
        at org.h2.server.TcpServerThread.run(TcpServerThread.java:135)
        at java.lang.Thread.run(Thread.java:662)

### The error may involve org.activiti.engine.impl.TablePageMap.selectTableCount-Inline
### The error occurred while setting parameters
4 REPLIES 4

trademak
Star Contributor
Star Contributor
Hi,

Can you explain a bit more in detail what you are trying to proof with this and exactly when does this error occur.
So does it occur when you are starting multiple instances of this process while accessing the manage section in the Activiti Explorer?

Best regards,

ronnie_and_sand
Champ in-the-making
Champ in-the-making
Our team was wondering how any of the products we are evaluating handle process exceptions.

This has generally occurred after starting just 1 instance of the process, followed by attempts to access the manage section of Activiti Explorer.

It looks like a best practice approach for our team will be to use BPMN exception handling, as hinted at here http://forums.activiti.org/en/viewtopic.php?f=6&t=2935 and described in the user manual.

Thanks!

ronnie_and_sand
Champ in-the-making
Champ in-the-making
Here is a BPMN way to handle java exceptions.

A scriptTask template would be

        <scriptTask id="scriptTask1" name="scriptTask1" scriptFormat="groovy">
            <script>
                processThrowable=null;
                try
                {
                <!– do stuff –>
                }
                catch (Throwable blockThrowable)
                {
                processThrowable=blockThrowable;
                }
            </script>
        </scriptTask>

And there would need to be 2 sequence flows for each scriptTask:

        <sequenceFlow id="scriptTask1NextRealTarget" name="" sourceRef="scriptTask1" targetRef="nextRealTarget">
            <conditionExpression>${null==processThrowable}</conditionExpression>
        </sequenceFlow>
        <sequenceFlow id="scriptTask1HandleThrowable" name="" sourceRef="scriptTask1" targetRef="handleThrowable">
            <conditionExpression>${null!=processThrowable}</conditionExpression>
        </sequenceFlow>

We've tested this solution.

The issue is that the outflow of each scriptTask has a decision flow, which gets uglier as the process gets more complex.

We're open to better, more general solutions, if anyone has one.

Thanks!

ronnie_and_sand
Champ in-the-making
Champ in-the-making
One way to avoid all the BPMN branching is to modify the groovy source code to wrap a Throwable as a ScriptException when the eval method fails, as was done below. The same approach could be used for every groovy script task, but what follows (in the groovy source code) only has to be done once.

In any case, when a ScriptException is thrown instead of Throwable, the table lock errors are avoided. However, we have not been able to track down evidence/history/state of a process where a ScriptException was thrown. There is no record in ACT_HI_PROCINST nor ACT_HI_ACTINST.

Does anyone know where information about ScriptException processes are stored or, more generally, how ScriptException processes are handled by Activiti?

Thank You!



GroovyScriptEngineImpl.eval wrap of Throwable:

//        } catch (Exception e) {
//            throw new ScriptException(e);
        } catch (Throwable e) {
            throw new ScriptException(new Exception(e));