google-code-export / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

Null Pointer exception while executing a Select #307

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
H2 Version: h2-1.2.136.jar
Mode: Embedded
OS: Linux
JVM: 1.6.0_19 (32 Bit)
DB URL: 
jdbc:h2:db/cruise;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MVCC=TRUE;DATABASE_EV
ENT_LISTENER='foo'

We have actually used H2 under very heavy loads (in the order of half a million 
queries in a span of an hour) and are very happy with its flexibility and 
performance.

Recently we saw a NPE being thrown from H2. Our logs were filled with NPEs and 
looked like all the queries failed. However, on restarting the JVM, which in 
turn initiates a new DataSource and connection with DB seems to correct the 
issue and everything is back in order now. 

Not sure if this is some sort of a bug or if we need to something else. 

Trace:

Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/thoughtworks/cruise/server/dao/maps/Stage.xml.  
--- The error occurred while applying a parameter map.  
--- Check the allPassedStagesAfter-InlineParameterMap.  
--- Check the statement (query failed).  
--- Cause: org.h2.jdbc.JdbcSQLException: General error: 
"java.lang.NullPointerException" [50000-136]
        at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:201)
        at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForList(MappedStatement.java:139)
        at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:567)
        at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:541)
        at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
        at org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:298)
        at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:209)
        ... 18 more
Caused by: org.h2.jdbc.JdbcSQLException: General error: 
"java.lang.NullPointerException" [50000-136]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
        at org.h2.message.DbException.get(DbException.java:156)
        at org.h2.message.DbException.convert(DbException.java:279)
        at org.h2.message.DbException.toSQLException(DbException.java:252)
        at org.h2.message.TraceObject.logAndConvert(TraceObject.java:387)
        at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:190)
        at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
        at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
        at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:185)
        at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteQuery(MappedStatement.java:221)
        at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:189)
        ... 24 more
Caused by: java.lang.NullPointerException
        at org.h2.index.PageBtreeIndex.writeRow(PageBtreeIndex.java:362)
        at org.h2.index.PageBtreeLeaf.writeData(PageBtreeLeaf.java:262)
        at org.h2.index.PageBtreeLeaf.write(PageBtreeLeaf.java:239)
        at org.h2.store.PageStore.writeBack(PageStore.java:775)
        at org.h2.util.CacheLRU.removeOld(CacheLRU.java:179)
        at org.h2.util.CacheLRU.removeOldIfRequired(CacheLRU.java:124)
        at org.h2.util.CacheLRU.put(CacheLRU.java:102)
        at org.h2.store.PageStore.getPage(PageStore.java:592)
        at org.h2.index.PageDataIndex.getPage(PageDataIndex.java:211)
        at org.h2.index.PageDataNode.getRow(PageDataNode.java:281)
        at org.h2.index.PageDataNode.getRow(PageDataNode.java:282)
        at org.h2.index.PageDataIndex.getRow(PageDataIndex.java:387)
        at org.h2.index.PageDataIndex.getRow(PageDataIndex.java:376)
        at org.h2.table.RegularTable.getRow(RegularTable.java:104)
        at org.h2.index.PageBtreeIndex.getRow(PageBtreeIndex.java:285)
        at org.h2.index.PageBtreeCursor.get(PageBtreeCursor.java:45)
        at org.h2.index.MultiVersionCursor.get(MultiVersionCursor.java:81)
        at org.h2.index.IndexCursor.get(IndexCursor.java:207)
        at org.h2.table.TableFilter.getValue(TableFilter.java:662)
        at org.h2.expression.ExpressionColumn.getValue(ExpressionColumn.java:166)
        at org.h2.expression.Comparison.getValue(Comparison.java:173)
        at org.h2.expression.ConditionAndOr.getValue(ConditionAndOr.java:83)
        at org.h2.expression.Expression.getBooleanValue(Expression.java:185)
        at org.h2.table.TableFilter.isOk(TableFilter.java:332)
        at org.h2.table.TableFilter.next(TableFilter.java:296)
        at org.h2.command.dml.Select.queryFlat(Select.java:492)
        at org.h2.command.dml.Select.queryWithoutCache(Select.java:579)
        at org.h2.command.dml.Query.query(Query.java:233)
        at org.h2.index.ViewIndex.find(ViewIndex.java:191)
    at org.h2.index.IndexCursor.find(IndexCursor.java:136)
        at org.h2.table.TableFilter.next(TableFilter.java:254)
        at org.h2.command.dml.Select.queryFlat(Select.java:492)
        at org.h2.command.dml.Select.queryWithoutCache(Select.java:579)
        at org.h2.command.dml.Query.query(Query.java:233)
        at org.h2.index.IndexCondition.getCurrentResult(IndexCondition.java:156)
        at org.h2.index.IndexCursor.find(IndexCursor.java:93)
        at org.h2.table.TableFilter.next(TableFilter.java:254)
        at org.h2.command.dml.Select.queryFlat(Select.java:492)
        at org.h2.command.dml.Select.queryWithoutCache(Select.java:579)
        at org.h2.command.dml.Query.query(Query.java:233)
        at org.h2.command.CommandContainer.query(CommandContainer.java:80)
        at org.h2.command.Command.executeQuery(Command.java:132)
        at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:175)
        ... 29 more

