java.nio.channels.ClosedChannelException and unrecoverable error

174 views
Skip to first unread message

Neil Avery

unread,
Jul 14, 2014, 10:41:46 AM7/14/14
to ma...@googlegroups.com
Hi All,

[Version 1.0.4]

We are experiencing the following Error when using mapDB is a fairly simple manner . The DB is created using:


val db: DB = DBMaker.newFileDB(new java.io.File(parentDir, "DbEvents")).closeOnJvmShutdown().cacheDisable().cacheSize(1024).transactionDisable().deleteFilesAfterClose().make()

Then we create treeMaps for user sessions - where data is pumped into their relevant instance...

db.createTreeMap(requestId).makeOrGet[java.lang.Long, ReplayEvent]


With a bit of thrashing about we experience the following Exception which the system cannot recover from. The Db is never closed - but there will be multiple streams going into successive trees concurrently.

Any clues?

Regards,
Na.

java.io.IOError: java.nio.channels.ClosedChannelException

at org.mapdb.Volume$FileChannelVol.getLong(Volume.java:837)

at org.mapdb.StoreDirect.get2(StoreDirect.java:440)

at org.mapdb.StoreDirect.get(StoreDirect.java:428)

at org.mapdb.EngineWrapper.get(EngineWrapper.java:58)

at org.mapdb.BTreeMap.get(BTreeMap.java:595)

at org.mapdb.BTreeMap.get(BTreeMap.java:589)

at org.mapdb.DB.catGet(DB.java:100)

at org.mapdb.DB$BTreeMapMaker.makeOrGet(DB.java:650)

at com.lll.play.replay.PerRequestSessionDb.<init>(PerRequestSessionDb.scala:23)


at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455$WSFrameHandler.onFrame(WebSocketConnectionRFC6455.java:835)

at org.eclipse.jetty.websocket.WebSocketParserRFC6455.parseNext(WebSocketParserRFC6455.java:349)

at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455.handle(WebSocketConnectionRFC6455.java:225)

at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)

at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)

at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)

at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)

at java.lang.Thread.run(Thread.java:744)

Caused by: java.nio.channels.ClosedChannelException

at sun.nio.ch.FileChannelImpl.ensureOpen(FileChannelImpl.java:99)

at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:678)

at org.mapdb.Volume$FileChannelVol.readFully(Volume.java:806)

at org.mapdb.Volume$FileChannelVol.getLong(Volume.java:834)

... 29 more

Jan Kotek

unread,
Jul 14, 2014, 1:52:25 PM7/14/14
to ma...@googlegroups.com, Neil Avery

Hi,

 

ClosedChannelException happens if one of the threads is interrupted while doing IO. The FileChannel gets closed on interruption and all future IOs will throw CCE. There is workaround to use memory-mapped files (mmapFileEnable()), but they only work on 64bit systems.

 

So either enable mmap or investigate what is interrupting your threads.

 

Jan

--
You received this message because you are subscribed to the Google Groups "MapDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapdb+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



Neil Avery

unread,
Jul 14, 2014, 1:59:01 PM7/14/14
to Jan Kotek, ma...@googlegroups.com

Brilliant - thank you!

Reply all
Reply to author
Forward
0 new messages