Guys,

In the latest 1.4.186 release I see NPE when running simple multithreaded 
benchmark:

@Benchmark
@Threads(4)
public void testMethod() throws SQLException {
    Connection c = connect.get();

    try (Statement s = c.createStatement()) {
        s.executeUpdate("create local temporary table t(id int)");
        s.executeUpdate("drop table t");
    }
}


Caused by: java.lang.NullPointerException
    at org.h2.mvstore.db.MVTable.checkDeadlock(MVTable.java:317)
    at org.h2.mvstore.db.MVTable.doLock1(MVTable.java:169)
    at org.h2.mvstore.db.MVTable.lock(MVTable.java:132)
    at org.h2.engine.Database.lockMeta(Database.java:890)
    at org.h2.command.ddl.DropTable.executeDrop(DropTable.java:102)
    at org.h2.command.ddl.DropTable.update(DropTable.java:114)
    at org.h2.command.CommandContainer.update(CommandContainer.java:78)
    at org.h2.command.Command.executeUpdate(Command.java:254)
    ... 15 more

This happens because field MVTable#lockExclusiveSession is nullified 
outside of lock in method #unlock but in method #checkDeadlock it is 
getting reread after the null check. To fix either assign it to a local var 
in #checkDeadlock or don't update outside of the lock in method #unlock.

By the way method #contains on ConcurrentHashMap (see field 
MVTable#lockSharedSessions) really means #constainsValue and does iteration 
over the whole map, I would recommend either to use #conatinsKey or use 
wrapper Collections.newSetFromMap to avoid confusions like that.

Sergi



-- 
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