Original issue reported on code.google.com by itspa...@gmail.com on 29 Mar 2011 at 5:00

GoogleCodeExporter commented 9 years ago
This issue happened yet again on the same database and bouncing the JVM again 
seemed to have fixed the issue.

I tried looking at what could have caused this issue, but have still not found 
a root cause yet. I do not know how to reproduce this either. Will keep you 
posted on the same. 

In the meanwhile, would it be possible to shed any light as to why this could 
be happening?

Thanks.

Original comment by itspa...@gmail.com on 31 Mar 2011 at 5:00

GoogleCodeExporter commented 9 years ago
Hi,

Sorry for the delay! 

You are using quite an old version. Is the problem reproducible with a more 
recent version, for example version 1.3.153? 

Do you use triggers?

Regards,
Thomas

Original comment by thomas.t...@gmail.com on 4 Apr 2011 at 5:39

GoogleCodeExporter commented 9 years ago
Hello,

This is an older version because we use it in our product that we ship to 
customers. And its weird, in my 2.5 years experience of using H2, this is the 
first time I am seeing this. I do not know the internals of H2 well enough to 
even guess what could be the cause (or the exact issue). 

So, I will try and see if this issue occurs in the version you mention. But, do 
you know what is this a symptom of? Like I said, this is just a temporary 
situation because when we bounce our server, the issue seems to have gone away.

And we do not use triggers.

Thanks,
Pavan

Original comment by itspa...@gmail.com on 5 Apr 2011 at 4:21

GoogleCodeExporter commented 9 years ago
> do you know what is this a symptom of? 

I'm not sure exactly, but it looks similar to a problem that was solved some 
time ago, where a deleted row was deleted again within a trigger. I guess it 
could also happen if you update or delete the row within a Java function, but 
I'm not sure.

If the problem still occurs, I would be very interested in trying to solve it.

Original comment by thomas.t...@gmail.com on 5 Apr 2011 at 5:45

GoogleCodeExporter commented 9 years ago
Hey,

So, we do not have any triggers on the DB. 

We run a *lot* of queries and our server is highly transactional. All the 
transactions, however, perform only updates i.e. we do not have any delete 
statements that get executed on any of the tables.

Also, this exception was happening on all select statements that were being 
executed as well and during updating. 

Since this is happening on a client setup, its hard to get all the things that 
would help me reproduce this issue. I currently have their .h2.db file. Will 
try and see what can be done to reproduce this issue.

- Pavan

Original comment by itspa...@gmail.com on 5 Apr 2011 at 7:11

GoogleCodeExporter commented 9 years ago
I'm closing the issue as 'works for me' currently. I will re-open it once we 
have more info.

Original comment by thomas.t...@gmail.com on 11 Sep 2011 at 3:03