I keep getting quite randomly the following kind of error when reading
BLOBs from database
org.h2.message.DbException: IO Exception: "java.io.EOFException";
"/root/.lobs.db/172.temp.db" [90031-143]
at
org.h2.message.DbException.get(DbException.java:156)
at
org.h2.message.DbException.convertIOException(DbException.java:313)
at
org.h2.store.FileStore.readFully(FileStore.java:287)
at
org.h2.store.FileStoreInputStream.fillBuffer(FileStoreInputStream.java:93)
at
org.h2.store.FileStoreInputStream.readBlock(FileStoreInputStream.java:73)
at
org.h2.store.FileStoreInputStream.read(FileStoreInputStream.java:61)
Behind it comes
Caused by: org.h2.jdbc.JdbcSQLException: IO Exception:
"java.io.EOFException"; "/root/.lobs.db/172.temp.db" [90031-143]
at
org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
... 31
more
Caused by:
java.io.EOFException
at
java.io.RandomAccessFile.readFully(RandomAccessFile.java:383)
at
org.h2.store.FileStore.readFully(FileStore.java:285)
... 28 more
My webserver shows images that are in the database and it seems that the
/root folder mentioned
in the exception point's to the webserver's (that is client's) /root folder.
This happens quite randomly so that when reloading the page, that
contains a list of images,
the image (BLOB) that causes the exception changes in a seemingly random
fashion.
Sometimes the exception is different like this
java.lang.NegativeArraySizeException
at
org.h2.util.Utils.newBytes(Utils.java:362)
at
org.h2.store.Data.expand(Data.java:1119)
at
org.h2.store.Data.checkCapacity(Data.java:1114)
at
org.h2.store.FileStoreInputStream.fillBuffer(FileStoreInputStream.java:100)
at
org.h2.store.FileStoreInputStream.readBlock(FileStoreInputStream.java:73)
at
org.h2.store.FileStoreInputStream.read(FileStoreInputStream.java:61)
Any ideas what this might be about or how to debug it further?
- Rami
I think the problem is that you try to read from the LOB object after
going to the next row in the result set, or after closing the result
set or connection. If this is not the problem, could you try with H2
version 1.2.145? Could you create a reproducible test case?
Regards,
Thomas
I created a test case where I create 10 threads that are started
approximately the same time and read 10 separate Blobs from a table
(altogether 100 blobs).
The test case is written in Beanshell and uses some of my utility
classes so you are not capable of running it but you can check it out as
pseudocode if you want (attached).
All threads report the same error:
Exception in thread "Thread-1" java.lang.OutOfMemoryError: Requested
memory: 1952885510
at org.h2.util.Utils.newBytes(Utils.java:364)
at org.h2.store.Data.expand(Data.java:1119)
at org.h2.store.Data.checkCapacity(Data.java:1114)
at
org.h2.store.FileStoreInputStream.fillBuffer(FileStoreInputStream.java:100)
at
org.h2.store.FileStoreInputStream.readBlock(FileStoreInputStream.java:73)
at org.h2.store.FileStoreInputStream.read(FileStoreInputStream.java:61)
I am quite convinced that these exceptions happen only when the reads
are concurrent.
When I limit the speed by writing to a slow output then I do not
encounter errors.
I will now try with version 1.2.145 as you suggested but it is a bit
more complicated in my case
because I have to merge separately my own changes to source (which you
did not accept as part of H2...)
- Rami
The results were better but not optimal.
Instead of all threads throwing exceptions I got 4 exceptions with the
100 reads.
They were now of the form:
Exception in thread "Thread-4" org.h2.message.DbException: IO Exception:
"java.io.EOFException";
"/opt/dev/+apps/exodus/test/.lobs.db/216.temp.db" [90031-143]
at org.h2.message.DbException.get(DbException.java:156)
at org.h2.message.DbException.convertIOException(DbException.java:313)
at org.h2.store.FileStore.readFully(FileStore.java:287)
at
org.h2.store.FileStoreInputStream.fillBuffer(FileStoreInputStream.java:93)
at
org.h2.store.FileStoreInputStream.readBlock(FileStoreInputStream.java:73)
at org.h2.store.FileStoreInputStream.read(FileStoreInputStream.java:61)
So clearly the local copies of the blobs keep encountering EOFException
when there is a higher read concurrency.
- Rami
For multiple reasons, your test case is not reproducible:
- the create table statements are missing
- the data is missing (insert statements)
- the test is not self-contained
- I can't reproduce the problem
My test case is: http://h2database.com/p.html#7051c1db4cfd824bb7c45e29c4d15ac6
Regards,
Thomas
I'm sorry, I can't reproduce the problem using your database. Could
you try again using the newest version, and then post the complete
stack trace? I think you didn't post the complete one (but I'm not
sure).
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.
>
And indeed the errors I reported have disappeared with the newest version.
I get them everytime I use the older 1.2.147 but never with 1.3.147.
So even though you could not reproduce the problem you somehow managed
to fix it! ;-)
Thank you.
- Rami
> I updated h2 and there were A LOT of changes.
Well, there always are.
> When I built it, it turned out that the jar was 1.3.147 instead of 1.2.147
> as before.
> So I suppose you changed the head of trunk from 1.2 to 1.3?
This is a small change: Constants.java, change VERSION_MINOR to 2.
Other settings depend on it, so this small change will have a big
effect.
Regards,
Thomas