I believe I understand the the cause of the hang. I investigated the 
simplest case of using a h2.serverResultSetFetchSize value of 600, which is 
greater than the 523 rows I know that I have. As I mentioned, I can 
retrieve the first 3 rows (single CLOB column) okay and then I either hang 
on the retrieval of the 4th row or I get a "The object is already closed" 
exception.

It turns out that the actual string comprising the first three columns seem 
to be rather short in length and method getInputStream in class 
org.h2.value.ValueLobDb has the data already and simply returns a 
ByteArrayInputStream constructed on this data. The 4th row's data is still 
on the server side and so an actual RemoteInputStream has to be built to 
process fetch the data from the server-side LOB.

Here's what seems to be the problem: Class org.h2.server.TcpServerThread is 
caching these LOBs in in instance of a SmallLRUCache. This cache seems to 
be designed to maintain only the least recently referenced LOBs!!! The 
default size of this cache is given by system property 
h2.serverCachedObjects, which defaults to 64, whereas the default fetch 
size is 100. So even if I had not overridden the default 
h2.serverResultSetFetchSize property, if all of my rows had sufficiently 
large columns requiring cached LOBs, any fetch size > 64 would cause the 
LOB representing the first row to be flushed out of the cache and I would 
not even be able to retrieve the first row.

An LRU cache seems to be the wrong structure for holding LOBs that are in 
an active result set. Certainly having a default cache size that is less 
than the default fetch size seems less than ideal.


On Monday, March 19, 2012 8:56:00 PM UTC-4, Ron Aaronson wrote:
>
> I am retrieving one text column (CLOB) from a table in a "remote" H2 
> database (actually on a local drive, but using Server, i.e. tcp/ip, to 
> access it) and after retrieving the first 100 rows the program hangs 
> on retrieving the next row of the result set. If, on the other hand, I 
> access the same database as an embedded database, there is no problem. 
> If I try to display the table's rows using H2's console application 
> accessing the database using the Server method, then I get the 
> following error message: 
>
> IO Exception: "java.io.IOException: org.h2.message.DbException: The 
> object is already closed [90007-164]"; 
> "lob: null table: 14 id: 1" [90031-164] 90031/90031 
>
> The table has 523 rows. When I started the application specifying 
> system property h2.serverResultSetFetchSize with a value of 600, it 
> hung after retrieving just 3 rows! When I reran specifying this 
> property with a value of 1, it no longer hung! Values up to 87 seem to 
> work OK. A value of 88 hung after 88 rows were returned.  I am a 
> newbie and it's not clear what this parameter is really supposed to be 
> doing.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/h2-database/-/pv5WP-jSRuMJ.
To post to this group, send email to h2-database@googlegroups.com.
To unsubscribe from this group, send email to 
h2-database+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to