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

nonblocking_server shutdown race under Ruby 1.9

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.6.1
    • 0.7
    • Ruby - Library
    • None
    • OS X Darwin 10.6 i686 + Ruby 1.9.2-p180

    • Patch Available

    Description

      While testing some changes today I noticed that nonblocking_server tests pass for me under Ruby 1.8.7 but fail under Ruby 1.9.2. Here are the test failures:

      ...
      1)
      Errno::EBADF in 'Thrift::NonblockingServer should shut down when asked'
      Bad file descriptor
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:47:in `select'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:47:in `block in serve'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in `loop'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in `serve'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/spec/nonblocking_server_spec.rb:118:in `block (3 levels) in <class:ThriftNonblockingServerSpec>'

      2)
      Errno::EBADF in 'Thrift::NonblockingServer should continue processing active messages when shutting down'
      Bad file descriptor
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:47:in `select'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:47:in `block in serve'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in `loop'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in `serve'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/spec/nonblocking_server_spec.rb:118:in `block (3 levels) in <class:ThriftNonblockingServerSpec>'

      3)
      Errno::EBADF in 'Thrift::NonblockingServer should kill active messages when they don't expire while shutting down'
      Bad file descriptor
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:47:in `select'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:47:in `block in serve'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in `loop'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in `serve'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/spec/nonblocking_server_spec.rb:118:in `block (3 levels) in <class:ThriftNonblockingServerSpec>'

      4)
      Errno::EBADF in 'Thrift::NonblockingServer should allow shutting down in response to a message'
      Bad file descriptor
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:47:in `select'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:47:in `block in serve'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in `loop'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in `serve'
      /Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/spec/nonblocking_server_spec.rb:118:in `block (3 levels) in <class:ThriftNonblockingServerSpec>'
      ...

      I think that either the behavior of select() changed between 1.8.7 and 1.9.2, or the different threading model in 1.9.2 is tickling a timing bug. In any case, shutting down the server causes the @server_transport socket to be closed, which raises Errno::EBADF in the main loop inside the serve() method. Probably not a big deal because the server is shutting down anyway, but should be fixed so the tests pass.

      Will attach patch shortly.

      Attachments

        1. patch-THRIFT-1187.txt
          1.0 kB
          Ilya Maykov

        Activity

          People

            ilyam Ilya Maykov
            ilyam Ilya Maykov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: