Hi All,

We identified the root cause for the JIRA issue [1]
<https://wso2.org/jira/browse/BPS-185>.

In datasources.properties file, Database connectivity related information
are stored in org.apache.commons.dbcp.BasicDataSource class.

BasciDataSource class has the following variable{

protected volatile boolean defaultAutoCommit = true;
}

Because of the above mentioned default value, without explicitly mentioning
about the defaultAutoCommit value in the datasources.properties, BPS was
able to handle transactions.

But with the introduction of *NDatasource*,
org.apache.tomcat.jdbc.pool.PoolProperties maintains the pool configuration
properties.

PoolProperties class has the following variable{

private volatile java.lang.Boolean defaultAutoCommit = null;
}

Therefore we thought of adding the <defaultAutoCommit> tag in the NData
source file ( bps-datasources.xml) to solve this issue.

After that I did the following tests which turned out to be positive.


   1. Tested the latest snapshot (3.5.0) in a clustered environment ( using
   mysql ).
   2. Tested the single node 3.2.0 with ( both H2 and mysql database ).
   3. Tested the latest snapshot (3.5.0)  single node ( mysql).


But I encountered a problem when I tried to shut down the latest snapshot
(3.5.0)  ( with H2 ), it threw following exceptions.

[2014-08-25 00:34:43,792]  INFO
{org.wso2.carbon.tomcat.ext.internal.CarbonTomcatServiceComponent} -
 Stopping the carbon web-app registered under : /
[2014-08-25 00:34:43,816]  INFO
{org.wso2.carbon.attachment.mgt.server.internal.AttachmentServiceComponent}
-
 
