users@glassfish.java.net

Derby DB / How to increase Heap Size / asadmin start-database

From: <glassfish_at_javadesktop.org>
Date: Wed, 13 Aug 2008 01:44:53 PDT

Hi!

I've created a table with some entries ( 50.000.000 ;-) ).

I run a this update Query:
[code]final Query cleanUpQuery = em.createQuery("DELETE FROM MyTable mt");
cleanUpQuery.executeUpdate();[code]

After 4 hours I got this exception on glassfish:
[code][#|2008-08-13T07:31:44.923+0200|WARNING|sun-appserver9.1|oracle.toplink.essentials.session.file:/C:/Data/ear/../dist-exploded/ear/jar_jar/-myPu|_ThreadID=18;_ThreadName=p: thread-pool-1; w: 6;_RequestID=483d07f4-f431-469e-9c37-a9a6b3fd647e;|
Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ001, SQLERRMC: java.lang.OutOfMemoryErrorJava heap spaceXJ001.U
Error Code: -1
Call: DELETE FROM MY_TABLE
Query: DeleteAllQuery()
        at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:311)
        at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:654)
        at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:703)
        at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:492)
        at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:452)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeCall(AbstractSession.java:690)
        at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
        at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:214)
        at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.deleteAll(DatasourceCallQueryMechanism.java:122)
        at oracle.toplink.essentials.queryframework.DeleteAllQuery.executeDatabaseQuery(DeleteAllQuery.java:198)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:555)
        at oracle.toplink.essentials.queryframework.ModifyAllQuery.executeInUnitOfWork(ModifyAllQuery.java:168)
        at oracle.toplink.essentials.queryframework.DeleteAllQuery.executeInUnitOfWork(DeleteAllQuery.java:124)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:924)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.executeUpdate(EJBQueryImpl.java:397)
        at de.test.TesterBean.cleanUpTestData(TesterBean.java:71)
        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.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
        at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
        at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
        at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:197)
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:127)
        at $Proxy163.cleanUpTestData(Unknown Source)
        at de.test.Test.onEvent(Test.java:37)
        at de.test.Handler.onMessage(Handler.java:29)
        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.sun.enterprise.security.SecurityUtil$2.run(SecurityUtil.java:182)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.enterprise.security.application.EJBSecurityManager.doAsPrivileged(EJBSecurityManager.java:1041)
        at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:187)
        at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
        at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
        at com.sun.ejb.containers.MessageBeanContainer.deliverMessage(MessageBeanContainer.java:1111)
        at com.sun.ejb.containers.MessageBeanListenerImpl.deliverMessage(MessageBeanListenerImpl.java:74)
        at com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:179)
        at $Proxy174.onMessage(Unknown Source)
        at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:258)
        at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:76)
        at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
Caused by: java.sql.SQLException: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ001, SQLERRMC: java.lang.OutOfMemoryErrorJava heap spaceXJ001.U
        at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
        at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
        at org.apache.derby.client.am.PreparedStatement.executeUpdate(Unknown Source)
        at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:647)
        ... 47 more
Caused by: org.apache.derby.client.am.SqlException: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ001, SQLERRMC: java.lang.OutOfMemoryErrorJava heap spaceXJ001.U
        at org.apache.derby.client.am.Statement.completeExecute(Unknown Source)
        at org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(Unknown Source)
        at org.apache.derby.client.net.NetStatementReply.readExecute(Unknown Source)
        at org.apache.derby.client.net.StatementReply.readExecute(Unknown Source)
        at org.apache.derby.client.net.NetPreparedStatement.readExecute_(Unknown Source)
        at org.apache.derby.client.am.PreparedStatement.readExecute(Unknown Source)
        at org.apache.derby.client.am.PreparedStatement.flowExecute(Unknown Source)
        at org.apache.derby.client.am.PreparedStatement.executeUpdateX(Unknown Source)
        ... 49 more
|#]
[/code]

In my Derby.log I see this:
[code]2008-08-13 02:27:41.765 GMT Thread[DRDAConnThread_5,5,main] (XID = 7789417), (SESSIONID = 33), (DATABASE = mydatabase), (DRDAID = NF000001.H264-651894827499824258{35}), Cleanup action starting
2008-08-13 02:27:41.765 GMT Thread[DRDAConnThread_5,5,main] (XID = 7789417), (SESSIONID = 33), (DATABASE = mydatabase), (DRDAID = NF000001.H264-651894827499824258{35}), Failed Statement is: DELETE FROM MY_TABLE
java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:2760)
        at java.util.Arrays.copyOf(Arrays.java:2734)
        at java.util.ArrayList.ensureCapacity(ArrayList.java:167)
        at java.util.ArrayList.add(ArrayList.java:351)
        at org.apache.derby.impl.store.raw.xact.Xact.addPostCommitWork(Unknown Source)
        at org.apache.derby.impl.store.access.RAMTransaction.addPostCommitWork(Unknown Source)
        at org.apache.derby.impl.store.access.heap.HeapController.queueDeletePostCommitWork(Unknown Source)
        at org.apache.derby.impl.store.access.conglomerate.GenericConglomerateController.delete(Unknown Source)
        at org.apache.derby.impl.sql.execute.RowChangerImpl.deleteRow(Unknown Source)
        at org.apache.derby.impl.sql.execute.DeleteResultSet.collectAffectedRows(Unknown Source)
        at org.apache.derby.impl.sql.execute.DeleteResultSet.open(Unknown Source)
        at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(Unknown Source)
        at org.apache.derby.iapi.jdbc.BrokeredPreparedStatement.execute(Unknown Source)
        at org.apache.derby.impl.drda.DRDAStatement.execute(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.parseEXCSQLSTT(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
Cleanup action completed
[/code]

So I wonder how I can increase the heap of java database, if I run "asadmin start-database".

Some one other has some problem:
http://markmail.org/message/b4jc2oninkcev37o
http://forums.java.net/jive/message.jspa?messageID=217473

But using the properties don't allow set java vm properties:
http://db.apache.org/derby/docs/10.1/tuning/ctunproper22250.html

Editing <install-dir>/javadb/frameworks/NetworkServer/bin/startNetworkServer is not a so beautifull way, I think.

Is there any other option?
[Message sent by forum member 'hegalor' (hegalor)]

http://forums.java.net/jive/thread.jspa?messageID=292980