vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

File close is done from the wrong thread

Open luengnat opened this issue 10 years ago • 5 comments

Got this thread warning from time to time due to AsyncFileImpl.close is called from Vert.x event loop.

2016-08-24 17:17:22,228 WARN io.vertx.core.impl.BlockedThreadChecker [vertx-blocked-thread-checker] Thread Thread[vert.x-eventloop-thread-1,5,main] has been blocked for 44689 ms, time limit is 2000 io.vertx.core.VertxException: Thread blocked
        at sun.nio.ch.FileDispatcherImpl.close0(Native Method)
        at sun.nio.ch.FileDispatcherImpl.close(FileDispatcherImpl.java:98)
        at sun.nio.ch.SimpleAsynchronousFileChannelImpl.close(SimpleAsynchronousFileChannelImpl.java:102)
        at io.vertx.core.file.impl.AsyncFileImpl.doClose(AsyncFileImpl.java:464)
        at io.vertx.core.file.impl.AsyncFileImpl.lambda$closeInternal$5(AsyncFileImpl.java:482)
        at io.vertx.core.file.impl.AsyncFileImpl$$Lambda$531/233412243.run(Unknown Source)
        at io.vertx.core.file.impl.AsyncFileImpl.lambda$doWrite$0(AsyncFileImpl.java:153)
        at io.vertx.core.file.impl.AsyncFileImpl$$Lambda$523/830092490.handle(Unknown Source)
        at io.vertx.core.file.impl.AsyncFileImpl$1.lambda$completed$0(AsyncFileImpl.java:394)
        at io.vertx.core.file.impl.AsyncFileImpl$1$$Lambda$525/1409392663.handle(Unknown Source)
        at io.vertx.core.impl.ContextImpl.lambda$wrapTask$3(ContextImpl.java:359)
        at io.vertx.core.impl.ContextImpl$$Lambda$122/405091754.run(Unknown Source)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:339)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:393)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742)
        at java.lang.Thread.run(Thread.java:745)

luengnat avatar Aug 25 '16 00:08 luengnat

hi, can you provide a reproducer ?

vietj avatar Aug 25 '16 10:08 vietj

I don't know how to provide a reproducer for this one as the code works fine most of the time but when a disk is slow, it can block the event loop thread. It seems like close() is always called from the event loop thread which is probably wrong.

luengnat avatar Aug 25 '16 18:08 luengnat

yep, it seems fairly easy to reproduce but never happens in tests.

vietj avatar Aug 25 '16 18:08 vietj

Well... because close() is usually fast unless the disk is really busy

luengnat avatar Aug 25 '16 23:08 luengnat

just noticed that this has been fixed already a few days ago https://github.com/eclipse/vert.x/issues/1573

vietj avatar Aug 26 '16 07:08 vietj