Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4598

TBinaryProtocol.readMessageBegin() hangs forever in Java

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 0.11.0
    • None
    • Java - Library
    • None
    • Ubuntu Linux 16.04 x86_64

    Description

      I run some internal tests for the robustness of our thrift Java server. One of the robustness tests is to try to connect to the secure server socket with an insecure client and vice versa. This may seem a slightly diabolic test but it can be a simple user error to forget enabling or disabling encryption. So I think thrift should handle this gracefully.

      However it seems that this test leads to an infinitely hanging server thread! The thread blocks the jvm (Java 1.8.0_161 x86_64) from ending. I can see in jstack that the main method ends and there are almost no threads left, except some garbage collectors and finalizers plus org.apache.thrift.server.TThreadPoolServer.

      Here is the call stack of the thrift server thread:

      java.lang.Thread.State: RUNNABLE
      at java.net.SocketInputStream.socketRead0(Native Method)
      at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
      at java.net.SocketInputStream.read(SocketInputStream.java:171)
      at java.net.SocketInputStream.read(SocketInputStream.java:141)
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
      at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
      - locked <0x000000067b390fd8> (a java.io.BufferedInputStream)
      at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:127)
      at org.apache.thrift.transport.TTransport.readAll(TTransport.java:86)
      at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:425)
      at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:321)
      at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:225)
      at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:27)
      at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:310)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
      

      I already reduced the server socket timeout to 30sec and the requestTimeout to 10sec. Is there anything else I can do to timeout readMessageBegin()?

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            jking3 James E. King III
            emmenlau Mario Emmenlauer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment