java.io.IOException: Insufficient system resources exist to complete the requested service during connection

1,144 views
Skip to first unread message

oxj

unread,
Dec 15, 2009, 3:55:59 PM12/15/09
to H2 Database
I'm running H2 (v1.1.118 and I tried v1.2.125) as an embedded database
in a Java application and the current size is about 24GB. I've
installed our application onto 10 HP laptops and 6 of the 10 get the
following error during establishing a JDBC connection to this
database:

org.h2.jdbc.JdbcSQLException: IO Exception: "java.io.IOException:
Insufficient system resources exist to complete the requested
service"; "C:\SAClient\data\IBMPROD.SA.h2.db" [90031-125]
at org.h2.message.Message.getSQLException(Message.java:111)
at org.h2.message.Message.convertIOException(Message.java:329)
at org.h2.store.FileStore.readFully(FileStore.java:286)
at org.h2.store.PageStore.readPage(PageStore.java:963)
at org.h2.store.PageStore.getPage(PageStore.java:484)
at org.h2.store.PageStore.getFreeList(PageStore.java:796)
at org.h2.store.PageStore.allocatePage(PageStore.java:858)
at org.h2.store.PageStore.allocatePage(PageStore.java:850)
at org.h2.store.PageStore.openExisting(PageStore.java:308)
at org.h2.store.PageStore.open(PageStore.java:262)
at org.h2.engine.Database.getPageStore(Database.java:2313)
at org.h2.engine.Database.open(Database.java:626)
at org.h2.engine.Database.openDatabase(Database.java:228)
at org.h2.engine.Database.<init>(Database.java:222)
at org.h2.engine.Engine.openSession(Engine.java:58)
at org.h2.engine.Engine.openSession(Engine.java:142)
at org.h2.engine.Engine.getSession(Engine.java:122)
at org.h2.engine.SessionFactoryEmbedded.createSession
(SessionFactoryEmbedded.java:17)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer
(SessionRemote.java:245)
at org.h2.engine.SessionRemote.createSession(SessionRemote.java:223)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
at org.h2.Driver.connect(Driver.java:58)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.sps.sa.services.H2Service.startDB(H2Service.java:50)
at com.sps.sa.services.SADBService.startDB(SADBService.java:54)
at com.sps.sa.db.SADBServiceManager.startDataBases
(SADBServiceManager.java:45)
at com.sps.sa.views.MainFrame.jbInit(MainFrame.java:176)
at com.sps.sa.views.MainFrame.<init>(MainFrame.java:72)
at com.sps.sa.views.MainFrame.<clinit>(MainFrame.java:42)
at com.sps.sa.views.SAClient.<init>(SAClient.java:47)
at com.sps.sa.views.SAClient.main(SAClient.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sps.sa.views.SplashScreen.<init>(SplashScreen.java:64)
at com.sps.sa.views.SplashScreen.main(SplashScreen.java:86)
Caused by: java.io.IOException: Insufficient system resources exist to
complete the requested service
at java.io.RandomAccessFile.readBytes(Native Method)
at java.io.RandomAccessFile.read(Unknown Source)
at java.io.RandomAccessFile.readFully(Unknown Source)
at org.h2.store.FileStore.readFully(FileStore.java:284)
... 36 more

All machines have 2GB of RAM and are running Windows XP Pro (2002)
SP3. The only thing I've noticed that the failed machines have in
common is smaller Kernel memory size (total around 170000) especially
low non-paged (under 40000). However, I'm not sure that has anything
to do with this error as I can run the application on my old laptop
with 1GB RAM and 90000 total Kernel. I've also tried changing registry
settings as instructed by Microsoft in http://support.microsoft.com/kb/Q304101
to no avail. I also did a test using a small database (<100MB) and
that seems to work fine so it seems I'm running into a some type of
size limitation.

Has anyone encountered anything similar to this? Are there database
settings that I might be able to try to get around this problem?

Thanks in advance.

Has anyone encountered this error?

Thomas Mueller

unread,
Dec 17, 2009, 6:22:36 AM12/17/09
to h2-da...@googlegroups.com
Hi,

I never heard about this problem. You probably already know that


"Insufficient system resources exist to complete the requested

service" is from the OS and not from H2, and I guess you have already
done a Google search (just to make sure).

If the problem is the file size, then you could try using the 'split'
file system: http://www.h2database.com/html/advanced.html#file_system
- please tell me if this helps!

Regards,
Thomas

oxj

unread,
Dec 17, 2009, 3:07:19 PM12/17/09
to H2 Database
Thanks for the tip about the zip. I will try that next. I tried
splitting the data into three databases with the largest being 14GB
and that seems still too large for the machines to handle. Based on
the research I did it seems that the machines are running out of non
paged Kernel memory during the connection open. The MS bulletins I saw
regarding the problem were hinting at a possible memory leak to
eventually fill up the Kernel, but I don't know if that is the case
here.

Do you see any problem with keeping all three databases in the same
zip file and reading from there? Also, on average what do you think
will be the performance hit for keeping it all compressed?

Thanks so much for your help.

Yeah, based on the searches I know that it is an OS related problem.

On Dec 17, 6:22 am, Thomas Mueller <thomas.tom.muel...@gmail.com>
wrote:

oxj

unread,
Dec 17, 2009, 7:54:04 PM12/17/09
to H2 Database
So far no luck with the zip version: I created the database using the
backup tool. But when trying to establish a connection to the database
I get the following error:

org.h2.jdbc.JdbcSQLException: IO Exception: "java.io.IOException: File
is read-only"; "zip:C:/SAClient/data/IBMPROD.ExpSA.dbz!/
IBMPROD.ExpSA.h2.db" [90031-125]

oxj

unread,
Dec 17, 2009, 9:32:44 PM12/17/09
to H2 Database
I got the test database to work with the zip. I used the backup tool
instead of the command line utility and that cleared the read only
issue. I am now building the large databases. I'll keep you posted on
whether that gets us around the memory issue.

Ewald

unread,
Dec 18, 2009, 2:59:06 AM12/18/09
to H2 Database
Hi.

How much memory are you making available to the JVM? I've had a
similiar issue, but it turned out that I simply had to make more
memory available to my Java Runtime with the -Xmx parameter. I solved
this by using a small batch file to start the application, it also
creates a neat little console that I use during debugging if I use
java to start the application. I then switch to javaw when I go to
production, hiding the little console.

For example (development code), I put all of this in a batch file
called runner.bat:

@echo off
@cls
@start java -Xmx512m -jar POSClient.jar


Once I'm happy and am deploying on the client side, I change the code
to use the javaw application:

@echo off
@cls
@start javaw -Xmx512m -jar POSClient.jar


This works quite well on Windows machines, of course on my Linux box I
use a little script, but that's mostly for servers and development,
very very few of my clients actually use Linux for workstations.


Best regards
Ewald

Thomas Mueller

unread,
Dec 18, 2009, 3:14:27 AM12/18/09
to h2-da...@googlegroups.com
Hi,

> Thanks for the tip about the zip

> I got the test database to work with the zip.

I never wrote anything about "zip". I wrote:

> If the problem is the file size, then you could try using the 'split' file system:
> http://www.h2database.com/html/advanced.html#file_system

Regards,
Thomas

> --
>
> You received this message because you are subscribed to the Google Groups "H2 Database" group.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to h2-database...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
>
>
>

oxj

unread,
Dec 21, 2009, 11:07:30 AM12/21/09
to H2 Database
Ok, I tried the split and got the same error on the same machines
(insuff resources).

Yes, I do set the java heap size. The problem is not JVM running out
of memory, but rather it seems that there is a slow memory leak from
the JVM to the OS into the nonpaged Kernel and eventually there is not
enough memory left that the database requires during the page loads.
So the machines with smaller Kernel sizes run out before the
connection establishes.

Do you think it would make a difference if I did not run the database
in embedded mode but rather as a local server? Or is the page IO the
same when establishing a connection?

oxj

unread,
Dec 22, 2009, 12:10:06 PM12/22/09
to H2 Database
Also tried running it client/server instead of embedded and got the
same results.

I'm desperately trying to avoid switching databases so I think in the
short term I am going to split the data into smaller databases. The
magic size limit seems to be around 9GB at the moment. In the long run
this will not work as I know the data size will continue to grow.

Thomas Mueller

unread,
Dec 22, 2009, 1:17:29 PM12/22/09
to h2-da...@googlegroups.com
Hi,

I have a few questions:

- What is your database URL?
- Did the application run out of memory (once, or multiple times)?
- How did you start the Java process (java -Xmx... and so on)?
- Is it (or was it at some point) a networked file system?
- How big is the database (file sizes)?
- How much heap memory does the Java process have?
- Are there any other exceptions (maybe in the .trace.db file)?
   Could you send them please?
- After how long do you usually get this problem?

> Yes, I do set the java heap size. The problem is not JVM running out
> of memory, but rather it seems that there is a slow memory leak from
> the JVM to the OS into the nonpaged Kernel and eventually there is not
> enough memory left that the database requires during the page loads.
> So the machines with smaller Kernel sizes run out before the
> connection establishes.

Could you provide the link where you found this information, except
for the one you aleady sent?

I found this:

http://support.microsoft.com/kb/272568
Possible cause: "Norton AntiVirus"

http://www.coderanch.com/t/381258/Java-General/java/java-io-Exception-Insufficient-system
Possible cause: "UNC Path"

http://support.microsoft.com/kb/259837
Possible cause: "paged pool memory"

> Do you think it would make a difference if I did not run the database
> in embedded mode but rather as a local server? Or is the page IO the
> same when establishing a connection?

Yes, potentially it will help, however I think it should work without
such tricks. H2 doesn't use a lot of resources. Both Java and H2 are
used by many people without problems. I don't think there is a slow
memory leak in the JVM that will show up in your case.

Regards,
Thomas

oxj

unread,
Dec 23, 2009, 9:58:10 AM12/23/09
to H2 Database
Here is a recap of all the things I tried. It has been tough to
pinpoint the problem because I have been unable to duplicate the
problem in any of my three computers. In our team of 10, five of the
10 HP laptops got the error.

- First I had everything in one large database - 24GB in size and I
used the standard jdbc:h2:<path> connection
- I split the data into three databases (15GB, 7GB, 3GB). The
computers could establish a connection to the other two but not the
15GB one.
- I switched to using jdbc:h2:zip:
- I switched to using jdbc:h2:split:
- I switched to using jdbc:h2:tcp:
(In all of the above tests the application worked fine on the other
machines but the same five failed with identical error.)
- I split and trimmed the data further (into five databases) so now
the largest database is only 6GB in size and I went back to using
jdbc:h2:split. This is currently the working version now on all the
machines.


> - What is your database URL?

These are the connections I tried:
// connection = DriverManager.getConnection("jdbc:h2:tcp://
localhost/" + path + ";CACHE_SIZE=512000", "sa", "");
// connection = DriverManager.getConnection("jdbc:h2:" + path +
";CACHE_SIZE=512000", "sa", "");
// connection = DriverManager.getConnection("jdbc:h2:zip:" +
path + ";CACHE_SIZE=512000", "sa", "");
connection = DriverManager.getConnection("jdbc:h2:split:" +
path + ";CACHE_SIZE=512000", "sa", "");

> - Did the application run out of memory (once, or multiple times)?

application did not run out of memory. I have code to close the
application when a database connection cannot be established.

> - How did you start the Java process (java -Xmx... and so on)?

from a batch file:
java -Xms256m -Xmx900m -jar EvoClient.jar

> - Is it (or was it at some point) a networked file system?

The laptops are on our corporate network with some mapped drives, but
all the database files were copied onto the local drives.

> - How big is the database (file sizes)?

So far the largest ...h2.db was 24GB. I also know that 15GB was still
too large but that 7GB works.

> - How much heap memory does the Java process have?

Initial allocation is 256MB and maximum is set to 900MB

> - Are there any other exceptions (maybe in the .trace.db file)?

This is the only exception in the trace.db file:
12-10 09:43:46 database: opening C:\SAClient\data\IBMPROD.SA
org.h2.jdbc.JdbcSQLException: IO Exception: "java.io.IOException:


Insufficient system resources exist to complete the requested

service"; "C:\SAClient\data\IBMPROD.SA.h2.db" [90031-124]


at org.h2.message.Message.getSQLException(Message.java:111)
at org.h2.message.Message.convertIOException(Message.java:329)
at org.h2.store.FileStore.readFully(FileStore.java:286)

at org.h2.store.PageStore.readPage(PageStore.java:969)
at org.h2.store.PageStore.getPage(PageStore.java:490)
at org.h2.store.PageStore.getFreeList(PageStore.java:802)
at org.h2.store.PageStore.allocatePage(PageStore.java:864)
at org.h2.store.PageStore.allocatePage(PageStore.java:856)
at org.h2.index.PageDataLeaf.split(PageDataLeaf.java:352)
at org.h2.index.PageDataNode.addRowTry(PageDataNode.java:153)
at org.h2.index.PageDataNode.addRowTry(PageDataNode.java:145)
at org.h2.index.PageDataIndex.addTry(PageDataIndex.java:149)
at org.h2.index.PageDataIndex.add(PageDataIndex.java:122)
at org.h2.table.TableData.addRow(TableData.java:130)
at org.h2.store.PageStore.redo(PageStore.java:1196)
at org.h2.store.PageLog.recover(PageLog.java:285)
at org.h2.store.PageStore.recover(PageStore.java:1051)
at org.h2.store.PageStore.openExisting(PageStore.java:310)
at org.h2.store.PageStore.open(PageStore.java:268)
at org.h2.engine.Database.getPageStore(Database.java:2305)
at org.h2.engine.Database.open(Database.java:624)
at org.h2.engine.Database.openDatabase(Database.java:227)
at org.h2.engine.Database.<init>(Database.java:221)


