Hi again,
I could get the problem again, and it seems that it happened due to an
OutOfMemoryError. The stack is this:
org.h2.jdbc.JdbcSQLException: IO Exception: "java.io.IOException: Map
failed"; "split:nioMapped:/opt/
jboss-5.0.1.GA/server/outsystems/data/
h2/localDB.h2.db"; SQL statement:
INSERT INTO JBM_MSG_CJQ (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP,
PRIORITY, TYPE, HEADERS, PAYLOAD) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
[90031-140]
at
org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:156)
at
org.h2.message.DbException.convertIOException(DbException.java:313)
at org.h2.store.FileStore.setLength(FileStore.java:397)
at org.h2.store.PageStore.increaseFileSize(PageStore.java:
1020)
at org.h2.store.PageStore.increaseFileSize(PageStore.java:
1011)
at org.h2.store.PageStore.allocatePage(PageStore.java:996)
at org.h2.store.PageStore.allocatePages(PageStore.java:965)
at org.h2.store.PageOutputStream.reserve(PageOutputStream.java:
74)
at org.h2.store.PageOutputStream.write(PageOutputStream.java:
123)
at org.h2.store.PageLog.write(PageLog.java:498)
at org.h2.store.PageLog.logAddOrRemoveRow(PageLog.java:602)
at org.h2.store.PageStore.logAddOrRemoveRow(PageStore.java:
1235)
at org.h2.index.PageDataIndex.addTry(PageDataIndex.java:193)
at org.h2.index.PageDataIndex.add(PageDataIndex.java:124)
at org.h2.table.RegularTable.addRow(RegularTable.java:116)
at org.h2.command.dml.Insert.insertRows(Insert.java:120)
at org.h2.command.dml.Insert.update(Insert.java:82)
at
org.h2.command.CommandContainer.update(CommandContainer.java:70)
at org.h2.command.Command.executeUpdate(Command.java:199)
at
org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:
141)
at
org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:
127)
[...]
Caused by: java.io.IOException: Map failed
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:758)
at
org.h2.store.fs.FileObjectDiskMapped.reMap(FileObjectDiskMapped.java:
102)
at
org.h2.store.fs.FileObjectDiskMapped.setFileLength(FileObjectDiskMapped.java:
164)
at
org.h2.store.fs.FileObjectSplit.setFileLength(FileObjectSplit.java:90)
at org.h2.store.FileStore.setLength(FileStore.java:395)
... 111 more
Caused by: java.lang.OutOfMemoryError: Map failed
at sun.nio.ch.FileChannelImpl.map0(Native Method)
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:755)
... 115 more
So the problem is that in org.h2.store.fs.FileObjectDiskMapped.reMap()
the line:
mapped = file.getChannel().map(mode, 0, length);
fails and mapped remains null, causing a lot of NullPointerExceptions
after that.
Maybe adding "if (mapping == null) reMap();" to readFully(), sync()
and write() methods is enough?
Thanks!