Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8139972

Interrupting an NIO thread blocks the interrupting thread

XMLWordPrintable

    • x86_64
    • linux

      FULL PRODUCT VERSION :
      java version "1.8.0_40"
      Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
      Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux hostname 3.10.75-82_fbk20_hotfix1_04883_g46b04b0 #1 SMP Thu May 28 16:25:56 PDT 2015 x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      A worker thread calls FileChannel.force(false) which ends up doing an fdatasync() system call. The target of the fdatasync() is on a buggy FUSE mount (Gluster) which causes the system call to hang.

      A different thread calls Thread.interrupt() on the worker thread. This interrupting thread hangs in the NativeThreadSet.signalAndWait() method waiting for the system call (in the other thread) to return.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Thread.interrupt() should never hang the interrupting thread. The reason we moved our file operations to a separate thread was to avoid buggy system calls from hanging the application.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      INTERRUPTING THREAD:
      "interrupting-thread" #12509 prio=5 os_prio=0 tid=0x00007f7f10063000 nid=0x3e67a in Object.wait() [0x00007f7d58126000]
         java.lang.Thread.State: TIMED_WAITING (on object monitor)
      at java.lang.Object.wait(Native Method)
      at sun.nio.ch.NativeThreadSet.signalAndWait(NativeThreadSet.java:101)
      - locked <0x00007f86336b5540> (a sun.nio.ch.NativeThreadSet)
      at sun.nio.ch.FileChannelImpl.implCloseChannel(FileChannelImpl.java:129)
      at java.nio.channels.spi.AbstractInterruptibleChannel$1.interrupt(AbstractInterruptibleChannel.java:165)
      - locked <0x00007f86336b5560> (a java.lang.Object)
      at java.lang.Thread.interrupt(Thread.java:919)
      - locked <0x00007f86c01a91e0> (a java.lang.Object)
      at java.util.concurrent.FutureTask.cancel(FutureTask.java:174)

      WORKER THREAD:
      "worker-thread" #50310 daemon prio=5 os_prio=0 tid=0x00007f7bd3306000 nid=0xe823b runnable [0x00007f7d34409000]
         java.lang.Thread.State: RUNNABLE
      at sun.nio.ch.FileDispatcherImpl.force0(Native Method)
      at sun.nio.ch.FileDispatcherImpl.force(FileDispatcherImpl.java:76)
      at sun.nio.ch.FileChannelImpl.force(FileChannelImpl.java:386)


      REPRODUCIBILITY :
      This bug can be reproduced always.

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: