My latest findings:
I can reproduce (again, sporadically) the problem by exclusively using h2
1.4.188 as follows:
1) set System.setProperty("h2.storeLocalTime", "false"), start the app,
import some data; then
2) restart the app with System.setProperty("h2.storeLocalTime", "true") and
import some more data.
Once the error occurs, the database is in a corrupted state.
I've managed to create and save a corrupted database, which is zipped to
only 5 MB. The zip file includes a trace.db file. Thomas, let me know if it
is useful for you to see this corrupted database.
So far I've been doing this with MV_STORE=false.
I'll continue posting more info as I narrow down the problem.
On Tuesday, 4 August 2015 18:48:06 UTC+2, Steve McLeod wrote:
>
> Hi Thomas,
>
> The database is created with 1.3.176. The error happens in 1.4.188.
>
> I don't normally set h2.storeLocalTime - I just observed that it has a
> different default in 1.4 to 1.3, and at one point my investigations led me
> to code dependent on the value. To investigate further, I tried reloading
> the database created in 1.3.176, this time running
> System.setProperty("h2.storeLocalTime", "true") immediately before loading
> the H2 JDBC driver (which I do using Class.forName("org.h2.Driver")), and
> was able to sporadically reproduce the problem.
>
> Here's a stack trace (right now it is happening with a simple INSERT
> statement)
>
> sql = INSERT INTO hand (gameid, casinoid, gamenumber, starttime) VALUES
> (?, ?, ?, ?)
> org.h2.jdbc.JdbcSQLException: General error:
> "java.lang.ArrayIndexOutOfBoundsException"; SQL statement:
> INSERT INTO hand (gameid, casinoid, gamenumber, starttime) VALUES (?, ?,
> ?, ?) [50000-188]
> at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
> at org.h2.message.DbException.get(DbException.java:168)
> at org.h2.message.DbException.convert(DbException.java:295)
> at org.h2.table.RegularTable.addRow(RegularTable.java:137)
> at org.h2.command.dml.Insert.insertRows(Insert.java:156)
> at org.h2.command.dml.Insert.update(Insert.java:114)
> at org.h2.command.CommandContainer.update(CommandContainer.java:78)
> at org.h2.command.Command.executeUpdate(Command.java:254)
> at
> org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:157)
> at
> org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:143)
> at // non-h2 removed
>
> Caused by: java.lang.ArrayIndexOutOfBoundsException
>
> I'll keep investigating...
>
> I can also supply a database that has the problem, but it is 768 MB after
> zipping...so I think I'll try to write some repro code instead.
>
>
> On Tuesday, 4 August 2015 18:01:59 UTC+2, Thomas Mueller wrote:
>>
>> Hi,
>>
>> Maybe you can reproduce the problem more easily if you set the system
>> property "h2.check2" to "true".
>>
>> I couldn't reproduce the problem so far, and the code looks correct to me
>> (I debugged it and added some trace output, both for storeLocalTime true
>> and false). Maybe it's a bug in an old version, or some strange combination.
>>
>> Could you post the exact stack trace including error message and error
>> code?
>>
>> Which version of H2 do you use exactly (1.3.x and 1.4.x), and what is the
>> "create_build" in the database file (select * from
>> information_schema.settings)? How do you set the system property (in which
>> version of H2, how, and when)? It would need to be set before loading the
>> H2 driver.
>>
>> Regards,
>> Thomas
>>
>>
>> On Tuesday, August 4, 2015, Steve McLeod <[email protected]> wrote:
>>
>>> 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.
>>>
>>
--
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.