org.wso2.carbon.attachment.mgt.server.internal.AttachmentServiceComponent.deactivate
[2014-08-25 00:34:43,847] ERROR
{org.activiti.engine.impl.interceptor.CommandContext} -  Error while
closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: org.h2.jdbc.JdbcSQLException: Database
is already closed (to disable automatic closing at VM shutdown, add
";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-140]
### The error may exist in org/activiti/db/mapping/entity/Job.xml
### The error may involve
org.activiti.engine.impl.persistence.entity.JobEntity.selectNextJobsToExecute
### The error occurred while executing a query
### SQL: select       RES.*            from ACT_RU_JOB RES          LEFT
OUTER JOIN ACT_RU_EXECUTION PI ON PI.ID_ = RES.PROCESS_INSTANCE_ID_
where (RES.RETRIES_ > 0)       and (RES.DUEDATE_ is null or RES.DUEDATE_ <
?)       and (RES.LOCK_OWNER_ is null or RES.LOCK_EXP_TIME_ < ?)    and (
      (RES.EXECUTION_ID_ is null)      or       (PI.SUSPENSION_STATE_ = 1)
      )       LIMIT ? OFFSET ?
### Cause: org.h2.jdbc.JdbcSQLException: Database is already closed (to
disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to
the db URL) [90121-140]
at
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
at
org.activiti.engine.impl.db.DbSqlSession.selectListWithRawParameter(DbSqlSession.java:286)
at
org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:277)
at
org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:272)
at
org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:259)
at
org.activiti.engine.impl.persistence.entity.JobEntityManager.findNextJobsToExecute(JobEntityManager.java:105)
at
org.activiti.engine.impl.cmd.AcquireJobsCmd.execute(AcquireJobsCmd.java:48)
at
org.activiti.engine.impl.cmd.AcquireJobsCmd.execute(AcquireJobsCmd.java:33)
at
org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at
org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at
org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at
org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
at
org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
at
org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable.run(AcquireJobsRunnable.java:59)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.h2.jdbc.JdbcSQLException: Database is already closed (to
disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to
the db URL) [90121-140]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.message.DbException.get(DbException.java:133)
at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1348)
at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1323)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:232)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126)
at
org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
at
org.wso2.carbon.ndatasource.rdbms.ConnectionRollbackOnReturnInterceptor.invoke(ConnectionRollbackOnReturnInterceptor.java:51)
at
org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
at
org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.invoke(AbstractCreateStatementInterceptor.java:67)
at
org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
at
org.apache.tomcat.jdbc.pool.interceptor.ConnectionState.invoke(ConnectionState.java:153)
at
org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
at org.apache.tomcat.jdbc.pool.TrapException.invoke(TrapException.java:41)
at
org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
at
org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:80)
at com.sun.proxy.$Proxy15.prepareStatement(Unknown Source)
at
org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:72)
at
org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:82)
at
org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:54)
at
org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:70)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56)
at
org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132)
at
org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)
... 15 more
[2014-08-25 00:34:43,849] ERROR
{org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable} -  exception
during job acquisition:
### Error querying database.  Cause: org.h2.jdbc.JdbcSQLException: Database
is already closed (to disable automatic closing at VM shutdown, add
";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-140]
### The error may exist in org/activiti/db/mapping/entity/Job.xml
### The error may involve
org.activiti.engine.impl.persistence.entity.JobEntity.selectNextJobsToExecute
### The error occurred while executing a query
### SQL: select       RES.*            from ACT_RU_JOB RES          LEFT
OUTER JOIN ACT_RU_EXECUTION PI ON PI.ID_ = RES.PROCESS_INSTANCE_ID_
where (RES.RETRIES_ > 0)       and (RES.DUEDATE_ is null or RES.DUEDATE_ <
?)       and (RES.LOCK_OWNER_ is null or RES.LOCK_EXP_TIME_ < ?)    and (
      (RES.EXECUTION_ID_ is null)      or       (PI.SUSPENSION_STATE_ = 1)
      )       LIMIT ? OFFSET ?
### Cause: org.h2.jdbc.JdbcSQLException: Database is already closed (to
disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to
the db URL) [90121-140]
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: org.h2.jdbc.JdbcSQLException: Database
is already closed (to disable automatic closing at VM shutdown, add
";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-140]
### The error may exist in org/activiti/db/mapping/entity/Job.xml
### The error may involve
org.activiti.engine.impl.persistence.entity.JobEntity.selectNextJobsToExecute
### The error occurred while executing a query
### SQL: select       RES.*            from ACT_RU_JOB RES          LEFT
OUTER JOIN ACT_RU_EXECUTION PI ON PI.ID_ = RES.PROCESS_INSTANCE_ID_
where (RES.RETRIES_ > 0)       and (RES.DUEDATE_ is null or RES.DUEDATE_ <
?)       and (RES.LOCK_OWNER_ is null or RES.LOCK_EXP_TIME_ < ?)    and (
      (RES.EXECUTION_ID_ is null)      or       (PI.SUSPENSION_STATE_ = 1)
      )       LIMIT ? OFFSET ?
### Cause: org.h2.jdbc.JdbcSQLException: Database is already closed (to
disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to
the db URL) [90121-140]
at
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
at
org.activiti.engine.impl.db.DbSqlSession.selectListWithRawParameter(DbSqlSession.java:286)
at
org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:277)
at
org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:272)
at
org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:259)
at
org.activiti.engine.impl.persistence.entity.JobEntityManager.findNextJobsToExecute(JobEntityManager.java:105)
at
org.activiti.engine.impl.cmd.AcquireJobsCmd.execute(AcquireJobsCmd.java:48)
at
org.activiti.engine.impl.cmd.AcquireJobsCmd.execute(AcquireJobsCmd.java:33)
at
org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at
org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at
org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at
org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
at
org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
at
org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable.run(AcquireJobsRunnable.java:59)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.h2.jdbc.JdbcSQLException: Database is already closed (to
disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to
the db URL) [90121-140]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.message.DbException.get(DbException.java:133)
at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1348)
at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1323)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:232)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126)
at
org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
at
org.wso2.carbon.ndatasource.rdbms.ConnectionRollbackOnReturnInterceptor.invoke(ConnectionRollbackOnReturnInterceptor.java:51)
at
org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
at
org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.invoke(AbstractCreateStatementInterceptor.java:67)
at
org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
at
org.apache.tomcat.jdbc.pool.interceptor.ConnectionState.invoke(ConnectionState.java:153)
at
org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
at org.apache.tomcat.jdbc.pool.TrapException.invoke(TrapException.java:41)
at
org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
at
org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:80)
at com.sun.proxy.$Proxy15.prepareStatement(Unknown Source)
at
org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:72)
at
org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:82)
at
org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:54)
at
org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:70)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56)
at
org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132)
at
org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)


The Root cause for the issue seems to be that activiti engine is trying to
commit in to the already closed H2 database ( This is because of enabling
defaultAutoCommit ).

How can we solve this issue? IMO Ideally activity engine should close
before H2 database closes.

Totally we can approach this issue by means of three ways

1) Dig deep in to the code and make sure H2 closes after activiti engine
closes.
2) By adding the param ";DB_CLOSE_ON_EXIT=FALSE" at the end of H2 url may
easily solve the issue.
3) We can set the PoolProperties class's defaultAutoCommit variable's
default value to true.

Any ideas or suggestions are welcome ?

 [1] https://wso2.org/jira/browse/BPS-185


Regards,
Firzhan
_______________________________________________
Architecture mailing list
Architecture@wso2.org
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to