at org.h2.engine.Engine.openSession(Engine.java:58)
at org.h2.engine.Engine.openSession(Engine.java:142)
at org.h2.engine.Engine.getSession(Engine.java:122)
at org.h2.engine.SessionFactoryEmbedded.createSession
(SessionFactoryEmbedded.java:17)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer
(SessionRemote.java:245)
at org.h2.engine.SessionRemote.createSession(SessionRemote.java:223)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
at org.h2.Driver.connect(Driver.java:58)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)

at com.sps.sa.services.H2Service.startDB(H2Service.java:49)
at com.sps.sa.services.SADBService.startDB(SADBService.java:53)


at com.sps.sa.db.SADBServiceManager.startDataBases
(SADBServiceManager.java:45)
at com.sps.sa.views.MainFrame.jbInit(MainFrame.java:176)
at com.sps.sa.views.MainFrame.<init>(MainFrame.java:72)
at com.sps.sa.views.MainFrame.<clinit>(MainFrame.java:42)
at com.sps.sa.views.SAClient.<init>(SAClient.java:47)
at com.sps.sa.views.SAClient.main(SAClient.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sps.sa.views.SplashScreen.<init>(SplashScreen.java:64)
at com.sps.sa.views.SplashScreen.main(SplashScreen.java:86)

Caused by: java.io.IOException: Insufficient system resources exist to
complete the requested service


at java.io.RandomAccessFile.readBytes(Native Method)
at java.io.RandomAccessFile.read(Unknown Source)
at java.io.RandomAccessFile.readFully(Unknown Source)
at org.h2.store.FileStore.readFully(FileStore.java:284)

... 45 more
12-10 09:45:21 database: opening C:\SAClient\data\IBMPROD.SA
org.h2.jdbc.JdbcSQLException: IO Exception: "java.io.IOException:


Insufficient system resources exist to complete the requested

service"; "C:\SAClient\data\IBMPROD.SA.h2.db" [90031-124]


at org.h2.message.Message.getSQLException(Message.java:111)
at org.h2.message.Message.convertIOException(Message.java:329)
at org.h2.store.FileStore.readFully(FileStore.java:286)

at org.h2.store.PageStore.readPage(PageStore.java:969)
at org.h2.store.PageStore.getPage(PageStore.java:490)
at org.h2.store.PageStore.getFreeList(PageStore.java:802)
at org.h2.store.PageStore.allocatePage(PageStore.java:864)
at org.h2.store.PageStore.allocatePage(PageStore.java:856)
at org.h2.index.PageDataLeaf.split(PageDataLeaf.java:352)
at org.h2.index.PageDataNode.addRowTry(PageDataNode.java:153)
at org.h2.index.PageDataNode.addRowTry(PageDataNode.java:145)
at org.h2.index.PageDataIndex.addTry(PageDataIndex.java:149)
at org.h2.index.PageDataIndex.add(PageDataIndex.java:122)
at org.h2.table.TableData.addRow(TableData.java:130)
at org.h2.store.PageStore.redo(PageStore.java:1196)
at org.h2.store.PageLog.recover(PageLog.java:285)
at org.h2.store.PageStore.recover(PageStore.java:1051)
at org.h2.store.PageStore.openExisting(PageStore.java:310)
at org.h2.store.PageStore.open(PageStore.java:268)
at org.h2.engine.Database.getPageStore(Database.java:2305)
at org.h2.engine.Database.open(Database.java:624)
at org.h2.engine.Database.openDatabase(Database.java:227)
at org.h2.engine.Database.<init>(Database.java:221)


at org.h2.engine.Engine.openSession(Engine.java:58)
at org.h2.engine.Engine.openSession(Engine.java:142)
at org.h2.engine.Engine.getSession(Engine.java:122)
at org.h2.engine.SessionFactoryEmbedded.createSession
(SessionFactoryEmbedded.java:17)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer
(SessionRemote.java:245)
at org.h2.engine.SessionRemote.createSession(SessionRemote.java:223)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
at org.h2.Driver.connect(Driver.java:58)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)

