After some more investigation, I think this happens when the database was 
created with H2 1.3.x, it is opened with H2 1.4.x, a SELECT query is 
performed that exceeds the "maxmemoryrows" value (a default of 10,000 
rows), and their is a TIMESTAMP column in the result.

It seems that the ResultDiskBuffer created to buffer the 
org.h2.result.ResultSet is getting a wrong result for row length from 
org.h2.store.Data.getValueLen(Value v, DataHandler handler) 
when v.getType() is of Value.TIMESTAMP. So a call to 
ByteArrayOutputStream.checkCapacity is given wrong input.

That's what I think, but as the code is foreign to me, I could be very 
wrong in my analysis.



On Monday, 3 August 2015 12:06:35 UTC+2, Steve McLeod wrote:
>
> It seems the problem is essentially caused by this:
>
> In H2 1.3, h2.storeLocalTime=false
> In H2 1.4, h2.storeLocalTime=true
>
> 1. Create a database with 1.3 that uses columns of type DATETIME
> 2. Subsequently open it with 1.4
> 3. You'll get sporadic exceptions when executing SQL select statements. 
> Here's a stack trace:
>
> org.h2.jdbc.JdbcSQLException: General error: 
> "java.lang.ArrayIndexOutOfBoundsException: 2048"
>
>   at org.h2.message.DbException.getJdbcSQLException(DbException.java:344) 
>                            
>   at org.h2.message.DbException.get(DbException.java:167)                 
>                            
>   at org.h2.message.DbException.convert(DbException.java:294)             
>                            
>   at org.h2.command.Command.executeQuery(Command.java:209)               
>                             
>   at 
> org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:109)
>  
>                  
>
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 2048               
> at org.h2.store.Data.writeVarLong(Data.java:1259)                      
> at org.h2.store.Data.writeValue(Data.java:526)                         
> at org.h2.index.PageBtreeIndex.writeRow(PageBtreeIndex.java:394)       
> at org.h2.index.PageBtreeNode.writeData(PageBtreeNode.java:454)        
> at org.h2.index.PageBtreeNode.write(PageBtreeNode.java:427)            
> at org.h2.store.PageStore.writeBack(PageStore.java:1047)               
> at org.h2.util.CacheLRU.removeOld(CacheLRU.java:216)                   
> at org.h2.util.CacheLRU.removeOldIfRequired(CacheLRU.java:142)         
> at org.h2.util.CacheLRU.put(CacheLRU.java:116)                         
> at org.h2.store.PageStore.getPage(PageStore.java:858)                  
> at org.h2.index.PageDataIndex.getPage(PageDataIndex.java:234)          
> at org.h2.index.PageDataNode.getNextPage(PageDataNode.java:233)        
> at org.h2.index.PageDataLeaf.getNextPage(PageDataLeaf.java:400)        
> at org.h2.index.PageDataCursor.nextRow(PageDataCursor.java:95)         
> at org.h2.index.PageDataCursor.next(PageDataCursor.java:53)            
> at org.h2.index.IndexCursor.next(IndexCursor.java:278)                 
> at org.h2.table.TableFilter.next(TableFilter.java:361)                 
> at org.h2.command.dml.Select.queryFlat(Select.java:533)                
> at org.h2.command.dml.Select.queryWithoutCache(Select.java:646)        
> at org.h2.command.dml.Query.query(Query.java:323)                      
> at org.h2.command.dml.Query.query(Query.java:291)                      
> at org.h2.index.ViewIndex.find(ViewIndex.java:283)                     
> at org.h2.index.ViewIndex.find(ViewIndex.java:179)                     
> at org.h2.index.BaseIndex.find(BaseIndex.java:128)                     
> at org.h2.index.IndexCursor.find(IndexCursor.java:160)                 
> at org.h2.table.TableFilter.next(TableFilter.java:330)                 
> at org.h2.command.dml.Select.queryGroup(Select.java:327)               
> at org.h2.command.dml.Select.queryWithoutCache(Select.java:641)        
> at org.h2.command.dml.Query.query(Query.java:323)                      
> at org.h2.command.dml.Query.query(Query.java:291)                      
> at org.h2.command.dml.Query.query(Query.java:37)                       
> at org.h2.command.CommandContainer.query(CommandContainer.java:91)     
> at org.h2.command.Command.executeQuery(Command.java:197)               
>
> The same problem occurs if I override  h2.storeLocalTime to be true on 1.3 
> and then open an existing database.
>
> The problem is sporadic; I've been unable to create a short test case. But 
> my findings are feasible, right?
>
> I'd say this is a significant problem.
>
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to