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

isServing is not thread safe

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.9.3, 0.10.0, 0.11.0, 0.12.0
    • 0.13.0
    • Java - Library

    Description

      We have some integration tests in storm were we create a TServer and call serve on it in a background thread, because it is a blocking call.

      Then in the main thread we wait for up to 10 seconds for isServing to return success with a 100ms sleep in between each call.

      I don't know if this is a java bug or what, but in some not so rare cases isServing does not return true during the entire 10 seconds and the test fails. The test prints out a stack trace when this happens and the background thread running the server is always at

      https://github.com/apache/thrift/blob/b636ffb613ab49e0f037fbe696d28a4b17a72c5f/lib/java/src/org/apache/thrift/server/AbstractNonblockingServer.java#L95

      happily serving.

      So either we got very unlucky many times and it takes just a few ms longer than 10 seconds to come up some times, and < 1 sec other times, or java is doing something strange some of the time, and because Server.isServing is not volatile the checking thread caches a copy of it in a register and never updates it during the 10 seconds of the test run.

      Even if it is a java bug, which I could argue probably is, it would be good to make isServing volatile.

      Attachments

        Issue Links

          Activity

            People

              jking3 James E. King III
              revans2 Robert Joseph Evans
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m