Hi,
I have a data source defined as:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url"
value="${com.groupgti.esb.cxf.tracking.dataSource.url}" />
<property name="username"
value="${com.groupgti.esb.cxf.tracking.dataSource.username}" />
<property name="password"
value="${com.groupgti.esb.cxf.tracking.dataSource.password}" />
<property name="initialSize" value="10" />
<property name="maxActive" value="100" />
<property name="maxIdle" value="10" />
<property name="maxWait" value="5000" />
<property name="minEvictableIdleTimeMillis" value="300000" />
<property name="timeBetweenEvictionRunsMillis" value="100000" />
<property name="testWhileIdle" value="true" />
<property name="validationQuery" value="select 1;" />
</bean>
Entities in the system have @Id values defined as:
@Entity
@Table( name = "Message" )
@NamedQueries( {
@NamedQuery( name = "Message_JpaImpl.findAll", query = "SELECT o from
Message_JpaImpl o " )
} )
public class Message_JpaImpl implements Message {
@Id
@GeneratedValue( strategy = GenerationType.SEQUENCE, generator =
"Message_JpaImpl" )
@SequenceGenerator( name = "Message_JpaImpl", sequenceName =
"class-table()" )
@Column
private long id;
When we thrash the system we get up to 100 connections to the database and then
it deadlocks - the connections remain there but no more are created and nothing
gets through them.
Looking at a thread dump I see:
153 threads calling org.apache.commons.pool.impl.GenericObjectPool.borrowObject
to try to get a connection
100 threads calling org.apache.openjpa.jdbc.kernel.TableJDBCSeq.nextInternal to
try to get an ID value
1 thread stuck calling borrowObject inside a call to nextInternal - to get a
connection in order to grab the next chunk of IDs.
This is pretty much a deadlock (every 5s the attempt to get a chunk of IDs will
fail, so another thread will try to get them, but the chances of it succeeding
are pretty slim (1:153 against)).
There are a few things I can do to reduce the chances of hitting this, but the
only way to fix it completely is for the call to nextInternal to avoid using my
main connection pool.
According to the JavaDoc for AbstractJDBCSeq it "handles whether a second
datasource is configured" - if this is true, how can I configure it to use a
second connection?
It looks like I ought to be able to set something in the sequenceName
parentheses, but I can't see what.
Is there some other fix for this?
Thanks
Jim