at com.sps.sa.services.H2Service.startDB(H2Service.java:49)
at com.sps.sa.services.SADBService.startDB(SADBService.java:53)


at com.sps.sa.db.SADBServiceManager.startDataBases
(SADBServiceManager.java:45)
at com.sps.sa.views.MainFrame.jbInit(MainFrame.java:176)
at com.sps.sa.views.MainFrame.<init>(MainFrame.java:72)
at com.sps.sa.views.MainFrame.<clinit>(MainFrame.java:42)
at com.sps.sa.views.SAClient.<init>(SAClient.java:47)
at com.sps.sa.views.SAClient.main(SAClient.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sps.sa.views.SplashScreen.<init>(SplashScreen.java:64)
at com.sps.sa.views.SplashScreen.main(SplashScreen.java:86)

Caused by: java.io.IOException: Insufficient system resources exist to
complete the requested service


at java.io.RandomAccessFile.readBytes(Native Method)
at java.io.RandomAccessFile.read(Unknown Source)
at java.io.RandomAccessFile.readFully(Unknown Source)
at org.h2.store.FileStore.readFully(FileStore.java:284)

... 45 more


>     Could you send them please?

> - After how long do you usually get this problem?

I put in debug statements right before the getconnection and right
after. I'm not exactly sure how long as I did not timestamp the
statements. But it seems about couple seconds into establishing the
connection. The second debug statement obviously does not get written
when the failure occurs.

> Could you provide the link where you found this information, except
> for the one you aleady sent?

I don't have any other links. I saw that last link as well. I can't
say for certain that the non paged Kernel is the issue. It is just
something we found in common with the failed machines. All 'good'
machines had a larger total Kernel and non paged whereas the failed
machines were all smaller in that regard. It is totally possible that
it could be something totally else and that is just a coincidence.

Thomas Mueller

unread,
Dec 25, 2009, 11:37:23 AM12/25/09
to h2-da...@googlegroups.com
Hi,

> //        connection = DriverManager.getConnection("jdbc:h2:tcp://
> localhost/" + path + ";CACHE_SIZE=512000", "sa", "");

The cache size is quite large. Could you try if it works using the
default cache size? And if yes, if it works using 128000. I would
probably not use a higher value (I don't think it will help
performance a lot).

> java -Xms256m -Xmx900m -jar EvoClient.jar

Could you try with a lower value, for example:

java -Xmx256m -jar EvoClient.jar

I'm not saying what you have used is wrong, I just like to find out if
using lower value solves the problem.

Regards,
Thomas

oxj

unread,
Dec 26, 2009, 3:04:02 PM12/26/09
to H2 Database
Hi,

Some of the queries ran out of memory with the default cache size. I
probably could get away with 256000 though but haven't tried it.

I did try the connection without specifying the cache size at all and
got the same resource error.

Thomas Mueller

unread,
Dec 31, 2009, 8:24:14 AM12/31/09
to h2-da...@googlegroups.com
Hi,

> Some of the queries ran out of memory with the default cache size.

That may be a different problem. Could you post the query that ran out
of memory? Also, could you run it with EXPLAIN SELECT ... and post the
query plan?

Regards,
Thomas

Reply all
Reply to author
Forward
0 new messages